blob: aa14f701f1830ff70f9b5b1584a89b833c3de494 [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'Connorabafb502014-12-02 22:26:20 -080016package org.onosproject.net.resource;
Toshio Koidec9051db2014-10-20 15:18:37 -070017
18import java.util.Objects;
19
20/**
21 * Representation of lambda resource.
22 */
Sho SHIMIZU94b7ff42015-05-06 17:51:49 -070023public final class LambdaResource extends LinkResource {
Toshio Koidec9051db2014-10-20 15:18:37 -070024
25 private final int lambda;
26
27 /**
28 * Creates a new instance with given lambda.
29 *
30 * @param lambda lambda value to be assigned
31 */
Sho SHIMIZU94b7ff42015-05-06 17:51:49 -070032 private LambdaResource(int lambda) {
Toshio Koidec9051db2014-10-20 15:18:37 -070033 this.lambda = lambda;
34 }
35
Thomas Vachuska7d0032b2014-11-04 17:39:57 -080036 // Constructor for serialization
Sho SHIMIZU94b7ff42015-05-06 17:51:49 -070037 private LambdaResource() {
Thomas Vachuska7d0032b2014-11-04 17:39:57 -080038 this.lambda = 0;
39 }
40
Toshio Koidec9051db2014-10-20 15:18:37 -070041 /**
42 * Creates a new instance with given lambda.
43 *
44 * @param lambda lambda value to be assigned
Sho SHIMIZU94b7ff42015-05-06 17:51:49 -070045 * @return {@link LambdaResource} instance with given lambda
Toshio Koidec9051db2014-10-20 15:18:37 -070046 */
Sho SHIMIZU94b7ff42015-05-06 17:51:49 -070047 public static LambdaResource valueOf(int lambda) {
48 return new LambdaResource(lambda);
Toshio Koidec9051db2014-10-20 15:18:37 -070049 }
50
51 /**
52 * Returns lambda as an int value.
Toshio Koide485b4782014-10-20 19:34:21 -070053 *
Toshio Koidec9051db2014-10-20 15:18:37 -070054 * @return lambda as an int value
55 */
56 public int toInt() {
57 return lambda;
58 }
59
60 @Override
61 public boolean equals(Object obj) {
Sho SHIMIZU94b7ff42015-05-06 17:51:49 -070062 if (obj instanceof LambdaResource) {
63 LambdaResource that = (LambdaResource) obj;
Toshio Koidec9051db2014-10-20 15:18:37 -070064 return Objects.equals(this.lambda, that.lambda);
65 }
66 return false;
67 }
68
69 @Override
70 public int hashCode() {
Sho SHIMIZUab392832015-04-28 19:08:14 -070071 return lambda;
Toshio Koidec9051db2014-10-20 15:18:37 -070072 }
73
74 @Override
75 public String toString() {
76 return String.valueOf(this.lambda);
77 }
78
79}