blob: 17a488a47e3fd7690af5b9b2f2e74daf4ebfdc88 [file] [log] [blame]
Aihua Guo1ce2dd12016-08-12 23:37:44 -04001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2016 Open Networking Foundation
Aihua Guo1ce2dd12016-08-12 23:37:44 -04003 *
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 */
Henry Yu4b4a7eb2016-11-09 20:07:53 -050016package org.onosproject.tetopology.management.api;
Aihua Guo1ce2dd12016-08-12 23:37:44 -040017
18import com.google.common.base.MoreObjects;
19
Henry Yu4b4a7eb2016-11-09 20:07:53 -050020import java.util.Objects;
21
Aihua Guo1ce2dd12016-08-12 23:37:44 -040022/**
Henry Yu4b4a7eb2016-11-09 20:07:53 -050023 * Implementation of using a long integer to represent
24 * an ElementType.
Aihua Guo1ce2dd12016-08-12 23:37:44 -040025 */
Henry Yu4b4a7eb2016-11-09 20:07:53 -050026public class LongValue {
Aihua Guo1ce2dd12016-08-12 23:37:44 -040027 private final long value;
28
29 /**
Henry Yu4b4a7eb2016-11-09 20:07:53 -050030 * Creates an instance of LongValue.
Aihua Guo1ce2dd12016-08-12 23:37:44 -040031 *
Henry Yu4b4a7eb2016-11-09 20:07:53 -050032 * @param value long value
Aihua Guo1ce2dd12016-08-12 23:37:44 -040033 */
Henry Yu4b4a7eb2016-11-09 20:07:53 -050034 public LongValue(long value) {
35 this.value = value;
Aihua Guo1ce2dd12016-08-12 23:37:44 -040036 }
37
38 /**
Henry Yu4b4a7eb2016-11-09 20:07:53 -050039 * Returns the long integer representing the ElementType.
Aihua Guo1ce2dd12016-08-12 23:37:44 -040040 *
Henry Yu4b4a7eb2016-11-09 20:07:53 -050041 * @return long integer
Aihua Guo1ce2dd12016-08-12 23:37:44 -040042 */
Henry Yu4b4a7eb2016-11-09 20:07:53 -050043 public long value() {
Aihua Guo1ce2dd12016-08-12 23:37:44 -040044 return value;
45 }
46
47 @Override
48 public int hashCode() {
49 return Objects.hash(value);
50 }
51
52 @Override
53 public boolean equals(Object obj) {
54 if (this == obj) {
55 return true;
56 }
Henry Yu4b4a7eb2016-11-09 20:07:53 -050057 if (obj instanceof LongValue) {
58 LongValue other = (LongValue) obj;
59 return Objects.equals(value, other.value);
Aihua Guo1ce2dd12016-08-12 23:37:44 -040060 }
61 return false;
62 }
63
64 @Override
65 public String toString() {
66 return MoreObjects.toStringHelper(getClass())
Henry Yu4b4a7eb2016-11-09 20:07:53 -050067 .add("value", value)
68 .toString();
Aihua Guo1ce2dd12016-08-12 23:37:44 -040069 }
70}