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 | /** |
| 18 | * Constructor. |
| 19 | * |
| 20 | * @param srcMac source MAC address after the modification |
| 21 | */ |
| 22 | public ModifySrcMacAction(MACAddress srcMac) { |
| 23 | this.srcMac = checkNotNull(srcMac); |
| 24 | } |
| 25 | |
| 26 | /** |
| 27 | * Gets the source MAC address. |
| 28 | * |
| 29 | * @return the source MAC address |
| 30 | */ |
| 31 | public MACAddress getSrcMac() { |
| 32 | return srcMac; |
| 33 | } |
| 34 | |
| 35 | @Override |
| 36 | public int hashCode() { |
| 37 | return Objects.hashCode(srcMac); |
| 38 | } |
| 39 | |
| 40 | @Override |
| 41 | public boolean equals(Object obj) { |
| 42 | if (this == obj) { |
| 43 | return true; |
| 44 | } |
| 45 | if (obj == null || getClass() != obj.getClass()) { |
| 46 | return false; |
| 47 | } |
| 48 | ModifySrcMacAction that = (ModifySrcMacAction) obj; |
| 49 | return Objects.equal(this.srcMac, that.srcMac); |
| 50 | } |
| 51 | } |