blob: 8e46d227f67aeb357c91b48f8c1a77d5ed6b723a [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/**
23 * Implementation of Automous System (AS) number as an ElementType.
24 */
25public class AsNumber implements ElementType {
26 private final int asNumber;
27
28 /**
29 * Creates an instance of AsNumber.
30 *
31 * @param asNumber value of autonomous system number
32 */
33 public AsNumber(int asNumber) {
34 this.asNumber = asNumber;
35 }
36
37 /**
38 * Returns the asNumber.
39 *
40 * @return value of the autonomous system number
41 */
42 public int getAsNumber() {
43 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}