Aihua Guo | 1ce2dd1 | 2016-08-12 23:37:44 -0400 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame^] | 2 | * Copyright 2016 Open Networking Foundation |
Aihua Guo | 1ce2dd1 | 2016-08-12 23:37:44 -0400 | [diff] [blame] | 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 | */ |
Henry Yu | 4b4a7eb | 2016-11-09 20:07:53 -0500 | [diff] [blame] | 16 | package org.onosproject.tetopology.management.api; |
Aihua Guo | 1ce2dd1 | 2016-08-12 23:37:44 -0400 | [diff] [blame] | 17 | |
| 18 | import com.google.common.base.MoreObjects; |
| 19 | |
Henry Yu | 4b4a7eb | 2016-11-09 20:07:53 -0500 | [diff] [blame] | 20 | import java.util.Objects; |
| 21 | |
Aihua Guo | 1ce2dd1 | 2016-08-12 23:37:44 -0400 | [diff] [blame] | 22 | /** |
Henry Yu | 4b4a7eb | 2016-11-09 20:07:53 -0500 | [diff] [blame] | 23 | * Implementation of using a long integer to represent |
| 24 | * an ElementType. |
Aihua Guo | 1ce2dd1 | 2016-08-12 23:37:44 -0400 | [diff] [blame] | 25 | */ |
Henry Yu | 4b4a7eb | 2016-11-09 20:07:53 -0500 | [diff] [blame] | 26 | public class LongValue { |
Aihua Guo | 1ce2dd1 | 2016-08-12 23:37:44 -0400 | [diff] [blame] | 27 | private final long value; |
| 28 | |
| 29 | /** |
Henry Yu | 4b4a7eb | 2016-11-09 20:07:53 -0500 | [diff] [blame] | 30 | * Creates an instance of LongValue. |
Aihua Guo | 1ce2dd1 | 2016-08-12 23:37:44 -0400 | [diff] [blame] | 31 | * |
Henry Yu | 4b4a7eb | 2016-11-09 20:07:53 -0500 | [diff] [blame] | 32 | * @param value long value |
Aihua Guo | 1ce2dd1 | 2016-08-12 23:37:44 -0400 | [diff] [blame] | 33 | */ |
Henry Yu | 4b4a7eb | 2016-11-09 20:07:53 -0500 | [diff] [blame] | 34 | public LongValue(long value) { |
| 35 | this.value = value; |
Aihua Guo | 1ce2dd1 | 2016-08-12 23:37:44 -0400 | [diff] [blame] | 36 | } |
| 37 | |
| 38 | /** |
Henry Yu | 4b4a7eb | 2016-11-09 20:07:53 -0500 | [diff] [blame] | 39 | * Returns the long integer representing the ElementType. |
Aihua Guo | 1ce2dd1 | 2016-08-12 23:37:44 -0400 | [diff] [blame] | 40 | * |
Henry Yu | 4b4a7eb | 2016-11-09 20:07:53 -0500 | [diff] [blame] | 41 | * @return long integer |
Aihua Guo | 1ce2dd1 | 2016-08-12 23:37:44 -0400 | [diff] [blame] | 42 | */ |
Henry Yu | 4b4a7eb | 2016-11-09 20:07:53 -0500 | [diff] [blame] | 43 | public long value() { |
Aihua Guo | 1ce2dd1 | 2016-08-12 23:37:44 -0400 | [diff] [blame] | 44 | 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 Yu | 4b4a7eb | 2016-11-09 20:07:53 -0500 | [diff] [blame] | 57 | if (obj instanceof LongValue) { |
| 58 | LongValue other = (LongValue) obj; |
| 59 | return Objects.equals(value, other.value); |
Aihua Guo | 1ce2dd1 | 2016-08-12 23:37:44 -0400 | [diff] [blame] | 60 | } |
| 61 | return false; |
| 62 | } |
| 63 | |
| 64 | @Override |
| 65 | public String toString() { |
| 66 | return MoreObjects.toStringHelper(getClass()) |
Henry Yu | 4b4a7eb | 2016-11-09 20:07:53 -0500 | [diff] [blame] | 67 | .add("value", value) |
| 68 | .toString(); |
Aihua Guo | 1ce2dd1 | 2016-08-12 23:37:44 -0400 | [diff] [blame] | 69 | } |
| 70 | } |