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