blob: 9032cc47c80a28c88b6dcba6c1adcfdc8bec4f6a [file] [log] [blame]
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07001/*
2 * Copyright 2014 Open Networking Laboratory
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
Toshio Koide485b4782014-10-20 19:34:21 -070016package org.onlab.onos.net.resource;
17
Brian O'Connorfe0f4b12014-10-30 21:19:02 -070018import com.google.common.base.MoreObjects;
19
Brian O'Connor41718fc2014-10-30 16:57:21 -070020import java.util.Objects;
21
Toshio Koide485b4782014-10-20 19:34:21 -070022/**
23 * Representation of allocated lambda resource.
24 */
Toshio Koided707d7a2014-10-23 12:37:51 -070025public class LambdaResourceAllocation extends LambdaResourceRequest
26 implements ResourceAllocation {
Toshio Koidefa0dff62014-10-23 11:46:44 -070027 private final Lambda lambda;
28
Toshio Koided1865a42014-10-23 12:44:55 -070029 @Override
30 public ResourceType type() {
31 return ResourceType.LAMBDA;
32 }
33
Toshio Koidefa0dff62014-10-23 11:46:44 -070034 /**
35 * Creates a new {@link LambdaResourceAllocation} with {@link Lambda}
36 * object.
37 *
38 * @param lambda allocated lambda
39 */
40 public LambdaResourceAllocation(Lambda lambda) {
41 this.lambda = lambda;
42 }
43
Toshio Koide485b4782014-10-20 19:34:21 -070044 /**
45 * Returns the lambda resource.
46 *
47 * @return the lambda resource
48 */
Toshio Koided1865a42014-10-23 12:44:55 -070049 public Lambda lambda() {
Toshio Koidefa0dff62014-10-23 11:46:44 -070050 return lambda;
51 }
Brian O'Connor41718fc2014-10-30 16:57:21 -070052
53 @Override
54 public int hashCode() {
55 return Objects.hash(lambda);
56 }
57
58 @Override
59 public boolean equals(Object obj) {
60 if (this == obj) {
61 return true;
62 }
63 if (obj == null || getClass() != obj.getClass()) {
64 return false;
65 }
66 final LambdaResourceAllocation other = (LambdaResourceAllocation) obj;
67 return Objects.equals(this.lambda, other.lambda);
68 }
Brian O'Connorfe0f4b12014-10-30 21:19:02 -070069
70 @Override
71 public String toString() {
72 return MoreObjects.toStringHelper(this)
73 .add("lambda", lambda)
74 .toString();
75 }
Toshio Koide485b4782014-10-20 19:34:21 -070076}