blob: daae1b36d32bb8a9ccc962227e7f0c3465553e6d [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 * This class provides information on Local Interface Identifier and Remote
24 * Interface Identifier of the link.
25 */
26public class InterfaceIdentifier {
27 private final Integer identifier;
28
29 /**
30 * Constructor to initialize identifier.
31 *
32 * @param identifier local/remote interface identifier
33 */
34 public InterfaceIdentifier(Integer identifier) {
35 this.identifier = identifier;
36 }
37
38 /**
39 * Provides the local/remote interface identifier of the link.
40 *
41 * @return interface identifier
42 */
43 public Integer identifier() {
44 return identifier;
45 }
46
47 @Override
48 public int hashCode() {
49 return Objects.hash(identifier);
50 }
51
52 @Override
53 public boolean equals(Object obj) {
54 if (this == obj) {
55 return true;
56 }
57
58 if (obj instanceof InterfaceIdentifier) {
59 InterfaceIdentifier other = (InterfaceIdentifier) obj;
60 return Objects.equals(identifier, other.identifier);
61 }
62 return false;
63 }
64
65 @Override
66 public String toString() {
67 return toStringHelper(this)
68 .add("identifier", identifier)
69 .toString();
70 }
71}