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")
21 public class ForwardingMode extends Property {
22 @XmlElement(name="value")
23 private final int modeValue;
24 public static final int REACTIVE_FORWARDING = 0;
25 public static final int PROACTIVE_FORWARDING = 1;
26 public static final String name = "forwarding";
29 * Private constructor used for JAXB mapping
31 private ForwardingMode() {
33 this.modeValue = REACTIVE_FORWARDING;
36 public ForwardingMode(int mode) {
38 this.modeValue = mode;
41 public int getValue() {
42 return this.modeValue;
45 public boolean isProactive() {
46 return (modeValue == ForwardingMode.PROACTIVE_FORWARDING);
49 public boolean isValid() {
50 return ((modeValue >= 0) && (modeValue <= 1));
54 public ForwardingMode clone() {
55 return new ForwardingMode(this.modeValue);
59 public int hashCode() {
61 int result = super.hashCode();
62 result = prime * result + modeValue;
67 public boolean equals(Object obj) {
70 if (!super.equals(obj))
72 if (getClass() != obj.getClass())
74 ForwardingMode other = (ForwardingMode) obj;
75 if (modeValue != other.modeValue)
81 public String toString() {
82 return "Mode[" + modeValue + "]";
86 public String getStringValue() {
87 return (modeValue == ForwardingMode.PROACTIVE_FORWARDING) ? "Proactive" : "Reactive";