Enhancement to switchmanager CLI commands to display all the properties of node and...
[controller.git] / opendaylight / 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.XmlElement;
13 import javax.xml.bind.annotation.XmlRootElement;
14
15 /**
16  * @file   Capabilities.java
17  *
18  * @brief  Class representing capabilities
19  *
20  * Describes supported capabilities
21  */
22 @XmlRootElement
23 public class Capabilities extends Property {
24         private static final long serialVersionUID = 1L;
25     @XmlElement(name="value")
26     private int capabilitiesValue;
27
28     public enum CapabilitiesType {
29         FLOW_STATS_CAPABILITY(1<<0),
30         TABLE_STATS_CAPABILITY(1<<1),
31         PORT_STATS_CAPABILITY(1<<2),
32         STP_CAPABILITY(1<<3),
33         RSVD_CAPABILITY(1<<4),
34         IP_REASSEM_CAPABILITY(1<<5),
35         QUEUE_STATS_CAPABILITY(1<<6),
36         ARP_MATCH_IP_CAPABILITY(1<<7);
37         private final int ct;
38         CapabilitiesType(int val) {
39                 this.ct = val;
40         }
41         public int getValue() {
42                 return ct;
43         }
44     }
45
46     public static final String CapabilitiesPropName = "capabilities";
47     /**
48      * Construct a Capabilities property
49      *
50      * @param capabilities the Capabilities value
51      * @return Constructed object
52      */
53     public Capabilities(int capabilities) {
54         super(CapabilitiesPropName);
55         this.capabilitiesValue = capabilities;
56     }
57
58     /*
59      * Private constructor used for JAXB mapping
60      */
61     private Capabilities() {
62         super(CapabilitiesPropName);
63         this.capabilitiesValue = 0;
64     }
65
66     @Override
67     public Capabilities clone() {
68         return new Capabilities(this.capabilitiesValue);
69     }
70
71     public int getValue() {
72         return this.capabilitiesValue;
73     }
74
75     @Override
76     public int hashCode() {
77         final int prime = 31;
78         int result = super.hashCode();
79         result = prime * result + capabilitiesValue;
80         return result;
81     }
82
83     @Override
84     public boolean equals(Object obj) {
85         if (this == obj)
86             return true;
87         if (!super.equals(obj))
88             return false;
89         if (getClass() != obj.getClass())
90             return false;
91         Capabilities other = (Capabilities) obj;
92         if (capabilitiesValue != other.capabilitiesValue)
93             return false;
94         return true;
95     }
96
97     @Override
98     public String toString() {
99         return "Capabilities[" + capabilitiesValue + "]";
100     }
101
102     @Override
103     public String getStringValue() {
104         return Integer.toHexString(capabilitiesValue);
105     }
106 }