Five more Equals/HashCode/StringBuilder replacements
[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
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     public Capabilities clone() {
67         return new Capabilities(this.capabilitiesValue);
68     }
69
70     public int getValue() {
71         return this.capabilitiesValue;
72     }
73     
74     @Override
75     public int hashCode() {
76         final int prime = 31;
77         int result = super.hashCode();
78         result = prime * result + capabilitiesValue;
79         return result;
80     }
81
82     @Override
83     public boolean equals(Object obj) {
84         if (this == obj)
85             return true;
86         if (!super.equals(obj))
87             return false;
88         if (getClass() != obj.getClass())
89             return false;
90         Capabilities other = (Capabilities) obj;
91         if (capabilitiesValue != other.capabilitiesValue)
92             return false;
93         return true;
94     }
95
96     @Override
97     public String toString() {
98         return "Capabilities[" + capabilitiesValue + "]";
99     }
100 }