blob: c39cebe98c781c15706c15c5b9fec1389c856861 [file] [log] [blame]
Toshio Koide80db1842014-08-11 17:08:32 -07001package net.onrc.onos.core.matchaction.action;
2
Toshio Koidebf8f8652014-08-19 16:34:24 -07003import static com.google.common.base.Preconditions.checkNotNull;
Toshio Koide80db1842014-08-11 17:08:32 -07004import net.floodlightcontroller.util.MACAddress;
5
Toshio Koidebf8f8652014-08-19 16:34:24 -07006import com.google.common.base.Objects;
7
Toshio Koide80db1842014-08-11 17:08:32 -07008/**
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 Koide7894ca02014-08-15 14:30:13 -070012 * MatchAction, Flow or Intent class.
Toshio Koide80db1842014-08-11 17:08:32 -070013 */
14public class ModifyDstMacAction implements Action {
15 private final MACAddress dstMac;
16
17 /**
Toshio Koide2c67a2d2014-08-27 11:30:56 -070018 * Default constructor for Kryo deserialization.
19 */
20 @Deprecated
21 protected ModifyDstMacAction() {
22 dstMac = null;
23 }
24
25 /**
Toshio Koide80db1842014-08-11 17:08:32 -070026 * Constructor.
27 *
28 * @param dstMac destination MAC address after the modification
29 */
30 public ModifyDstMacAction(MACAddress dstMac) {
Toshio Koidebf8f8652014-08-19 16:34:24 -070031 this.dstMac = checkNotNull(dstMac);
Toshio Koide80db1842014-08-11 17:08:32 -070032 }
33
34 /**
35 * Gets the destination MAC address.
36 *
37 * @return the destination MAC address
38 */
39 public MACAddress getDstMac() {
40 return dstMac;
41 }
42
Toshio Koidebf8f8652014-08-19 16:34:24 -070043 @Override
44 public int hashCode() {
45 return Objects.hashCode(dstMac);
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 ModifyDstMacAction that = (ModifyDstMacAction) obj;
57 return Objects.equal(this.dstMac, that.dstMac);
58 }
Toshio Koide80db1842014-08-11 17:08:32 -070059}