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.protocol.concepts.IPv4Address;
12 import org.opendaylight.protocol.pcep.concepts.UnnumberedInterfaceIdentifier;
13 import com.google.common.base.Objects.ToStringHelper;
16 * Structure of unnumbered Iterface Subobject.
18 * @see <a href="http://tools.ietf.org/html/rfc3477">Section 4: Signalling
19 * Unnumbered Links in EROs</a>
21 public class EROUnnumberedInterfaceSubobject extends ExplicitRouteSubobject {
22 private final UnnumberedInterfaceIdentifier interfaceID;
23 private final IPv4Address routerID;
26 * Constructs new Unnumbered Interface Subobject.
31 * UnnumberedInterfaceIdentifier
35 public EROUnnumberedInterfaceSubobject(final IPv4Address routerID, final UnnumberedInterfaceIdentifier interfaceID, boolean loose) {
37 this.routerID = routerID;
38 this.interfaceID = interfaceID;
42 * Gets {@link IPv4Address} representation of router ID.
46 public IPv4Address getRouterID() {
51 * Gets {@link UnnumberedInterfaceIdentifier} representation of Interface
54 * @return UnnumberedInterfaceIdentifier
56 public UnnumberedInterfaceIdentifier getInterfaceID() {
57 return this.interfaceID;
61 public int hashCode() {
64 result = prime * result + ((this.interfaceID == null) ? 0 : this.interfaceID.hashCode());
65 result = prime * result + ((this.routerID == null) ? 0 : this.routerID.hashCode());
70 public boolean equals(Object obj) {
75 if (this.getClass() != obj.getClass())
77 final EROUnnumberedInterfaceSubobject other = (EROUnnumberedInterfaceSubobject) obj;
78 if (this.interfaceID == null) {
79 if (other.interfaceID != null)
81 } else if (!this.interfaceID.equals(other.interfaceID))
83 if (this.routerID == null) {
84 if (other.routerID != null)
86 } else if (!this.routerID.equals(other.routerID))
92 public String toString() {
93 final StringBuilder builder = new StringBuilder();
94 builder.append("EROUnnumberedInterfaceSubobject [interfaceID=");
95 builder.append(this.interfaceID);
96 builder.append(", routerID=");
97 builder.append(this.routerID);
98 builder.append(", loose=");
99 builder.append(this.loose);
101 return builder.toString();
105 protected ToStringHelper addToStringAttributes(ToStringHelper toStringHelper) {
106 toStringHelper.add("interfaceID", this.interfaceID);
107 toStringHelper.add("routerID", this.routerID);
108 toStringHelper.add("loose", this.loose);
109 return super.addToStringAttributes(toStringHelper);