Merge "Bug 1029: Remove dead code: samples/clustersession"
[controller.git] / opendaylight / adsal / sal / api / src / main / java / org / opendaylight / controller / sal / core / Property.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 java.io.Serializable;
12
13 import javax.xml.bind.annotation.XmlAccessType;
14 import javax.xml.bind.annotation.XmlAccessorType;
15 import javax.xml.bind.annotation.XmlRootElement;
16
17 /**
18  * @file   Property.java
19  *
20  * @brief  Abstract base class for a Property that can be attached to
21  * any sal core element
22  *
23  * Abstract base class for a Property that can be attached to any sal
24  * core element
25  */
26
27 /**
28  * Abstract base class for a Property that can be attached to any sal core
29  * element
30  */
31 @XmlRootElement
32 @XmlAccessorType(XmlAccessType.NONE)
33 abstract public class Property implements Serializable, Cloneable {
34     private static final long serialVersionUID = 1L;
35     private final String name;
36
37     /**
38      * Private constructor used for JAXB mapping
39      */
40     @SuppressWarnings("unused")
41     private Property() {
42         this.name = null;
43     }
44
45     protected Property(String name) {
46         this.name = name;
47     }
48
49     public String getName() {
50         return this.name;
51     }
52
53     public abstract String getStringValue();
54
55     /**
56      * Used to copy the Property in a polymorphic way
57      *
58      * @return A clone of this Property
59      */
60     @Override
61     public abstract Property clone();
62
63     @Override
64     public int hashCode() {
65         final int prime = 31;
66         int result = 1;
67         result = prime * result + ((name == null) ? 0 : name.hashCode());
68         return result;
69     }
70
71     @Override
72     public boolean equals(Object obj) {
73         if (this == obj) {
74             return true;
75         }
76         if (obj == null) {
77             return false;
78         }
79         if (getClass() != obj.getClass()) {
80             return false;
81         }
82         Property other = (Property) obj;
83         if (name == null) {
84             if (other.name != null) {
85                 return false;
86             }
87         } else if (!name.equals(other.name)) {
88             return false;
89         }
90         return true;
91     }
92
93     @Override
94     public String toString() {
95         return "Property [name=" + name + "]";
96     }
97 }