blob: fbe6955d0562cb3520cbbf2cb5c0ca5ac9abc092 [file] [log] [blame]
Aihua Guo1ce2dd12016-08-12 23:37:44 -04001/*
2 * Copyright 2016 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.tetopology.management.api.link;
17
18import java.util.Objects;
19
20import com.google.common.base.MoreObjects;
21
22/**
Henry Yu4b4a7eb2016-11-09 20:07:53 -050023 * Implementation of Autonomous System (AS) number as an ElementType.
Aihua Guo1ce2dd12016-08-12 23:37:44 -040024 */
25public class AsNumber implements ElementType {
26 private final int asNumber;
27
28 /**
29 * Creates an instance of AsNumber.
30 *
Henry Yu4b4a7eb2016-11-09 20:07:53 -050031 * @param asNumber autonomous system number
Aihua Guo1ce2dd12016-08-12 23:37:44 -040032 */
33 public AsNumber(int asNumber) {
34 this.asNumber = asNumber;
35 }
36
37 /**
Henry Yu4b4a7eb2016-11-09 20:07:53 -050038 * Returns the autonomous system number.
Aihua Guo1ce2dd12016-08-12 23:37:44 -040039 *
Henry Yu4b4a7eb2016-11-09 20:07:53 -050040 * @return the AS number
Aihua Guo1ce2dd12016-08-12 23:37:44 -040041 */
Henry Yu4b4a7eb2016-11-09 20:07:53 -050042 public int asNumber() {
Aihua Guo1ce2dd12016-08-12 23:37:44 -040043 return asNumber;
44 }
45
46 @Override
47 public int hashCode() {
48 return Objects.hash(asNumber);
49 }
50
51 @Override
52 public boolean equals(Object obj) {
53 if (this == obj) {
54 return true;
55 }
56 if (obj instanceof AsNumber) {
57 AsNumber other = (AsNumber) obj;
58 return Objects.equals(asNumber, other.asNumber);
59 }
60 return false;
61 }
62
63 @Override
64 public String toString() {
65 return MoreObjects.toStringHelper(getClass())
66 .add("asNumber", asNumber)
67 .toString();
68 }
69
70}