blob: 792b76ed3f148bb809200ae774740a0919335b1a [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 /**
18 * Constructor.
19 *
20 * @param dstPort The port number of the target output port.
21 */
22 public OutputAction(PortNumber dstPort) {
Toshio Koidebf8f8652014-08-19 16:34:24 -070023 this.portNumber = checkNotNull(dstPort);
Toshio Koidea03915e2014-07-01 18:39:52 -070024 }
25
26 /**
27 * Gets the port number of the target output port.
28 *
29 * @return The port number of the target output port.
30 */
31 public PortNumber getPortNumber() {
32 return portNumber;
33 }
Toshio Koidebf8f8652014-08-19 16:34:24 -070034
35 @Override
36 public int hashCode() {
37 return Objects.hashCode(portNumber);
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 OutputAction that = (OutputAction) obj;
49 return Objects.equal(this.portNumber, that.portNumber);
50 }
51
Toshio Koidea03915e2014-07-01 18:39:52 -070052}