Revert "BUG-47 : unfinished PCEP migration to generated DTOs."
[bgpcep.git] / pcep / api / src / main / java / org / opendaylight / protocol / pcep / tlv / P2MPCapabilityTlv.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 P2MP Capability Tlv.
14  * 
15  * @see <a href="http://tools.ietf.org/html/rfc6006#section-3.1.2">3.1.2. Open
16  *      Message Extension [RFC6006]</a>
17  */
18 public class P2MPCapabilityTlv implements PCEPTlv {
19     private static final long serialVersionUID = -7959631526276210055L;
20
21     private final int value;
22
23     /**
24      * Constructs new P2MP Capability Tlv.
25      */
26     public P2MPCapabilityTlv(int value) {
27         if (value < 0 || value > 65535)
28             throw new IllegalArgumentException("Value (" + value + ") cannot be negative or bigger than 2^16 -1.");
29
30         this.value = value;
31     }
32
33     /**
34      * Constructs new P2MP Capability Tlv, with value defaultly set to zero as
35      * mentioned in RFC6006.
36      */
37     public P2MPCapabilityTlv() {
38         this.value = 0;
39     }
40
41     /**
42      * Gets integer value of P2MP Capability Tlv.
43      * 
44      * @return int
45      */
46     public int getValue() {
47         return this.value;
48     }
49
50     @Override
51     public int hashCode() {
52         final int prime = 31;
53         int result = 1;
54         result = prime * result + this.value;
55         return result;
56     }
57
58     @Override
59     public boolean equals(Object obj) {
60         if (this == obj)
61             return true;
62         if (obj == null)
63             return false;
64         if (this.getClass() != obj.getClass())
65             return false;
66         final P2MPCapabilityTlv other = (P2MPCapabilityTlv) obj;
67         if (this.value != other.value)
68             return false;
69         return true;
70     }
71
72     @Override
73     public String toString() {
74         final StringBuilder builder = new StringBuilder();
75         builder.append("P2MPCapablityTlv [value=");
76         builder.append(this.value);
77         builder.append("]");
78         return builder.toString();
79     }
80 }