Toshio Koide | 80db184 | 2014-08-11 17:08:32 -0700 | [diff] [blame] | 1 | package net.onrc.onos.core.matchaction.action; |
| 2 | |
Toshio Koide | bf8f865 | 2014-08-19 16:34:24 -0700 | [diff] [blame] | 3 | import static com.google.common.base.Preconditions.checkNotNull; |
Toshio Koide | 80db184 | 2014-08-11 17:08:32 -0700 | [diff] [blame] | 4 | import net.floodlightcontroller.util.MACAddress; |
| 5 | |
Toshio Koide | bf8f865 | 2014-08-19 16:34:24 -0700 | [diff] [blame] | 6 | import com.google.common.base.Objects; |
| 7 | |
Toshio Koide | 80db184 | 2014-08-11 17:08:32 -0700 | [diff] [blame] | 8 | /** |
| 9 | * An action object to modify destination MAC address. |
| 10 | * <p> |
| 11 | * This class does not have a switch ID. The switch ID is handled by |
Toshio Koide | 7894ca0 | 2014-08-15 14:30:13 -0700 | [diff] [blame] | 12 | * MatchAction, Flow or Intent class. |
Toshio Koide | 80db184 | 2014-08-11 17:08:32 -0700 | [diff] [blame] | 13 | */ |
| 14 | public class ModifyDstMacAction implements Action { |
| 15 | private final MACAddress dstMac; |
| 16 | |
| 17 | /** |
| 18 | * Constructor. |
| 19 | * |
| 20 | * @param dstMac destination MAC address after the modification |
| 21 | */ |
| 22 | public ModifyDstMacAction(MACAddress dstMac) { |
Toshio Koide | bf8f865 | 2014-08-19 16:34:24 -0700 | [diff] [blame] | 23 | this.dstMac = checkNotNull(dstMac); |
Toshio Koide | 80db184 | 2014-08-11 17:08:32 -0700 | [diff] [blame] | 24 | } |
| 25 | |
| 26 | /** |
| 27 | * Gets the destination MAC address. |
| 28 | * |
| 29 | * @return the destination MAC address |
| 30 | */ |
| 31 | public MACAddress getDstMac() { |
| 32 | return dstMac; |
| 33 | } |
| 34 | |
Toshio Koide | bf8f865 | 2014-08-19 16:34:24 -0700 | [diff] [blame] | 35 | @Override |
| 36 | public int hashCode() { |
| 37 | return Objects.hashCode(dstMac); |
| 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 | ModifyDstMacAction that = (ModifyDstMacAction) obj; |
| 49 | return Objects.equal(this.dstMac, that.dstMac); |
| 50 | } |
Toshio Koide | 80db184 | 2014-08-11 17:08:32 -0700 | [diff] [blame] | 51 | } |