Revert "BUG-47 : unfinished PCEP migration to generated DTOs."
[bgpcep.git] / pcep / api / src / main / java / org / opendaylight / protocol / pcep / subobject / XROUnnumberedInterfaceSubobject.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 package org.opendaylight.protocol.pcep.subobject;
9
10 import org.opendaylight.protocol.concepts.IPv4Address;
11 import org.opendaylight.protocol.pcep.concepts.UnnumberedInterfaceIdentifier;
12
13 /**
14  * Structure of unnumbered Iterface Subobject. Defined in RFC5521.
15  *
16  * @see <a href="http://tools.ietf.org/html/rfc5521#section-2.1.1">Exclude Route
17  *      Object definition</a>
18  */
19 public class XROUnnumberedInterfaceSubobject extends ExcludeRouteSubobject {
20
21         private final XROSubobjectAttribute attribute;
22
23         private final UnnumberedInterfaceIdentifier interfaceID;
24
25         private final IPv4Address routerID;
26
27         /**
28          * Constructs new Unnumbered Interface Subobject.
29          *
30          * @param routerID
31          *            IPv4Address
32          * @param interfaceID
33          *            UnnumberedInterfaceIdentifier
34          * @param mandatory
35          *            boolean
36          * @param attribute
37          *            XROSubobjectAttribute
38          */
39         public XROUnnumberedInterfaceSubobject(final IPv4Address routerID, final UnnumberedInterfaceIdentifier interfaceID, boolean mandatory,
40                         XROSubobjectAttribute attribute) {
41                 super(mandatory);
42                 this.attribute = attribute;
43                 this.routerID = routerID;
44                 this.interfaceID = interfaceID;
45         }
46
47         /**
48          * Gets the attribute of the subobject
49          *
50          * @return the attribute
51          */
52         public XROSubobjectAttribute getAttribute() {
53                 return this.attribute;
54         }
55
56         /**
57          * Gets {@link IPv4Address} representation of router ID.
58          *
59          * @return IPv4Address
60          */
61         public IPv4Address getRouterID() {
62                 return this.routerID;
63         }
64
65         /**
66          * Gets {@link UnnumberedInterfaceIdentifier} representation of Interface
67          * ID.
68          *
69          * @return UnnumberedInterfaceIdentifier
70          */
71         public UnnumberedInterfaceIdentifier getInterfaceID() {
72                 return this.interfaceID;
73         }
74
75         @Override
76         public int hashCode() {
77                 final int prime = 31;
78                 int result = super.hashCode();
79                 result = prime * result + ((this.attribute == null) ? 0 : this.attribute.hashCode());
80                 result = prime * result + ((this.interfaceID == null) ? 0 : this.interfaceID.hashCode());
81                 result = prime * result + ((this.routerID == null) ? 0 : this.routerID.hashCode());
82                 return result;
83         }
84
85         @Override
86         public boolean equals(Object obj) {
87                 if (this == obj)
88                         return true;
89                 if (!super.equals(obj))
90                         return false;
91                 if (this.getClass() != obj.getClass())
92                         return false;
93                 final XROUnnumberedInterfaceSubobject other = (XROUnnumberedInterfaceSubobject) obj;
94                 if (this.attribute != other.attribute)
95                         return false;
96                 if (this.interfaceID == null) {
97                         if (other.interfaceID != null)
98                                 return false;
99                 } else if (!this.interfaceID.equals(other.interfaceID))
100                         return false;
101                 if (this.routerID == null) {
102                         if (other.routerID != null)
103                                 return false;
104                 } else if (!this.routerID.equals(other.routerID))
105                         return false;
106                 return true;
107         }
108
109         @Override
110         public String toString() {
111                 final StringBuilder builder = new StringBuilder();
112                 builder.append("XROUnnumberedInterfaceSubobject [attribute=");
113                 builder.append(this.attribute);
114                 builder.append(", interfaceID=");
115                 builder.append(this.interfaceID);
116                 builder.append(", routerID=");
117                 builder.append(this.routerID);
118                 builder.append(", mandatory=");
119                 builder.append(this.mandatory);
120                 builder.append("]");
121                 return builder.toString();
122         }
123
124 }