blob: 161cf45515be3d1d359315205b58113a914253ac [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 */
Brian O'Connor6de2e202015-05-21 14:30:41 -070016package org.onosproject.net.resource.link;
Toshio Koide485b4782014-10-20 19:34:21 -070017
Brian O'Connorfe0f4b12014-10-30 21:19:02 -070018import com.google.common.base.MoreObjects;
Brian O'Connor6de2e202015-05-21 14:30:41 -070019import org.onosproject.net.resource.ResourceAllocation;
20import org.onosproject.net.resource.ResourceType;
Brian O'Connorfe0f4b12014-10-30 21:19:02 -070021
Brian O'Connor41718fc2014-10-30 16:57:21 -070022import java.util.Objects;
23
Toshio Koide485b4782014-10-20 19:34:21 -070024/**
25 * Representation of allocated lambda resource.
26 */
Sho SHIMIZUc4d56612015-07-02 13:54:09 -070027public class LambdaResourceAllocation implements ResourceAllocation {
Sho SHIMIZU94b7ff42015-05-06 17:51:49 -070028 private final LambdaResource lambda;
Toshio Koidefa0dff62014-10-23 11:46:44 -070029
Toshio Koided1865a42014-10-23 12:44:55 -070030 @Override
31 public ResourceType type() {
32 return ResourceType.LAMBDA;
33 }
34
Toshio Koidefa0dff62014-10-23 11:46:44 -070035 /**
Sho SHIMIZU94b7ff42015-05-06 17:51:49 -070036 * Creates a new {@link LambdaResourceAllocation} with {@link LambdaResource}
Toshio Koidefa0dff62014-10-23 11:46:44 -070037 * object.
38 *
39 * @param lambda allocated lambda
40 */
Sho SHIMIZU94b7ff42015-05-06 17:51:49 -070041 public LambdaResourceAllocation(LambdaResource lambda) {
Toshio Koidefa0dff62014-10-23 11:46:44 -070042 this.lambda = lambda;
43 }
44
Toshio Koide485b4782014-10-20 19:34:21 -070045 /**
46 * Returns the lambda resource.
47 *
48 * @return the lambda resource
49 */
Sho SHIMIZU94b7ff42015-05-06 17:51:49 -070050 public LambdaResource lambda() {
Toshio Koidefa0dff62014-10-23 11:46:44 -070051 return lambda;
52 }
Brian O'Connor41718fc2014-10-30 16:57:21 -070053
54 @Override
55 public int hashCode() {
HIGUCHI Yutaca9cc8e2015-10-29 23:26:51 -070056 return Objects.hashCode(lambda);
Brian O'Connor41718fc2014-10-30 16:57:21 -070057 }
58
59 @Override
60 public boolean equals(Object obj) {
61 if (this == obj) {
62 return true;
63 }
64 if (obj == null || getClass() != obj.getClass()) {
65 return false;
66 }
67 final LambdaResourceAllocation other = (LambdaResourceAllocation) obj;
68 return Objects.equals(this.lambda, other.lambda);
69 }
Brian O'Connorfe0f4b12014-10-30 21:19:02 -070070
71 @Override
72 public String toString() {
73 return MoreObjects.toStringHelper(this)
74 .add("lambda", lambda)
75 .toString();
76 }
Toshio Koide485b4782014-10-20 19:34:21 -070077}