blob: 210bba6e255a1dd1b7943de2653c3b8b243c001c [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 */
Toshio Koided707d7a2014-10-23 12:37:51 -070027public class LambdaResourceAllocation extends LambdaResourceRequest
28 implements ResourceAllocation {
Sho SHIMIZU94b7ff42015-05-06 17:51:49 -070029 private final LambdaResource lambda;
Toshio Koidefa0dff62014-10-23 11:46:44 -070030
Toshio Koided1865a42014-10-23 12:44:55 -070031 @Override
32 public ResourceType type() {
33 return ResourceType.LAMBDA;
34 }
35
Toshio Koidefa0dff62014-10-23 11:46:44 -070036 /**
Sho SHIMIZU94b7ff42015-05-06 17:51:49 -070037 * Creates a new {@link LambdaResourceAllocation} with {@link LambdaResource}
Toshio Koidefa0dff62014-10-23 11:46:44 -070038 * object.
39 *
40 * @param lambda allocated lambda
41 */
Sho SHIMIZU94b7ff42015-05-06 17:51:49 -070042 public LambdaResourceAllocation(LambdaResource lambda) {
Toshio Koidefa0dff62014-10-23 11:46:44 -070043 this.lambda = lambda;
44 }
45
Toshio Koide485b4782014-10-20 19:34:21 -070046 /**
47 * Returns the lambda resource.
48 *
49 * @return the lambda resource
50 */
Sho SHIMIZU94b7ff42015-05-06 17:51:49 -070051 public LambdaResource lambda() {
Toshio Koidefa0dff62014-10-23 11:46:44 -070052 return lambda;
53 }
Brian O'Connor41718fc2014-10-30 16:57:21 -070054
55 @Override
56 public int hashCode() {
57 return Objects.hash(lambda);
58 }
59
60 @Override
61 public boolean equals(Object obj) {
62 if (this == obj) {
63 return true;
64 }
65 if (obj == null || getClass() != obj.getClass()) {
66 return false;
67 }
68 final LambdaResourceAllocation other = (LambdaResourceAllocation) obj;
69 return Objects.equals(this.lambda, other.lambda);
70 }
Brian O'Connorfe0f4b12014-10-30 21:19:02 -070071
72 @Override
73 public String toString() {
74 return MoreObjects.toStringHelper(this)
75 .add("lambda", lambda)
76 .toString();
77 }
Toshio Koide485b4782014-10-20 19:34:21 -070078}