Merge "Randomize port to allow concurrent execution"
[bgpcep.git] / pcep / api / src / main / java / org / opendaylight / protocol / pcep / tlv / LSPUpdateErrorTlv.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 java.util.Arrays;
12
13 import org.opendaylight.protocol.pcep.PCEPTlv;
14
15 /**
16  * Structure of LSP Update Error TLV.
17  * 
18  * @see <a
19  *      href="http://tools.ietf.org/html/draft-crabbe-pce-stateful-pce-02#section-7.2.3">LSP
20  *      Update Error Code TLV</a>
21  */
22 public class LSPUpdateErrorTlv implements PCEPTlv {
23         private static final long serialVersionUID = -6919035417806059716L;
24         private final byte[] errorCode;
25
26         /**
27          * Constructs new LSP Update Error Tlv.
28          * 
29          * @param errorCode
30          *            byte[]. Size has to be 4 bytes.
31          */
32         public LSPUpdateErrorTlv(byte[] errorCode) {
33                 if (errorCode.length != 4)
34                         throw new IllegalArgumentException("Update error code has wrong size.");
35                 this.errorCode = errorCode;
36         }
37
38         /**
39          * TBD
40          * 
41          * @return error code as byte[]
42          */
43         public byte[] getErrorCode() {
44                 return this.errorCode;
45         }
46
47         @Override
48         public int hashCode() {
49                 final int prime = 31;
50                 int result = 1;
51                 result = prime * result + Arrays.hashCode(this.errorCode);
52                 return result;
53         }
54
55         @Override
56         public boolean equals(Object obj) {
57                 if (this == obj)
58                         return true;
59                 if (obj == null)
60                         return false;
61                 if (this.getClass() != obj.getClass())
62                         return false;
63                 final LSPUpdateErrorTlv other = (LSPUpdateErrorTlv) obj;
64                 if (!Arrays.equals(this.errorCode, other.errorCode))
65                         return false;
66                 return true;
67         }
68
69         @Override
70         public String toString() {
71                 final StringBuilder builder = new StringBuilder();
72                 builder.append("LSPUpdateErrorTlv [errorCode=");
73                 builder.append(Arrays.toString(this.errorCode));
74                 builder.append("]");
75                 return builder.toString();
76         }
77
78 }