blob: 074a866a6a4e720b0a7988f511d01cad94e79730 [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.Ip6Address;
21
22import com.google.common.base.MoreObjects;
23
24/**
25 * Implementation of IPv6 address as an ElementType.
26 */
27public class TeIpv6 implements ElementType {
28 private Ip6Address v6Address;
29 private short v6PrefixLength;
30 private boolean v6Loose;
31
32 /**
33 * Creates an instance of TeIpv6.
34 */
35 public TeIpv6() {
36 }
37
38 /**
39 * Sets the v6 address.
40 *
41 * @param v6Address the v6Address to set
42 */
43 public void setV6Address(Ip6Address v6Address) {
44 this.v6Address = v6Address;
45 }
46
47 /**
48 * Sets the prefix length.
49 *
50 * @param v6PrefixLength the v6PrefixLength to set
51 */
52 public void setV6PrefixLength(short v6PrefixLength) {
53 this.v6PrefixLength = v6PrefixLength;
54 }
55
56 /**
57 * Sets the loose flag.
58 *
59 * @param v6Loose the v6Loose to set
60 */
61 public void setv6Loose(boolean v6Loose) {
62 this.v6Loose = v6Loose;
63 }
64
65 /**
66 * Returns the v6Address.
67 *
68 * @return IPv6 address
69 */
70 public Ip6Address v6Address() {
71 return v6Address;
72 }
73
74 /**
75 * Returns the v6PrefixLength.
76 *
77 * @return IPv6 address prefix length
78 */
79 public short v6PrefixLength() {
80 return v6PrefixLength;
81 }
82
83 /**
84 * Returns the v6Loose.
85 *
86 * @return true if the address specifies a loose hop; false otherwise
87 */
88 public boolean v6Loose() {
89 return v6Loose;
90 }
91
92 @Override
93 public int hashCode() {
94 return Objects.hash(v6Address, v6PrefixLength, v6Loose);
95 }
96
97 @Override
98 public boolean equals(Object obj) {
99 if (this == obj) {
100 return true;
101 }
102 if (obj instanceof TeIpv6) {
103 TeIpv6 other = (TeIpv6) obj;
104 return Objects.equals(v6Address, other.v6Address) &&
105 Objects.equals(v6PrefixLength, other.v6PrefixLength) &&
106 Objects.equals(v6Loose, other.v6Loose);
107 }
108 return false;
109 }
110
111 @Override
112 public String toString() {
113 return MoreObjects.toStringHelper(getClass())
114 .add("v6Address", v6Address)
115 .add("v6PrefixLength", v6PrefixLength)
116 .add("v6Loose", v6Loose)
117 .toString();
118 }
119
120}