Revert "BUG-47 : unfinished PCEP migration to generated DTOs."
[bgpcep.git] / pcep / api / src / main / java / org / opendaylight / protocol / pcep / subobject / EROUnnumberedInterfaceSubobject.java
1 /*
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8
9 package org.opendaylight.protocol.pcep.subobject;
10
11 import org.opendaylight.protocol.concepts.IPv4Address;
12 import org.opendaylight.protocol.pcep.concepts.UnnumberedInterfaceIdentifier;
13 import com.google.common.base.Objects.ToStringHelper;
14
15 /**
16  * Structure of unnumbered Iterface Subobject.
17  *
18  * @see <a href="http://tools.ietf.org/html/rfc3477">Section 4: Signalling
19  *      Unnumbered Links in EROs</a>
20  */
21 public class EROUnnumberedInterfaceSubobject extends ExplicitRouteSubobject {
22         private final UnnumberedInterfaceIdentifier interfaceID;
23         private final IPv4Address routerID;
24
25         /**
26          * Constructs new Unnumbered Interface Subobject.
27          *
28          * @param routerID
29          *            IPv4Address
30          * @param interfaceID
31          *            UnnumberedInterfaceIdentifier
32          * @param loose
33          *            boolean
34          */
35         public EROUnnumberedInterfaceSubobject(final IPv4Address routerID, final UnnumberedInterfaceIdentifier interfaceID, boolean loose) {
36                 super(loose);
37                 this.routerID = routerID;
38                 this.interfaceID = interfaceID;
39         }
40
41         /**
42          * Gets {@link IPv4Address} representation of router ID.
43          *
44          * @return IPv4Address
45          */
46         public IPv4Address getRouterID() {
47                 return this.routerID;
48         }
49
50         /**
51          * Gets {@link UnnumberedInterfaceIdentifier} representation of Interface
52          * ID.
53          *
54          * @return UnnumberedInterfaceIdentifier
55          */
56         public UnnumberedInterfaceIdentifier getInterfaceID() {
57                 return this.interfaceID;
58         }
59
60         @Override
61         public int hashCode() {
62                 final int prime = 31;
63                 int result = 1;
64                 result = prime * result + ((this.interfaceID == null) ? 0 : this.interfaceID.hashCode());
65                 result = prime * result + ((this.routerID == null) ? 0 : this.routerID.hashCode());
66                 return result;
67         }
68
69         @Override
70         public boolean equals(Object obj) {
71                 if (this == obj)
72                         return true;
73                 if (obj == null)
74                         return false;
75                 if (this.getClass() != obj.getClass())
76                         return false;
77                 final EROUnnumberedInterfaceSubobject other = (EROUnnumberedInterfaceSubobject) obj;
78                 if (this.interfaceID == null) {
79                         if (other.interfaceID != null)
80                                 return false;
81                 } else if (!this.interfaceID.equals(other.interfaceID))
82                         return false;
83                 if (this.routerID == null) {
84                         if (other.routerID != null)
85                                 return false;
86                 } else if (!this.routerID.equals(other.routerID))
87                         return false;
88                 return true;
89         }
90
91         @Override
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);
100                 builder.append("]");
101                 return builder.toString();
102         }
103
104     @Override
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);
110         }
111
112 }