Add ByteBufUtils
[bgpcep.git] / pcep / spi / src / main / java / org / opendaylight / protocol / pcep / spi / PCEPErrorIdentifier.java
1 /*
2  * Copyright (c) 2014 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.spi;
9
10 import java.io.Serializable;
11
12 /**
13  * Caret for combination of Error-type and Error-value.
14  */
15 final class PCEPErrorIdentifier implements Serializable {
16     private static final long serialVersionUID = 2434590156751699872L;
17
18     // FIXME: these should be Uint8s
19     private final short type;
20     private final short value;
21
22     PCEPErrorIdentifier(final short type, final short value) {
23         this.type = type;
24         this.value = value;
25     }
26
27     public short getType() {
28         return this.type;
29     }
30
31     public short getValue() {
32         return this.value;
33     }
34
35     @Override
36     public int hashCode() {
37         final int prime = 31;
38         int result = 1;
39         result = prime * result + this.type;
40         result = prime * result + this.value;
41         return result;
42     }
43
44     @Override
45     public boolean equals(final java.lang.Object obj) {
46         if (this == obj) {
47             return true;
48         }
49         if (obj == null || this.getClass() != obj.getClass()) {
50             return false;
51         }
52         final PCEPErrorIdentifier other = (PCEPErrorIdentifier) obj;
53         return this.type == other.type && this.value == other.value;
54     }
55
56     @Override
57     public String toString() {
58         return "type " + this.type + " value " + this.value;
59     }
60 }