724c8427f6edbe0003ed202930d0267cba04ede4
[controller.git] / opendaylight / adsal / sal / api / src / main / java / org / opendaylight / controller / sal / core / Tables.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   Tables.java
19  *
20  * @brief  Class representing tables
21  *
22  * Describes supported # of datapath tables
23  */
24 @XmlRootElement
25 @XmlAccessorType(XmlAccessType.NONE)
26 public class Tables extends Property {
27         private static final long serialVersionUID = 1L;
28     @XmlElement(name="value")
29     private byte tablesValue;
30
31     public static final String TablesPropName = "tables";
32     /**
33      * Construct a Tables property
34      *
35      * @param tables the Tables
36      * @return Constructed object
37      */
38     public Tables(byte tables) {
39         super(TablesPropName);
40         this.tablesValue = tables;
41     }
42
43     /*
44      * Private constructor used for JAXB mapping
45      */
46     private Tables() {
47         super(TablesPropName);
48         this.tablesValue = 0;
49     }
50
51     @Override
52     public Tables clone() {
53         return new Tables(this.tablesValue);
54     }
55
56     public byte getValue() {
57         return this.tablesValue;
58     }
59
60     @Override
61     public int hashCode() {
62         final int prime = 31;
63         int result = super.hashCode();
64         result = prime * result + tablesValue;
65         return result;
66     }
67
68     @Override
69     public boolean equals(Object obj) {
70         if (this == obj)
71             return true;
72         if (!super.equals(obj))
73             return false;
74         if (getClass() != obj.getClass())
75             return false;
76         Tables other = (Tables) obj;
77         if (tablesValue != other.tablesValue)
78             return false;
79         return true;
80     }
81
82     @Override
83     public String toString() {
84         return "Tables[" + tablesValue + "]";
85     }
86
87     @Override
88     public String getStringValue() {
89         return String.format("%02x", tablesValue);
90     }
91 }