BUG-47: more subobject models
[bgpcep.git] / pcep / api / src / main / java / org / opendaylight / protocol / pcep / subobject / EROWavebandSwitchingLabelSubobject.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 Generalized Label subobject
15  *
16  * @see <a href="http://tools.ietf.org/html/rfc3473#section-2.4">2.4. Waveband
17  *      Switching Object </a>
18  */
19 public class EROWavebandSwitchingLabelSubobject extends EROLabelSubobject {
20
21     private final long wavebandId;
22
23     private final long startLabel;
24
25     private final long endLabel;
26
27     public EROWavebandSwitchingLabelSubobject(long wavebandId, long startLabel, long endLabel, boolean upStream, boolean loose) {
28         super(upStream);
29         this.wavebandId = wavebandId;
30         this.startLabel = startLabel;
31         this.endLabel = endLabel;
32     }
33
34     public long getWavebandId() {
35         return this.wavebandId;
36     }
37
38     public long getStartLabel() {
39         return this.startLabel;
40     }
41
42     public long getEndLabel() {
43         return this.endLabel;
44     }
45
46     @Override
47     public int hashCode() {
48         final int prime = 31;
49         int result = super.hashCode();
50         result = prime * result + (int) (this.endLabel ^ (this.endLabel >>> 32));
51         result = prime * result + (int) (this.startLabel ^ (this.startLabel >>> 32));
52         result = prime * result + (int) (this.wavebandId ^ (this.wavebandId >>> 32));
53         return result;
54     }
55
56     @Override
57     public boolean equals(Object obj) {
58         if (this == obj)
59             return true;
60         if (!super.equals(obj))
61             return false;
62         if (this.getClass() != obj.getClass())
63             return false;
64         final EROWavebandSwitchingLabelSubobject other = (EROWavebandSwitchingLabelSubobject) obj;
65         if (this.endLabel != other.endLabel)
66             return false;
67         if (this.startLabel != other.startLabel)
68             return false;
69         if (this.wavebandId != other.wavebandId)
70             return false;
71         return true;
72     }
73
74     @Override
75         protected ToStringHelper addToStringAttributes(ToStringHelper toStringHelper) {
76                 toStringHelper.add("wavebandId", this.wavebandId);
77                 toStringHelper.add("startLabel", this.startLabel);
78                 toStringHelper.add("endLabel", this.endLabel);
79                 return super.addToStringAttributes(toStringHelper);
80         }
81 }