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.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.UnnumberedSubobject;
14 import com.google.common.base.Objects.ToStringHelper;
17 * Structure of unnumbered Interface Subobject.
19 * @see <a href="http://tools.ietf.org/html/rfc3477">Section 4: Signalling Unnumbered Links in EROs</a>
21 public class EROUnnumberedInterfaceSubobject extends ExplicitRouteSubobject {
22 private final UnnumberedSubobject interfaceID;
23 private final IPv4Address routerID;
26 * Constructs new Unnumbered Interface Subobject.
28 * @param routerID IPv4Address
29 * @param interfaceID UnnumberedInterfaceIdentifier
30 * @param loose boolean
32 public EROUnnumberedInterfaceSubobject(final IPv4Address routerID, final UnnumberedSubobject interfaceID, final boolean loose) {
34 this.routerID = routerID;
35 this.interfaceID = interfaceID;
39 * Gets {@link IPv4Address} representation of router ID.
43 public IPv4Address getRouterID() {
48 * Gets {@link UnnumberedSubobject} representation of Interface ID.
50 * @return UnnumberedSubobject
52 public UnnumberedSubobject getInterfaceID() {
53 return this.interfaceID;
57 public int hashCode() {
60 result = prime * result + ((this.interfaceID == null) ? 0 : this.interfaceID.hashCode());
61 result = prime * result + ((this.routerID == null) ? 0 : this.routerID.hashCode());
66 public boolean equals(final Object obj) {
71 if (this.getClass() != obj.getClass())
73 final EROUnnumberedInterfaceSubobject other = (EROUnnumberedInterfaceSubobject) obj;
74 if (this.interfaceID == null) {
75 if (other.interfaceID != null)
77 } else if (!this.interfaceID.equals(other.interfaceID))
79 if (this.routerID == null) {
80 if (other.routerID != null)
82 } else if (!this.routerID.equals(other.routerID))
88 public String toString() {
89 final StringBuilder builder = new StringBuilder();
90 builder.append("EROUnnumberedInterfaceSubobject [interfaceID=");
91 builder.append(this.interfaceID);
92 builder.append(", routerID=");
93 builder.append(this.routerID);
94 builder.append(", loose=");
95 builder.append(this.loose);
97 return builder.toString();
101 protected ToStringHelper addToStringAttributes(final ToStringHelper toStringHelper) {
102 toStringHelper.add("interfaceID", this.interfaceID);
103 toStringHelper.add("routerID", this.routerID);
104 toStringHelper.add("loose", this.loose);
105 return super.addToStringAttributes(toStringHelper);