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