* Moved all l2 forwarding services based on OF to a separate OSGi
[affinity.git] / affinity / api / src / main / java / org / opendaylight / affinity / affinity / AffinityAttribute.java
1 package org.opendaylight.affinity.affinity;
2
3 import javax.xml.bind.annotation.XmlAccessType;
4 import javax.xml.bind.annotation.XmlAccessorType;
5 import javax.xml.bind.annotation.XmlElement;
6 import javax.xml.bind.annotation.XmlRootElement;
7 import java.io.Serializable;
8
9 import org.slf4j.Logger;
10 import org.slf4j.LoggerFactory;
11
12
13 /**
14  * Represents the attribute associated with an affinity link. 
15  */
16 @XmlRootElement
17 @XmlAccessorType(XmlAccessType.NONE)
18 public abstract class AffinityAttribute implements Serializable {
19     private static final long serialVersionUID = 1L;
20     private static final Logger logger = LoggerFactory.getLogger(AffinityAttribute.class);
21     @XmlElement
22     protected AffinityAttributeType type;
23     private transient boolean isValid = true;
24
25     /* Dummy constructor for JAXB */
26     public AffinityAttribute() {
27     }
28
29     public AffinityAttributeType getType() {
30         return type;
31     }
32
33     /**
34      * Returns the id of this action
35      *
36      * @return String
37      */
38     public String getId() {
39         return type.getId();
40     }
41
42     @Override
43     public int hashCode() {
44         final int prime = 31;
45         int result = 1;
46         result = prime * result + ((type == null) ? 0 : type.calculateConsistentHashCode());
47         return result;
48     }
49
50     @Override
51     public boolean equals(Object obj) {
52         if (this == obj) {
53             return true;
54         }
55         if (obj == null) {
56             return false;
57         }
58         if (getClass() != obj.getClass()) {
59             return false;
60         }
61         AffinityAttribute other = (AffinityAttribute) obj;
62         if (type != other.type) {
63             return false;
64         }
65         return true;
66     }
67
68     @Override
69     public String toString() {
70         return type.toString();
71     }
72
73 }