Prevent ConfigPusher from killing its thread
[controller.git] / opendaylight / sal / api / src / main / java / org / opendaylight / controller / sal / core / ForwardingMode.java
1 package org.opendaylight.controller.sal.core;
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
8 /**
9  * The class represents the forwarding mode property of a node.
10  */
11 @XmlRootElement
12 @XmlAccessorType(XmlAccessType.NONE)
13 @SuppressWarnings("serial")
14 public class ForwardingMode extends Property {
15     @XmlElement(name="value")
16     private final int modeValue;
17     public static final int REACTIVE_FORWARDING = 0;
18     public static final int PROACTIVE_FORWARDING = 1;
19     public static final String name = "forwarding";
20
21     /*
22      * Private constructor used for JAXB mapping
23      */
24     private ForwardingMode() {
25         super(name);
26         this.modeValue = REACTIVE_FORWARDING;
27     }
28
29     public ForwardingMode(int mode) {
30         super(name);
31         this.modeValue = mode;
32     }
33
34     public int getValue() {
35         return this.modeValue;
36     }
37
38     public boolean isProactive() {
39         return (modeValue == ForwardingMode.PROACTIVE_FORWARDING);
40     }
41
42     public boolean isValid() {
43         return ((modeValue >= 0) && (modeValue <= 1));
44     }
45
46     @Override
47     public ForwardingMode clone() {
48         return new ForwardingMode(this.modeValue);
49     }
50
51     @Override
52     public int hashCode() {
53         final int prime = 31;
54         int result = super.hashCode();
55         result = prime * result + modeValue;
56         return result;
57     }
58
59     @Override
60     public boolean equals(Object obj) {
61         if (this == obj)
62             return true;
63         if (!super.equals(obj))
64             return false;
65         if (getClass() != obj.getClass())
66             return false;
67         ForwardingMode other = (ForwardingMode) obj;
68         if (modeValue != other.modeValue)
69             return false;
70         return true;
71     }
72
73     @Override
74     public String toString() {
75         return "Mode[" + modeValue + "]";
76     }
77
78     @Override
79     public String getStringValue() {
80         return (modeValue == ForwardingMode.PROACTIVE_FORWARDING) ? "Proactive" : "Reactive";
81     }
82 }