Merge "Randomize port to allow concurrent execution"
[bgpcep.git] / pcep / api / src / main / java / org / opendaylight / protocol / pcep / tlv / NoPathVectorTlv.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.tlv;
10
11 import org.opendaylight.protocol.pcep.PCEPTlv;
12
13 /**
14  * Structure of No Path Vector TLV. Extended to conform RFC5557.
15  * 
16  * @see <a href="http://tools.ietf.org/html/rfc5440#section-7.5">NO-PATH Object
17  *      [RFC5440]</a> - defined in text
18  * @see <a href="http://tools.ietf.org/html/rfc5557#section-5.7">NO-PATH
19  *      Indicator [RFC5557]</a>
20  */
21 public class NoPathVectorTlv implements PCEPTlv {
22
23         private static final long serialVersionUID = -4993945476359800826L;
24
25         private final boolean pceUnavailable;
26
27         private final boolean unknownDest;
28
29         private final boolean unknownSrc;
30
31         private final boolean noGCOSolution;
32
33         private final boolean noGCOMigrationPath;
34
35         private final boolean reachablityProblem;
36
37         /**
38          * Constructs new No Path Vector Tlv.
39          * 
40          * @param pceUnavailable
41          *            boolean
42          * @param unknownDest
43          *            boolean
44          * @param unknownSrc
45          *            boolean
46          * @param noGCOSolution
47          *            boolean
48          * @param noGCOMigrationPath
49          *            boolean
50          */
51         public NoPathVectorTlv(boolean pceUnavailable, boolean unknownDest, boolean unknownSrc, boolean noGCOSolution, boolean noGCOMigrationPath,
52                         boolean reachabilityProblem) {
53                 super();
54                 this.pceUnavailable = pceUnavailable;
55                 this.unknownDest = unknownDest;
56                 this.unknownSrc = unknownSrc;
57                 this.noGCOSolution = noGCOSolution;
58                 this.noGCOMigrationPath = noGCOMigrationPath;
59                 this.reachablityProblem = reachabilityProblem;
60         }
61
62         /**
63          * Returns true if PCE currently unavailable
64          * 
65          * @return boolean
66          */
67         public boolean isPceUnavailable() {
68                 return this.pceUnavailable;
69         }
70
71         /**
72          * Returns true if unknown destination
73          * 
74          * @return boolean
75          */
76         public boolean isUnknownDest() {
77                 return this.unknownDest;
78         }
79
80         /**
81          * Returns true if unknown source
82          * 
83          * @return boolean
84          */
85         public boolean isUnknownSrc() {
86                 return this.unknownSrc;
87         }
88
89         /**
90          * If returns true the PCE indicates that no migration path was found.
91          * 
92          * @return boolean
93          */
94         public boolean isNoGCOSolution() {
95                 return this.noGCOSolution;
96         }
97
98         /**
99          * If returns true the PCE indicates no feasible solution was found that
100          * meets all the constraints associated with global concurrent path
101          * optimization in the PCRep message
102          * 
103          * @return boolean
104          */
105         public boolean isNoGCOMigrationPath() {
106                 return this.noGCOMigrationPath;
107         }
108
109         /**
110          * @return the reachablityProblem
111          */
112         public boolean isReachablityProblem() {
113                 return this.reachablityProblem;
114         }
115
116         @Override
117         public int hashCode() {
118                 final int prime = 31;
119                 int result = 1;
120                 result = prime * result + (this.noGCOMigrationPath ? 1231 : 1237);
121                 result = prime * result + (this.noGCOSolution ? 1231 : 1237);
122                 result = prime * result + (this.pceUnavailable ? 1231 : 1237);
123                 result = prime * result + (this.reachablityProblem ? 1231 : 1237);
124                 result = prime * result + (this.unknownDest ? 1231 : 1237);
125                 result = prime * result + (this.unknownSrc ? 1231 : 1237);
126                 return result;
127         }
128
129         @Override
130         public boolean equals(Object obj) {
131                 if (this == obj)
132                         return true;
133                 if (obj == null)
134                         return false;
135                 if (this.getClass() != obj.getClass())
136                         return false;
137                 final NoPathVectorTlv other = (NoPathVectorTlv) obj;
138                 if (this.noGCOMigrationPath != other.noGCOMigrationPath)
139                         return false;
140                 if (this.noGCOSolution != other.noGCOSolution)
141                         return false;
142                 if (this.pceUnavailable != other.pceUnavailable)
143                         return false;
144                 if (this.reachablityProblem != other.reachablityProblem)
145                         return false;
146                 if (this.unknownDest != other.unknownDest)
147                         return false;
148                 if (this.unknownSrc != other.unknownSrc)
149                         return false;
150                 return true;
151         }
152
153         @Override
154         public String toString() {
155                 final StringBuilder builder = new StringBuilder();
156                 builder.append("NoPathVectorTlv [pceUnavailable=");
157                 builder.append(this.pceUnavailable);
158                 builder.append(", unknownDest=");
159                 builder.append(this.unknownDest);
160                 builder.append(", unknownSrc=");
161                 builder.append(this.unknownSrc);
162                 builder.append(", noGCOSolution=");
163                 builder.append(this.noGCOSolution);
164                 builder.append(", noGCOMigrationPath=");
165                 builder.append(this.noGCOMigrationPath);
166                 builder.append(", reachablityProblem=");
167                 builder.append(this.reachablityProblem);
168                 builder.append("]");
169                 return builder.toString();
170         }
171
172 }