blob: 21ecf32bef18e0639da7ca29eec7193447e55c13 [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 /**
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}