BUG-47: more subobject models
[bgpcep.git] / pcep / api / src / main / java / org / opendaylight / protocol / pcep / subobject / RROType1LabelSubobject.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.subobject;
10
11 import com.google.common.base.Objects.ToStringHelper;
12
13 /**
14  * Structure of Type 1 Label subobject
15  *
16  * @see <a href="http://tools.ietf.org/html/rfc3209#section-4.1">4.1. Label
17  *      Object</a>
18  */
19 public class RROType1LabelSubobject extends RROLabelSubobject {
20
21     private final long label;
22
23     public RROType1LabelSubobject(long label, boolean upStream) {
24         super(upStream);
25         this.label = label;
26     }
27
28     public long getLabel() {
29         return this.label;
30     }
31
32     @Override
33     public int hashCode() {
34         final int prime = 31;
35         int result = super.hashCode();
36         result = prime * result + (int) (this.label ^ (this.label >>> 32));
37         return result;
38     }
39
40     @Override
41     public boolean equals(Object obj) {
42         if (this == obj)
43             return true;
44         if (!super.equals(obj))
45             return false;
46         if (this.getClass() != obj.getClass())
47             return false;
48         final RROType1LabelSubobject other = (RROType1LabelSubobject) obj;
49         if (this.label != other.label)
50             return false;
51         return true;
52     }
53
54         @Override
55         protected ToStringHelper addToStringAttributes(ToStringHelper toStringHelper) {
56                 toStringHelper.add("label", this.label);
57                 return super.addToStringAttributes(toStringHelper);
58         }
59
60 }