blob: 1b47cf90da8040cb18309faeb6f911faafd4a1d2 [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 org.onlab.packet.IpAddress;
21
22import com.google.common.base.MoreObjects;
23
24/**
25 * Implementation of unnumbered link as an ElementType.
26 */
27public class UnnumberedLink implements ElementType {
28 private IpAddress routerId;
29 private long interfaceId;
30
31 /**
32 * Creates an instance of UnnumberedLink.
33 */
34 public UnnumberedLink() {
35 }
36
37 /**
38 * Sets the router Id.
39 *
40 * @param routerId the routerId to set
41 */
42 public void setRouterId(IpAddress routerId) {
43 this.routerId = routerId;
44 }
45
46 /**
47 * Sets the interface Id.
48 *
49 * @param interfaceId the interfaceId to set
50 */
51 public void setInterfaceId(long interfaceId) {
52 this.interfaceId = interfaceId;
53 }
54
55 /**
56 * Returns the router Id.
57 *
58 * @return router identifier
59 */
60 public IpAddress routerId() {
61 return routerId;
62 }
63
64 /**
65 * Returns the interface Id.
66 *
67 * @return interface identifier
68 */
69 public long interfaceId() {
70 return interfaceId;
71 }
72
73 @Override
74 public int hashCode() {
75 return Objects.hash(routerId, interfaceId);
76 }
77
78 @Override
79 public boolean equals(Object obj) {
80 if (this == obj) {
81 return true;
82 }
83 if (obj instanceof UnnumberedLink) {
84 UnnumberedLink other = (UnnumberedLink) obj;
85 return
86 Objects.equals(routerId, other.routerId) &&
87 Objects.equals(interfaceId, other.interfaceId);
88 }
89 return false;
90 }
91
92 @Override
93 public String toString() {
94 return MoreObjects.toStringHelper(getClass())
95 .add("routerId", routerId)
96 .add("interfaceId", interfaceId)
97 .toString();
98 }
99}