2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
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
9 package org.opendaylight.protocol.pcep.tlv;
11 import org.opendaylight.protocol.concepts.NetworkAddress;
12 import org.opendaylight.protocol.pcep.PCEPTlv;
15 * Structure of RSVP Error Spec Tlv.
17 * @see <a href="http://tools.ietf.org/html/rfc2205">Apendix A.5: ERROR_SPEC
21 public class RSVPErrorSpecTlv<T extends NetworkAddress<T>> implements PCEPTlv {
22 private static final long serialVersionUID = 3948879942549682846L;
24 private final T errorNodeAddress;
26 private final boolean inPlace;
28 private final boolean guilty;
30 private final int errorCode;
32 private final int errorValue;
36 * Constructs new RSVP Error Spec Tlv.
38 * @param errorNodeAddress
49 public RSVPErrorSpecTlv(T errorNodeAddress, boolean inPlace, boolean guilty, int errorCode, int errorValue) {
50 this.errorNodeAddress = errorNodeAddress;
51 this.inPlace = inPlace;
53 this.errorCode = errorCode;
54 this.errorValue = errorValue;
58 * Gets {@link NetworkAddress} of Error Node.
62 public T getErrorNodeAddress() {
63 return this.errorNodeAddress;
67 * Setting of InPlace flag.
71 public boolean isInPlace() {
76 * Setting of Guilty flag.
80 public boolean isGuilty() {
85 * Gets int representation of Error Code.
89 public int getErrorCode() {
90 return this.errorCode;
94 * Gets int representation of Error Value.
98 public int getErrorValue() {
99 return this.errorValue;
103 public int hashCode() {
104 final int prime = 31;
106 result = prime * result + this.errorCode;
107 result = prime * result + ((this.errorNodeAddress == null) ? 0 : this.errorNodeAddress.hashCode());
108 result = prime * result + this.errorValue;
109 result = prime * result + (this.guilty ? 1231 : 1237);
110 result = prime * result + (this.inPlace ? 1231 : 1237);
115 public boolean equals(Object obj) {
120 if (this.getClass() != obj.getClass())
122 final RSVPErrorSpecTlv<?> other = (RSVPErrorSpecTlv<?>) obj;
123 if (this.errorCode != other.errorCode)
125 if (this.errorNodeAddress == null) {
126 if (other.errorNodeAddress != null)
128 } else if (!this.errorNodeAddress.equals(other.errorNodeAddress))
130 if (this.errorValue != other.errorValue)
132 if (this.guilty != other.guilty)
134 if (this.inPlace != other.inPlace)
140 public String toString() {
141 final StringBuilder builder = new StringBuilder();
142 builder.append("RSVPErrorSpecTlv [errorNodeAddress=");
143 builder.append(this.errorNodeAddress);
144 builder.append(", inPlace=");
145 builder.append(this.inPlace);
146 builder.append(", guilty=");
147 builder.append(this.guilty);
148 builder.append(", errorCode=");
149 builder.append(this.errorCode);
150 builder.append(", errorValue=");
151 builder.append(this.errorValue);
153 return builder.toString();