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