blob: be0325432a1b2c0096721cb1997f99299821ae88 [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 */
23public final class Lambda extends LinkResource {
24
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 */
32 private Lambda(int lambda) {
33 this.lambda = lambda;
34 }
35
Thomas Vachuska7d0032b2014-11-04 17:39:57 -080036 // Constructor for serialization
37 private Lambda() {
38 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
45 * @return {@link Lambda} instance with given lambda
46 */
47 public static Lambda valueOf(int lambda) {
48 return new Lambda(lambda);
49 }
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) {
62 if (obj instanceof Lambda) {
63 Lambda that = (Lambda) obj;
64 return Objects.equals(this.lambda, that.lambda);
65 }
66 return false;
67 }
68
69 @Override
70 public int hashCode() {
71 return Objects.hashCode(this.lambda);
72 }
73
74 @Override
75 public String toString() {
76 return String.valueOf(this.lambda);
77 }
78
79}