blob: 35f630a810cb994d01e90bd664d5234c4068ac7e [file] [log] [blame]
Satish Kf6d87cb2015-11-30 19:59:22 +05301/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2015-present Open Networking Foundation
Satish Kf6d87cb2015-11-30 19:59:22 +05303 *
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.iptopology.api;
17
18import static com.google.common.base.MoreObjects.toStringHelper;
19
20import java.util.Objects;
21
22/**
23 * Represents Position of device in the network.
24 */
25public class Position {
26 private final Boolean asbr;
27 private final Boolean abr;
28
29 /**
30 * Constructor to set position of device.
31 *
32 * @param asbr autonomous system boundary router
33 * @param abr area boundary router
34 */
35 public Position(Boolean asbr, Boolean abr) {
36 this.asbr = asbr;
37 this.abr = abr;
38 }
39
40 /**
41 * obtain whether the device is autonomous system boundary router or not.
42 *
43 * @return autonomous system boundary router or not
44 */
45 Boolean asbr() {
46 return asbr;
47 }
48
49 /**
50 * obtain whether the device is area boundary router or not.
51 *
52 * @return area boundary router or not
53 */
54 Boolean abr() {
55 return abr;
56 }
57
58 @Override
59 public int hashCode() {
60 return Objects.hash(abr, asbr);
61 }
62
63 @Override
64 public boolean equals(Object obj) {
65 if (this == obj) {
66 return true;
67 }
68
69 if (obj instanceof Position) {
70 Position other = (Position) obj;
71 return Objects.equals(abr, other.abr) && Objects.equals(asbr, other.asbr);
72 }
73 return false;
74 }
75
76 @Override
77 public String toString() {
78 return toStringHelper(this)
79 .omitNullValues()
80 .add("abrBit", abr)
81 .add("asbrBit", asbr)
82 .toString();
83 }
84}