Satish K | f6d87cb | 2015-11-30 19:59:22 +0530 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2015 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 | */ |
| 16 | package org.onosproject.iptopology.api; |
| 17 | |
| 18 | import static com.google.common.base.MoreObjects.toStringHelper; |
| 19 | |
| 20 | import java.util.Objects; |
| 21 | |
| 22 | /** |
| 23 | * Represents administrative group color. |
| 24 | * bit mask - least significant bit is referred to as 'group 0', |
| 25 | * and the most significant bit is referred to as 'group 31' |
| 26 | */ |
| 27 | public class Color { |
| 28 | private final int color; |
| 29 | |
| 30 | /** |
| 31 | * Constructor to initialize its parameter. |
| 32 | * |
| 33 | * @param color assigned by the network administrator |
| 34 | */ |
| 35 | public Color(int color) { |
| 36 | this.color = color; |
| 37 | } |
| 38 | |
| 39 | /** |
| 40 | * Obtains administrative group. |
| 41 | * |
| 42 | * @return administrative group |
| 43 | */ |
| 44 | public int color() { |
| 45 | return color; |
| 46 | } |
| 47 | |
| 48 | @Override |
| 49 | public int hashCode() { |
| 50 | return Objects.hash(color); |
| 51 | } |
| 52 | |
| 53 | @Override |
| 54 | public boolean equals(Object obj) { |
| 55 | if (this == obj) { |
| 56 | return true; |
| 57 | } |
| 58 | |
| 59 | if (obj instanceof Color) { |
| 60 | Color other = (Color) obj; |
| 61 | return Objects.equals(color, other.color); |
| 62 | } |
| 63 | return false; |
| 64 | } |
| 65 | |
| 66 | @Override |
| 67 | public String toString() { |
| 68 | return toStringHelper(this) |
| 69 | .add("color", color) |
| 70 | .toString(); |
| 71 | } |
| 72 | } |