BUG 2302 : odl-clustering-test-app should not be part of the odl-restconf-all feature set
[controller.git] / opendaylight / adsal / 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.XmlAccessType;
12 import javax.xml.bind.annotation.XmlAccessorType;
13 import javax.xml.bind.annotation.XmlElement;
14 import javax.xml.bind.annotation.XmlRootElement;
15
16 /**
17  * The class represents Admin Config status
18  *
19  *
20  */
21 @XmlRootElement
22 @SuppressWarnings("serial")
23 @XmlAccessorType(XmlAccessType.NONE)
24 public class Config extends Property {
25     @XmlElement(name="value")
26     private short configValue;
27
28     public static final short ADMIN_DOWN = 0;
29     public static final short ADMIN_UP = 1;
30     public static final short ADMIN_UNDEF = 0x7fff;
31     public static final String ConfigPropName = "config";
32
33     /*
34      * Private constructor used for JAXB mapping
35      */
36     private Config() {
37         super(ConfigPropName);
38         this.configValue = ADMIN_UNDEF;
39     }
40
41     public Config(short config) {
42         super(ConfigPropName);
43         this.configValue = config;
44     }
45
46     @Override
47     public Config clone() {
48         return new Config(this.configValue);
49     }
50
51     public short getValue() {
52         return this.configValue;
53     }
54
55     @Override
56     public int hashCode() {
57         final int prime = 31;
58         int result = super.hashCode();
59         result = prime * result + configValue;
60         return result;
61     }
62
63     @Override
64     public boolean equals(Object obj) {
65         if (this == obj)
66             return true;
67         if (!super.equals(obj))
68             return false;
69         if (getClass() != obj.getClass())
70             return false;
71         Config other = (Config) obj;
72         if (configValue != other.configValue)
73             return false;
74         return true;
75     }
76
77     @Override
78     public String toString() {
79         return "Config["+ configValue +"]";
80     }
81
82     @Override
83     public String getStringValue() {
84         if (configValue == 0) {
85             return "ADMIN_DOWN";
86         } else if (configValue == 1) {
87             return "ADMIN_UP";
88         } else if (configValue == 0x7fff) {
89             return "ADMIN_UNDEF";
90         } else {
91             return String.valueOf(configValue);
92         }
93     }
94 }