blob: d5fbc9884909f917b5e2ab02c9dc289121eea90a [file] [log] [blame]
Jian Lid56f97e2016-07-19 15:48:15 +09001/*
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.lisp.msg.types;
17
18import java.util.Objects;
19
20import static com.google.common.base.MoreObjects.toStringHelper;
21
22/**
23 * Distinguished name address that is used by LISP Locator.
24 */
25public class LispDistinguishedNameAddress extends LispAfiAddress {
26
27 private final String distinguishedName;
28
29 /**
30 * Initializes LISP locator's distinguished name address with AFI enum.
31 *
32 * @param distinguishedName distinguished name address
33 */
34 public LispDistinguishedNameAddress(String distinguishedName) {
35 super(AddressFamilyIdentifierEnum.DISTINGUISHED_NAME);
36 this.distinguishedName = distinguishedName;
37 }
38
39 /**
40 * Obtains LISP locator's distinguished name address.
41 *
42 * @return distinguished name address
43 */
44 public String getDistinguishedName() {
45 return distinguishedName;
46 }
47
48 @Override
49 public int hashCode() {
50 return Objects.hash(distinguishedName);
51 }
52
53 @Override
54 public boolean equals(Object obj) {
55 if (this == obj) {
56 return true;
57 }
58
59 if (obj instanceof LispDistinguishedNameAddress) {
60 final LispDistinguishedNameAddress other = (LispDistinguishedNameAddress) obj;
61 return Objects.equals(this.distinguishedName, other.distinguishedName);
62 }
63 return false;
64 }
65
66 @Override
67 public String toString() {
68 return toStringHelper(this)
69 .add("distinguished name", distinguishedName)
70 .toString();
71 }
72}