blob: e679e29de12f724ca2ff62008cc0e79cc9882bab [file] [log] [blame]
Toshio Koidebf8f8652014-08-19 16:34:24 -07001package net.onrc.onos.core.matchaction.action;
2
3import static com.google.common.base.Preconditions.checkNotNull;
4import net.floodlightcontroller.util.MACAddress;
5
6import 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 */
14public class ModifySrcMacAction implements Action {
15 private final MACAddress srcMac;
16
17 /**
Toshio Koide2c67a2d2014-08-27 11:30:56 -070018 * Default constructor for Kryo deserialization.
19 */
20 @Deprecated
21 protected ModifySrcMacAction() {
22 srcMac = null;
23 }
24
25 /**
Toshio Koidebf8f8652014-08-19 16:34:24 -070026 * 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}