2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.protocol.pcep.subobject;
11 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpPrefix;
14 * Parametrized structure of RRO IP Address Subobject.
16 * @see <a href="http://tools.ietf.org/html/rfc3209#section-4.4.1.1">Section 4.4.1.1: Subobject 1: IPv4 address</a> and
17 * <a href="http://tools.ietf.org/html/rfc3209#section-4.4.1.2">Section 4.4.1.2: Subobject 2: IPv6 address</a>
19 * @param <T> subtype of Prefix
21 public class RROIPAddressSubobject extends ReportedRouteSubobject {
23 private final IpPrefix prefix;
26 * Local protection available
28 private final boolean localProtectionAvailable;
31 * Local protection in use
33 private final boolean localProtectionInUse;
36 * Constructs IPPrefix Subobject.
39 * @param localProtectionAvailable boolean
40 * @param localProtectionInUse boolean
42 public RROIPAddressSubobject(final IpPrefix prefix, final boolean localProtectionAvailable, final boolean localProtectionInUse) {
45 this.localProtectionAvailable = localProtectionAvailable;
46 this.localProtectionInUse = localProtectionInUse;
50 * Gets specific {@link Prefix}.
54 public IpPrefix getPrefix() {
59 * Returns tru if local protection is available.
63 public boolean isLocalProtectionAvailable() {
64 return this.localProtectionAvailable;
68 * Returns true if local protection is in use
72 public boolean isLocalProtectionInUse() {
73 return this.localProtectionInUse;
77 public int hashCode() {
80 result = prime * result + (this.localProtectionAvailable ? 1231 : 1237);
81 result = prime * result + (this.localProtectionInUse ? 1231 : 1237);
82 result = prime * result + ((this.prefix == null) ? 0 : this.prefix.hashCode());
87 public boolean equals(final Object obj) {
92 if (this.getClass() != obj.getClass())
94 final RROIPAddressSubobject other = (RROIPAddressSubobject) obj;
95 if (this.localProtectionAvailable != other.localProtectionAvailable)
97 if (this.localProtectionInUse != other.localProtectionInUse)
99 if (this.prefix == null) {
100 if (other.prefix != null)
102 } else if (!this.prefix.equals(other.prefix))
108 public String toString() {
109 final StringBuilder builder = new StringBuilder();
110 builder.append("RROIPAddressSubobject [prefix=");
111 builder.append(this.prefix);
112 builder.append(", lpa=");
113 builder.append(this.localProtectionAvailable);
114 builder.append(", lpiu=");
115 builder.append(this.localProtectionInUse);
117 return builder.toString();