BUG-47: more subobject models
[bgpcep.git] / pcep / api / src / main / java / org / opendaylight / protocol / pcep / subobject / XROSRLGSubobject.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.subobject;
9
10 /**
11  * Structure of Shared Risk Link Group Subobject. Defined in RFC5521.
12  * 
13  * @see <a href="http://tools.ietf.org/html/rfc5521#section-2.1.1">Exclude Route Object definition</a>
14  */
15 public class XROSRLGSubobject extends ExcludeRouteSubobject {
16
17         private final XROSubobjectAttribute attribute;
18
19         // private final SharedRiskLinkGroup srlgId;
20
21         /**
22          * Constructs new Shared Risk Link Group Subobject.
23          * 
24          * @param srlgId SharedRiskLinkGroup
25          * @param mandatory boolean
26          */
27         public XROSRLGSubobject(final boolean mandatory) {
28                 super(mandatory);
29                 this.attribute = XROSubobjectAttribute.SRLG;
30                 // this.srlgId = srlgId;
31         }
32
33         /**
34          * Gets the Shared Risk Link Group.
35          * 
36          * @return SharedRiskLinkGroup
37          */
38         // public SharedRiskLinkGroup getSrlgId() {
39         // return this.srlgId;
40         // }
41
42         /**
43          * Gets the attribute of the subobject
44          * 
45          * @return the attribute
46          */
47         public XROSubobjectAttribute getAttribute() {
48                 return this.attribute;
49         }
50
51         @Override
52         public String toString() {
53                 final StringBuilder builder = new StringBuilder();
54                 builder.append("XROSRLGSubobject [attribute=");
55                 builder.append(this.attribute);
56                 builder.append(", mandatory=");
57                 builder.append(this.mandatory);
58                 builder.append("]");
59                 return builder.toString();
60         }
61
62         @Override
63         public int hashCode() {
64                 final int prime = 31;
65                 int result = super.hashCode();
66                 result = prime * result + ((this.attribute == null) ? 0 : this.attribute.hashCode());
67                 return result;
68         }
69
70         @Override
71         public boolean equals(final Object obj) {
72                 if (this == obj)
73                         return true;
74                 if (!super.equals(obj))
75                         return false;
76                 if (this.getClass() != obj.getClass())
77                         return false;
78                 final XROSRLGSubobject other = (XROSRLGSubobject) obj;
79                 if (this.attribute != other.attribute)
80                         return false;
81                 return true;
82         }
83
84 }