Merge "Bug 1029: Remove dead code: samples/clustersession"
[controller.git] / opendaylight / adsal / sal / api / src / main / java / org / opendaylight / controller / sal / core / Capabilities.java
1
2 /*
3  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
4  *
5  * This program and the accompanying materials are made available under the
6  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
7  * and is available at http://www.eclipse.org/legal/epl-v10.html
8  */
9
10 package org.opendaylight.controller.sal.core;
11
12 import javax.xml.bind.annotation.XmlAccessType;
13 import javax.xml.bind.annotation.XmlAccessorType;
14 import javax.xml.bind.annotation.XmlElement;
15 import javax.xml.bind.annotation.XmlRootElement;
16
17 /**
18  * @file   Capabilities.java
19  *
20  * @brief  Class representing capabilities
21  *
22  * Describes supported capabilities
23  */
24 @XmlRootElement
25 @XmlAccessorType(XmlAccessType.NONE)
26 public class Capabilities extends Property {
27         private static final long serialVersionUID = 1L;
28     @XmlElement(name="value")
29     private int capabilitiesValue;
30
31     public enum CapabilitiesType {
32         FLOW_STATS_CAPABILITY(1<<0),
33         TABLE_STATS_CAPABILITY(1<<1),
34         PORT_STATS_CAPABILITY(1<<2),
35         STP_CAPABILITY(1<<3),
36         RSVD_CAPABILITY(1<<4),
37         IP_REASSEM_CAPABILITY(1<<5),
38         QUEUE_STATS_CAPABILITY(1<<6),
39         ARP_MATCH_IP_CAPABILITY(1<<7);
40         private final int ct;
41         CapabilitiesType(int val) {
42                 this.ct = val;
43         }
44         public int getValue() {
45                 return ct;
46         }
47     }
48
49     public static final String CapabilitiesPropName = "capabilities";
50     /**
51      * Construct a Capabilities property
52      *
53      * @param capabilities the Capabilities value
54      * @return Constructed object
55      */
56     public Capabilities(int capabilities) {
57         super(CapabilitiesPropName);
58         this.capabilitiesValue = capabilities;
59     }
60
61     /*
62      * Private constructor used for JAXB mapping
63      */
64     private Capabilities() {
65         super(CapabilitiesPropName);
66         this.capabilitiesValue = 0;
67     }
68
69     @Override
70     public Capabilities clone() {
71         return new Capabilities(this.capabilitiesValue);
72     }
73
74     public int getValue() {
75         return this.capabilitiesValue;
76     }
77
78     @Override
79     public int hashCode() {
80         final int prime = 31;
81         int result = super.hashCode();
82         result = prime * result + capabilitiesValue;
83         return result;
84     }
85
86     @Override
87     public boolean equals(Object obj) {
88         if (this == obj)
89             return true;
90         if (!super.equals(obj))
91             return false;
92         if (getClass() != obj.getClass())
93             return false;
94         Capabilities other = (Capabilities) obj;
95         if (capabilitiesValue != other.capabilitiesValue)
96             return false;
97         return true;
98     }
99
100     @Override
101     public String toString() {
102         return "Capabilities[" + capabilitiesValue + "]";
103     }
104
105     @Override
106     public String getStringValue() {
107         return Integer.toHexString(capabilitiesValue);
108     }
109 }