Toshio Koide | bf8f865 | 2014-08-19 16:34:24 -0700 | [diff] [blame] | 1 | package net.onrc.onos.core.matchaction.action; |
| 2 | |
| 3 | import static com.google.common.base.Preconditions.checkNotNull; |
| 4 | import net.floodlightcontroller.util.MACAddress; |
| 5 | |
| 6 | import com.google.common.base.Objects; |
| 7 | |
| 8 | /** |
| 9 | * An action object to modify source MAC address. |
| 10 | * <p> |
| 11 | * This class does not have a switch ID. The switch ID is handled by |
| 12 | * MatchAction, Flow or Intent class. |
| 13 | */ |
| 14 | public class ModifySrcMacAction implements Action { |
| 15 | private final MACAddress srcMac; |
| 16 | |
| 17 | /** |
Toshio Koide | 2c67a2d | 2014-08-27 11:30:56 -0700 | [diff] [blame] | 18 | * Default constructor for Kryo deserialization. |
| 19 | */ |
| 20 | @Deprecated |
| 21 | protected ModifySrcMacAction() { |
| 22 | srcMac = null; |
| 23 | } |
| 24 | |
| 25 | /** |
Toshio Koide | bf8f865 | 2014-08-19 16:34:24 -0700 | [diff] [blame] | 26 | * Constructor. |
| 27 | * |
| 28 | * @param srcMac source MAC address after the modification |
| 29 | */ |
| 30 | public ModifySrcMacAction(MACAddress srcMac) { |
| 31 | this.srcMac = checkNotNull(srcMac); |
| 32 | } |
| 33 | |
| 34 | /** |
| 35 | * Gets the source MAC address. |
| 36 | * |
| 37 | * @return the source MAC address |
| 38 | */ |
| 39 | public MACAddress getSrcMac() { |
| 40 | return srcMac; |
| 41 | } |
| 42 | |
| 43 | @Override |
| 44 | public int hashCode() { |
| 45 | return Objects.hashCode(srcMac); |
| 46 | } |
| 47 | |
| 48 | @Override |
| 49 | public boolean equals(Object obj) { |
| 50 | if (this == obj) { |
| 51 | return true; |
| 52 | } |
| 53 | if (obj == null || getClass() != obj.getClass()) { |
| 54 | return false; |
| 55 | } |
| 56 | ModifySrcMacAction that = (ModifySrcMacAction) obj; |
| 57 | return Objects.equal(this.srcMac, that.srcMac); |
| 58 | } |
| 59 | } |