Revert "BUG-47 : unfinished PCEP migration to generated DTOs."
[bgpcep.git] / pcep / api / src / main / java / org / opendaylight / protocol / pcep / subobject / RROUnnumberedInterfaceSubobject.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
14 /**
15  * Structure of unnumbered Iterface Subobject.
16  *
17  * @see <a href="http://tools.ietf.org/html/rfc3477">Section 4: Signalling
18  *      Unnumbered Links in EROs</a>
19  */
20 public class RROUnnumberedInterfaceSubobject extends ReportedRouteSubobject {
21     private final UnnumberedInterfaceIdentifier interfaceID;
22     private final IPv4Address routerID;
23
24     /**
25      * Constructs new Unnumbered Interface Subobject.
26      *
27      * @param routerID
28      *            IPv4Address
29      * @param interfaceID
30      *            UnnumberedInterfaceIdentifier
31      */
32     public RROUnnumberedInterfaceSubobject(final IPv4Address routerID, final UnnumberedInterfaceIdentifier interfaceID) {
33         super();
34         this.routerID = routerID;
35         this.interfaceID = interfaceID;
36     }
37
38     /**
39      * Gets {@link IPv4Address} representation of router ID.
40      *
41      * @return IPv4Address
42      */
43     public IPv4Address getRouterID() {
44         return this.routerID;
45     }
46
47     /**
48      * Gets {@link UnnumberedInterfaceIdentifier} representation of Interface
49      * ID.
50      *
51      * @return UnnumberedInterfaceIdentifier
52      */
53     public UnnumberedInterfaceIdentifier getInterfaceID() {
54         return this.interfaceID;
55     }
56
57     @Override
58     public int hashCode() {
59         final int prime = 31;
60         int result = 1;
61         result = prime * result + ((this.interfaceID == null) ? 0 : this.interfaceID.hashCode());
62         result = prime * result + ((this.routerID == null) ? 0 : this.routerID.hashCode());
63         return result;
64     }
65
66     @Override
67     public boolean equals(Object obj) {
68         if (this == obj)
69             return true;
70         if (obj == null)
71             return false;
72         if (this.getClass() != obj.getClass())
73             return false;
74         final RROUnnumberedInterfaceSubobject other = (RROUnnumberedInterfaceSubobject) obj;
75         if (this.interfaceID == null) {
76             if (other.interfaceID != null)
77                 return false;
78         } else if (!this.interfaceID.equals(other.interfaceID))
79             return false;
80         if (this.routerID == null) {
81             if (other.routerID != null)
82                 return false;
83         } else if (!this.routerID.equals(other.routerID))
84             return false;
85         return true;
86     }
87
88     @Override
89     public String toString() {
90         final StringBuilder builder = new StringBuilder();
91         builder.append("RROUnnumberedInterfaceSubobject [interfaceID=");
92         builder.append(this.interfaceID);
93         builder.append(", routerID=");
94         builder.append(this.routerID);
95         builder.append("]");
96         return builder.toString();
97     }
98
99 }