blob: efc5ea6ff1ecd662081b20c4c2f3544b9c762454 [file] [log] [blame]
Jian Li6b77dc02016-07-14 16:04:25 +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
Jian Lid56f97e2016-07-19 15:48:15 +090018import java.util.Objects;
19
Jian Li6b77dc02016-07-14 16:04:25 +090020/**
21 * LISP Locator address typed by Address Family Identifier (AFI).
22 */
23public abstract class LispAfiAddress {
24
25 private final AddressFamilyIdentifierEnum afi;
26
27 /**
28 * Initializes AFI enumeration value.
29 *
30 * @param afi address family identifier
31 */
32 protected LispAfiAddress(AddressFamilyIdentifierEnum afi) {
33 this.afi = afi;
34 }
35
36 /**
37 * Obtains AFI enumeration value.
38 *
39 * @return AFI enumeration value
40 */
41 public AddressFamilyIdentifierEnum getAfi() {
42 return afi;
43 }
44
45 @Override
46 public int hashCode() {
Jian Lid56f97e2016-07-19 15:48:15 +090047 return Objects.hash(afi);
Jian Li6b77dc02016-07-14 16:04:25 +090048 }
49
50 @Override
51 public boolean equals(Object obj) {
52 if (this == obj) {
53 return true;
54 }
55
56 if (obj == null) {
57 return false;
58 }
59
60 if (getClass() != obj.getClass()) {
61 return false;
62 }
63
64 LispAfiAddress other = (LispAfiAddress) obj;
65 if (afi != other.afi) {
66 return false;
67 }
68 return true;
69 }
70}