blob: fb5c616a5b393a204c3ed86725917c1c68457e0d [file] [log] [blame]
Jian Li6b77dc02016-07-14 16:04:25 +09001/*
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 */
16package org.onosproject.lisp.msg.types;
17
Jian Lid56f97e2016-07-19 15:48:15 +090018import java.util.Objects;
19
Jian Li6b77dc02016-07-14 16:04:25 +090020/**
21 * The identifier of Autonomous System (AS).
22 */
23public 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 Lid56f97e2016-07-19 15:48:15 +090048 return Objects.hash(asNum);
Jian Li6b77dc02016-07-14 16:04:25 +090049 }
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}