ef6efc58211577fb9799509c1d998949a44364dc
[controller.git] / opendaylight / sal / api / src / main / java / org / opendaylight / controller / sal / core / Config.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
9 package org.opendaylight.controller.sal.core;
10
11 import javax.xml.bind.annotation.XmlElement;
12 import javax.xml.bind.annotation.XmlRootElement;
13
14 /**
15  * The class represents Admin Config status
16  *
17  *
18  */
19 @XmlRootElement
20 @SuppressWarnings("serial")
21 public class Config extends Property {
22     @XmlElement(name="value")
23     private short configValue;
24
25     public static final short ADMIN_DOWN = 0;
26     public static final short ADMIN_UP = 1;
27     public static final short ADMIN_UNDEF = 0x7fff;
28     public static final String ConfigPropName = "config";
29
30     /*
31      * Private constructor used for JAXB mapping
32      */
33     private Config() {
34         super(ConfigPropName);
35         this.configValue = ADMIN_UNDEF;
36     }
37
38     public Config(short config) {
39         super(ConfigPropName);
40         this.configValue = config;
41     }
42
43     @Override
44     public Config clone() {
45         return new Config(this.configValue);
46     }
47
48     public short getValue() {
49         return this.configValue;
50     }
51
52     @Override
53     public int hashCode() {
54         final int prime = 31;
55         int result = super.hashCode();
56         result = prime * result + configValue;
57         return result;
58     }
59
60     @Override
61     public boolean equals(Object obj) {
62         if (this == obj)
63             return true;
64         if (!super.equals(obj))
65             return false;
66         if (getClass() != obj.getClass())
67             return false;
68         Config other = (Config) obj;
69         if (configValue != other.configValue)
70             return false;
71         return true;
72     }
73
74     @Override
75     public String toString() {
76         return "Config["+ configValue +"]";
77     }
78 }