Toshio Koide | a03915e | 2014-07-01 18:39:52 -0700 | [diff] [blame] | 1 | package net.onrc.onos.core.matchaction.action; |
| 2 | |
Toshio Koide | bf8f865 | 2014-08-19 16:34:24 -0700 | [diff] [blame] | 3 | import static com.google.common.base.Preconditions.checkNotNull; |
Toshio Koide | a03915e | 2014-07-01 18:39:52 -0700 | [diff] [blame] | 4 | import net.onrc.onos.core.util.PortNumber; |
| 5 | |
Toshio Koide | bf8f865 | 2014-08-19 16:34:24 -0700 | [diff] [blame] | 6 | import com.google.common.base.Objects; |
| 7 | |
Toshio Koide | a03915e | 2014-07-01 18:39:52 -0700 | [diff] [blame] | 8 | /** |
| 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 Koide | 7894ca0 | 2014-08-15 14:30:13 -0700 | [diff] [blame] | 12 | * MatchAction, Flow or Intent class. |
Toshio Koide | a03915e | 2014-07-01 18:39:52 -0700 | [diff] [blame] | 13 | */ |
Toshio Koide | d8b077a | 2014-08-13 10:47:21 -0700 | [diff] [blame] | 14 | public class OutputAction implements Action { |
Toshio Koide | bf8f865 | 2014-08-19 16:34:24 -0700 | [diff] [blame] | 15 | private final PortNumber portNumber; |
Toshio Koide | a03915e | 2014-07-01 18:39:52 -0700 | [diff] [blame] | 16 | |
| 17 | /** |
| 18 | * Constructor. |
| 19 | * |
| 20 | * @param dstPort The port number of the target output port. |
| 21 | */ |
| 22 | public OutputAction(PortNumber dstPort) { |
Toshio Koide | bf8f865 | 2014-08-19 16:34:24 -0700 | [diff] [blame] | 23 | this.portNumber = checkNotNull(dstPort); |
Toshio Koide | a03915e | 2014-07-01 18:39:52 -0700 | [diff] [blame] | 24 | } |
| 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 Koide | bf8f865 | 2014-08-19 16:34:24 -0700 | [diff] [blame] | 34 | |
| 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 | |
Sho SHIMIZU | 645be14 | 2014-08-21 20:26:18 -0700 | [diff] [blame] | 52 | @Override |
| 53 | public String toString() { |
| 54 | return Objects.toStringHelper(getClass()) |
| 55 | .add("portNumber", portNumber) |
| 56 | .toString(); |
| 57 | } |
Toshio Koide | a03915e | 2014-07-01 18:39:52 -0700 | [diff] [blame] | 58 | } |