blob: 574f4405a557aaff56fc96c04214aab13f50f221 [file] [log] [blame]
sunish vk7bdf4d42016-06-24 12:29:43 +05301/*
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.isis.controller.impl.topology;
17
18import com.google.common.base.MoreObjects;
19import com.google.common.base.Objects;
20import org.onlab.packet.Ip4Address;
21import org.onosproject.isis.controller.topology.LinkInformation;
22
23/**
24 * Representation of an ISIS link information..
25 */
26public class DefaultIsisLinkInformation implements LinkInformation {
27
28 String linkId;
29 String linkSourceId;
30 String linkDestinationId;
31 Ip4Address interfaceIp;
32 Ip4Address neighborIp;
33 boolean alreadyCreated;
34
35 /**
36 * Gets link id.
37 *
38 * @return link id
39 */
40 public String linkId() {
41 return linkId;
42 }
43
44 /**
45 * Sets link id.DefaultIsisDeviceInformation.
46 *
47 * @param linkId link id
48 */
49 public void setLinkId(String linkId) {
50 this.linkId = linkId;
51 }
52
53 /**
54 * Gets is already created or not.
55 *
56 * @return true if already created else false
57 */
58 public boolean isAlreadyCreated() {
59 return alreadyCreated;
60 }
61
62 /**
63 * Sets is already created or not.
64 *
65 * @param alreadyCreated true or false
66 */
67 public void setAlreadyCreated(boolean alreadyCreated) {
68 this.alreadyCreated = alreadyCreated;
69 }
70
71 /**
72 * Gets link destination id.
73 *
74 * @return link destination id
75 */
76 public String linkDestinationId() {
77 return linkDestinationId;
78 }
79
80 /**
81 * Sets link destination id.
82 *
83 * @param linkDestinationId link destination id
84 */
85 public void setLinkDestinationId(String linkDestinationId) {
86 this.linkDestinationId = linkDestinationId;
87 }
88
89 /**
90 * Gets link source id.
91 *
92 * @return link source id
93 */
94 public String linkSourceId() {
95 return linkSourceId;
96 }
97
98 /**
99 * Sets link source id.
100 *
101 * @param linkSourceId link source id
102 */
103 public void setLinkSourceId(String linkSourceId) {
104 this.linkSourceId = linkSourceId;
105 }
106
107 /**
108 * Gets interface IP address.
109 *
110 * @return interface IP address
111 */
112 public Ip4Address interfaceIp() {
113 return interfaceIp;
114 }
115
116 /**
117 * Sets interface IP address.
118 *
119 * @param interfaceIp interface IP address
120 */
121 public void setInterfaceIp(Ip4Address interfaceIp) {
122 this.interfaceIp = interfaceIp;
123 }
124
125 @Override
126 public Ip4Address neighborIp() {
127 return this.neighborIp;
128 }
129
130 @Override
131 public void setNeighborIp(Ip4Address neighborIp) {
132 this.neighborIp = neighborIp;
133 }
134
135 @Override
136 public String toString() {
137 return MoreObjects.toStringHelper(getClass())
138 .omitNullValues()
139 .add("linkId", linkId)
140 .add("linkSourceId", linkSourceId)
141 .add("linkDestinationId", linkDestinationId)
142 .add("interfaceIp", interfaceIp)
143 .toString();
144 }
145
146 @Override
147 public boolean equals(Object o) {
148 if (this == o) {
149 return true;
150 }
151 if (o == null || getClass() != o.getClass()) {
152 return false;
153 }
154 DefaultIsisLinkInformation that = (DefaultIsisLinkInformation) o;
155 return Objects.equal(linkId, that.linkId) &&
156 Objects.equal(linkSourceId, that.linkSourceId) &&
157 Objects.equal(linkDestinationId, that.linkDestinationId) &&
158 Objects.equal(interfaceIp, that.interfaceIp);
159 }
160
161 @Override
162 public int hashCode() {
163 return Objects.hashCode(linkId, linkSourceId, linkDestinationId,
164 interfaceIp);
165 }
166}