blob: cb31108a311c4af783aeaa975ddc2a302e5ddeb1 [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
18/**
19 * The identifier of Autonomous System (AS).
20 */
21public class LispAsAddress extends LispAfiAddress {
22
23 private final int asNum;
24
25 /**
26 * Initializes AS identifier number.
27 *
28 * @param num AS number
29 */
30 public LispAsAddress(int num) {
31 super(AddressFamilyIdentifierEnum.AS);
32 this.asNum = num;
33 }
34
35 /**
36 * Obtains AS identifier number.
37 *
38 * @return AS number
39 */
40 public int getASNum() {
41 return asNum;
42 }
43
44 @Override
45 public int hashCode() {
46 final int prime = 31;
47 int result = super.hashCode();
48 result = prime * result + asNum;
49 return result;
50 }
51
52 @Override
53 public boolean equals(Object obj) {
54 if (this == obj) {
55 return true;
56 }
57
58 if (!super.equals(obj)) {
59 return false;
60 }
61
62 if (getClass() != obj.getClass()) {
63 return false;
64 }
65
66 LispAsAddress other = (LispAsAddress) obj;
67 if (asNum != other.asNum) {
68 return false;
69 }
70 return true;
71 }
72
73 @Override
74 public String toString() {
75 return String.valueOf(asNum);
76 }
77}