Jian Li | 6b77dc0 | 2016-07-14 16:04:25 +0900 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2016-present 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.lisp.msg.types; |
| 17 | |
Jian Li | d56f97e | 2016-07-19 15:48:15 +0900 | [diff] [blame^] | 18 | import java.util.Objects; |
| 19 | |
Jian Li | 6b77dc0 | 2016-07-14 16:04:25 +0900 | [diff] [blame] | 20 | /** |
| 21 | * The identifier of Autonomous System (AS). |
| 22 | */ |
| 23 | public class LispAsAddress extends LispAfiAddress { |
| 24 | |
| 25 | private final int asNum; |
| 26 | |
| 27 | /** |
| 28 | * Initializes AS identifier number. |
| 29 | * |
| 30 | * @param num AS number |
| 31 | */ |
| 32 | public LispAsAddress(int num) { |
| 33 | super(AddressFamilyIdentifierEnum.AS); |
| 34 | this.asNum = num; |
| 35 | } |
| 36 | |
| 37 | /** |
| 38 | * Obtains AS identifier number. |
| 39 | * |
| 40 | * @return AS number |
| 41 | */ |
| 42 | public int getASNum() { |
| 43 | return asNum; |
| 44 | } |
| 45 | |
| 46 | @Override |
| 47 | public int hashCode() { |
Jian Li | d56f97e | 2016-07-19 15:48:15 +0900 | [diff] [blame^] | 48 | return Objects.hash(asNum); |
Jian Li | 6b77dc0 | 2016-07-14 16:04:25 +0900 | [diff] [blame] | 49 | } |
| 50 | |
| 51 | @Override |
| 52 | public boolean equals(Object obj) { |
| 53 | if (this == obj) { |
| 54 | return true; |
| 55 | } |
| 56 | |
| 57 | if (!super.equals(obj)) { |
| 58 | return false; |
| 59 | } |
| 60 | |
| 61 | if (getClass() != obj.getClass()) { |
| 62 | return false; |
| 63 | } |
| 64 | |
| 65 | LispAsAddress other = (LispAsAddress) obj; |
| 66 | if (asNum != other.asNum) { |
| 67 | return false; |
| 68 | } |
| 69 | return true; |
| 70 | } |
| 71 | |
| 72 | @Override |
| 73 | public String toString() { |
| 74 | return String.valueOf(asNum); |
| 75 | } |
| 76 | } |