Merge "Randomize port to allow concurrent execution"
[bgpcep.git] / pcep / api / src / main / java / org / opendaylight / protocol / pcep / tlv / PCEStatefulCapabilityTlv.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.tlv;
9
10 import org.opendaylight.protocol.pcep.PCEPTlv;
11
12 /**
13  * Structure of PCE Stateful Capability Tlv.
14  *
15  * @see <a
16  *      href="http://tools.ietf.org/html/draft-crabbe-pce-stateful-pce-02#section-8.6">STATEFUL-PCE-CAPABILITY
17  *      TLV</a>
18  * @see <a
19  *              href="http://www.ietf.org/id/draft-crabbe-pce-pce-initiated-lsp-00.txt#section-4.1">Stateful PCE Capability
20  *              TLV</a>
21  *
22  */
23 public class PCEStatefulCapabilityTlv implements PCEPTlv {
24
25         private static final long serialVersionUID = 5567589958323130325L;
26
27         private final boolean update;
28
29         private final boolean versioned;
30
31         private final boolean instantiated;
32
33         /**
34          * Constructs PCE Stateful Capability Tlv
35          *
36          * @param update
37          *            boolean
38          * @param versioned
39          *            boolean
40          */
41         public PCEStatefulCapabilityTlv(boolean instantiated, boolean update, boolean versioned) {
42                 this.instantiated = instantiated;
43                 this.update = update;
44                 this.versioned = versioned;
45         }
46
47         /**
48          * Setting of Instantiated flag.
49          *
50          * @return boolean
51          */
52         public boolean isInstantiated() {
53                 return this.instantiated;
54         }
55
56         /**
57          * Setting of Update flag.
58          *
59          * @return boolean
60          */
61         public boolean isUpdate() {
62                 return this.update;
63         }
64
65         /**
66          * Setting of Versioned flag.
67          *
68          * @return boolean
69          */
70         public boolean isVersioned() {
71                 return this.versioned;
72         }
73
74         /* (non-Javadoc)
75          * @see java.lang.Object#hashCode()
76          */
77         @Override
78         public int hashCode() {
79                 final int prime = 31;
80                 int result = 1;
81                 result = prime * result + (this.instantiated ? 1231 : 1237);
82                 result = prime * result + (this.update ? 1231 : 1237);
83                 result = prime * result + (this.versioned ? 1231 : 1237);
84                 return result;
85         }
86
87         /* (non-Javadoc)
88          * @see java.lang.Object#equals(java.lang.Object)
89          */
90         @Override
91         public boolean equals(Object obj) {
92                 if (this == obj)
93                         return true;
94                 if (obj == null)
95                         return false;
96                 if (!(obj instanceof PCEStatefulCapabilityTlv))
97                         return false;
98                 final PCEStatefulCapabilityTlv other = (PCEStatefulCapabilityTlv) obj;
99                 if (this.instantiated != other.instantiated)
100                         return false;
101                 if (this.update != other.update)
102                         return false;
103                 if (this.versioned != other.versioned)
104                         return false;
105                 return true;
106         }
107
108         /* (non-Javadoc)
109          * @see java.lang.Object#toString()
110          */
111         @Override
112         public String toString() {
113                 final StringBuilder builder = new StringBuilder();
114                 builder.append("PCEStatefulCapabilityTlv [update=");
115                 builder.append(this.update);
116                 builder.append(", versioned=");
117                 builder.append(this.versioned);
118                 builder.append(", instantiated=");
119                 builder.append(this.instantiated);
120                 builder.append("]");
121                 return builder.toString();
122         }
123 }