2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.controller.sal.core;
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;
16 * The class represents the forwarding mode property of a node.
19 @XmlAccessorType(XmlAccessType.NONE)
20 @SuppressWarnings("serial")
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";
30 * Private constructor used for JAXB mapping
32 private ForwardingMode() {
34 this.modeValue = REACTIVE_FORWARDING;
37 public ForwardingMode(int mode) {
39 this.modeValue = mode;
42 public int getValue() {
43 return this.modeValue;
46 public boolean isProactive() {
47 return (modeValue == ForwardingMode.PROACTIVE_FORWARDING);
50 public boolean isValid() {
51 return ((modeValue >= 0) && (modeValue <= 1));
55 public ForwardingMode clone() {
56 return new ForwardingMode(this.modeValue);
60 public int hashCode() {
62 int result = super.hashCode();
63 result = prime * result + modeValue;
68 public boolean equals(Object obj) {
71 if (!super.equals(obj))
73 if (getClass() != obj.getClass())
75 ForwardingMode other = (ForwardingMode) obj;
76 if (modeValue != other.modeValue)
82 public String toString() {
83 return "Mode[" + modeValue + "]";
87 public String getStringValue() {
88 return (modeValue == ForwardingMode.PROACTIVE_FORWARDING) ? "Proactive" : "Reactive";