blob: c4c49e155bafb877d80a60a42e552ac41ad3a3ee [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
18/**
19 * LISP Locator address typed by Address Family Identifier (AFI).
20 */
21public abstract class LispAfiAddress {
22
23 private final AddressFamilyIdentifierEnum afi;
24
25 /**
26 * Initializes AFI enumeration value.
27 *
28 * @param afi address family identifier
29 */
30 protected LispAfiAddress(AddressFamilyIdentifierEnum afi) {
31 this.afi = afi;
32 }
33
34 /**
35 * Obtains AFI enumeration value.
36 *
37 * @return AFI enumeration value
38 */
39 public AddressFamilyIdentifierEnum getAfi() {
40 return afi;
41 }
42
43 @Override
44 public int hashCode() {
45 final int prime = 31;
46 int result = 1;
47 result = prime * result + ((afi == null) ? 0 : afi.hashCode());
48 return result;
49 }
50
51 @Override
52 public boolean equals(Object obj) {
53 if (this == obj) {
54 return true;
55 }
56
57 if (obj == null) {
58 return false;
59 }
60
61 if (getClass() != obj.getClass()) {
62 return false;
63 }
64
65 LispAfiAddress other = (LispAfiAddress) obj;
66 if (afi != other.afi) {
67 return false;
68 }
69 return true;
70 }
71}