X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fsal%2Fapi%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fsal%2Faction%2FAction.java;h=c1c38aa76c85412ea7db20848580e6b490e822fa;hp=332e31f6bf5337e93f0516eafe03166680450e88;hb=181b536d898b6385093d4e4eddad495917da4571;hpb=ff1b4a79cca00743a00c3b0b1100bd0ab2b2fb31 diff --git a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/action/Action.java b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/action/Action.java index 332e31f6bf..c1c38aa76c 100644 --- a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/action/Action.java +++ b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/action/Action.java @@ -1,4 +1,3 @@ - /* * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. * @@ -9,40 +8,39 @@ package org.opendaylight.controller.sal.action; -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlSeeAlso; -import javax.xml.bind.annotation.XmlTransient; - import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import javax.xml.bind.annotation.*; +import java.io.Serializable; + /** - * Represents the generic action to be applied to the matched frame/packet/message + * Represents the generic action to be applied to the matched + * frame/packet/message */ @XmlRootElement @XmlAccessorType(XmlAccessType.NONE) -@XmlSeeAlso({Controller.class, Drop.class, Flood.class, FloodAll.class, HwPath.class, Loopback.class, Output.class, - PopVlan.class, PushVlan.class, SetDlDst.class, SetDlSrc.class, SetDlType.class, SetNwDst.class, SetNwSrc.class, - SetNwTos.class, SetTpDst.class, SetTpSrc.class, SetVlanCfi.class, SetVlanId.class, SetVlanPcp.class, SwPath.class}) -public abstract class Action { +@XmlSeeAlso({ Controller.class, Drop.class, Flood.class, FloodAll.class, HwPath.class, Loopback.class, Output.class, + PopVlan.class, PushVlan.class, SetDlDst.class, SetDlSrc.class, SetDlType.class, SetNwDst.class, SetNwSrc.class, + SetNwTos.class, SetTpDst.class, SetTpSrc.class, SetVlanCfi.class, SetVlanId.class, SetVlanPcp.class, + SwPath.class }) +public abstract class Action implements Serializable { + private static final long serialVersionUID = 1L; private static final Logger logger = LoggerFactory.getLogger(Action.class); - private static boolean debug = false; // Enable to find where in the code an invalid assignment is made - @XmlTransient + private static boolean debug = false; // Enable to find where in the code an + // invalid assignment is made + @XmlElement protected ActionType type; private transient boolean isValid = true; /* Dummy constructor for JAXB */ - public Action () { + public Action() { } /* - public Action (ActionType type, Object value) { - this.type = type; - this.value = value; - this.isValid = true; - } */ + * public Action (ActionType type, Object value) { this.type = type; + * this.value = value; this.isValid = true; } + */ /** * Checks if the passed value is in the valid range for this action @@ -58,8 +56,8 @@ public abstract class Action { } /** - * Checks if the passed value is in the valid range for the passed action type - * This method is used for complex Action types which are + * Checks if the passed value is in the valid range for the passed action + * type This method is used for complex Action types which are * * @param value * @return boolean @@ -78,15 +76,14 @@ public abstract class Action { * @return void */ private void throwValueException(int value) { - String error = "Invalid field value assignement. For type: " - + type.getId() + " Expected: " + type.getRange() + ", Got: 0x" - + Integer.toHexString(value); + String error = "Invalid field value assignement. For type: " + type.getId() + " Expected: " + type.getRange() + + ", Got: 0x" + Integer.toHexString(value); try { throw new Exception(error); } catch (Exception e) { logger.error(e.getMessage()); if (debug) { - logger.error("",e); + logger.error("", e); } } } @@ -112,7 +109,7 @@ public abstract class Action { /** * Returns whether the Action is valid or not * - * @return boolean + * @return boolean */ public boolean isValid() { return isValid; @@ -122,21 +119,25 @@ public abstract class Action { public int hashCode() { final int prime = 31; int result = 1; - result = prime * result + ((type == null) ? 0 : type.hashCode()); + result = prime * result + ((type == null) ? 0 : type.calculateConsistentHashCode()); return result; } @Override public boolean equals(Object obj) { - if (this == obj) + if (this == obj) { return true; - if (obj == null) + } + if (obj == null) { return false; - if (getClass() != obj.getClass()) + } + if (getClass() != obj.getClass()) { return false; + } Action other = (Action) obj; - if (type != other.type) + if (type != other.type) { return false; + } return true; }