blob: 10b5aaff3f08bbbc2a8cbca13af539cc87f51cfe [file] [log] [blame]
Toshio Koidea03915e2014-07-01 18:39:52 -07001package net.onrc.onos.core.matchaction.action;
2
Toshio Koidebf8f8652014-08-19 16:34:24 -07003import static com.google.common.base.Preconditions.checkNotNull;
Toshio Koidea03915e2014-07-01 18:39:52 -07004import net.onrc.onos.core.util.PortNumber;
5
Toshio Koidebf8f8652014-08-19 16:34:24 -07006import com.google.common.base.Objects;
7
Toshio Koidea03915e2014-07-01 18:39:52 -07008/**
9 * An action object to output traffic to specified port.
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 Koidea03915e2014-07-01 18:39:52 -070013 */
Toshio Koided8b077a2014-08-13 10:47:21 -070014public class OutputAction implements Action {
Toshio Koidebf8f8652014-08-19 16:34:24 -070015 private final PortNumber portNumber;
Toshio Koidea03915e2014-07-01 18:39:52 -070016
17 /**
Toshio Koide2c67a2d2014-08-27 11:30:56 -070018 * Default constructor for Kryo deserialization.
19 */
20 @Deprecated
21 protected OutputAction() {
22 portNumber = null;
23 }
24
25 /**
Toshio Koidea03915e2014-07-01 18:39:52 -070026 * Constructor.
27 *
28 * @param dstPort The port number of the target output port.
29 */
30 public OutputAction(PortNumber dstPort) {
Toshio Koidebf8f8652014-08-19 16:34:24 -070031 this.portNumber = checkNotNull(dstPort);
Toshio Koidea03915e2014-07-01 18:39:52 -070032 }
33
34 /**
35 * Gets the port number of the target output port.
36 *
37 * @return The port number of the target output port.
38 */
39 public PortNumber getPortNumber() {
40 return portNumber;
41 }
Toshio Koidebf8f8652014-08-19 16:34:24 -070042
43 @Override
44 public int hashCode() {
45 return Objects.hashCode(portNumber);
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 OutputAction that = (OutputAction) obj;
57 return Objects.equal(this.portNumber, that.portNumber);
58 }
59
Sho SHIMIZU645be142014-08-21 20:26:18 -070060 @Override
61 public String toString() {
62 return Objects.toStringHelper(getClass())
63 .add("portNumber", portNumber)
64 .toString();
65 }
Toshio Koidea03915e2014-07-01 18:39:52 -070066}