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