blob: d7d5d73bcf09f2f39d5c5623914910a452b2a8a2 [file] [log] [blame]
Toshio Koidea03915e2014-07-01 18:39:52 -07001package net.onrc.onos.core.matchaction;
2
Toshio Koidea03915e2014-07-01 18:39:52 -07003import java.util.List;
4
Toshio Koidefad1cd52014-08-07 17:10:07 -07005import net.onrc.onos.api.batchoperation.BatchOperationTarget;
Toshio Koided8b077a2014-08-13 10:47:21 -07006import net.onrc.onos.core.matchaction.action.Action;
Toshio Koided8b077a2014-08-13 10:47:21 -07007import net.onrc.onos.core.matchaction.match.Match;
Toshio Koidea03915e2014-07-01 18:39:52 -07008import net.onrc.onos.core.util.SwitchPort;
9
10/**
Ray Milkeyc127a5a2014-08-20 11:22:12 -070011 * A filter and actions for traffic. Objects of this class are immutable.
Toshio Koidea03915e2014-07-01 18:39:52 -070012 */
Brian O'Connordee2e6b2014-08-12 11:34:51 -070013public final class MatchAction implements BatchOperationTarget {
Toshio Koide80db1842014-08-11 17:08:32 -070014 private final MatchActionId id;
15 private final SwitchPort port;
16 private final Match match;
17 private final List<Action> actions;
Toshio Koidea03915e2014-07-01 18:39:52 -070018
19 /**
20 * Constructor.
21 *
Toshio Koide80db1842014-08-11 17:08:32 -070022 * @param id ID for this MatchAction object
Brian O'Connordee2e6b2014-08-12 11:34:51 -070023 * @param port switch port to apply changes to
Toshio Koide80db1842014-08-11 17:08:32 -070024 * @param match the Match object as match condition on the port
25 * @param actions the list of Action objects as actions on the switch
Toshio Koidea03915e2014-07-01 18:39:52 -070026 */
Ray Milkey9ed4b962014-08-20 15:43:40 -070027 public MatchAction(MatchActionId id, SwitchPort port, Match match, List<Action> actions) {
28 this.id = id;
29 this.port = port;
30 this.match = match;
31 this.actions = actions;
32 }
33
34 /**
Brian O'Connor0efc9062014-09-02 14:47:28 -070035 * no-arg constructor for Kryo.
36 */
37 protected MatchAction() {
38 id = null;
39 port = null;
40 match = null;
41 actions = null;
42 }
43
44 /**
Toshio Koide80db1842014-08-11 17:08:32 -070045 * Gets ID for this object.
Toshio Koidea03915e2014-07-01 18:39:52 -070046 *
Toshio Koide80db1842014-08-11 17:08:32 -070047 * @return the ID for this object
Toshio Koidea03915e2014-07-01 18:39:52 -070048 */
Toshio Koide025a9152014-07-21 11:00:34 -070049 public MatchActionId getId() {
Toshio Koidea03915e2014-07-01 18:39:52 -070050 return id;
51 }
52
53 /**
54 * Gets the switch-port which is the target of this match-action.
55 *
Toshio Koide80db1842014-08-11 17:08:32 -070056 * @return the target switch-port of this match-action
Toshio Koidea03915e2014-07-01 18:39:52 -070057 */
58 public SwitchPort getSwitchPort() {
59 return port;
60 }
61
62 /**
63 * Gets the traffic filter of the match-action.
64 *
Toshio Koide80db1842014-08-11 17:08:32 -070065 * @return the traffic filter
Toshio Koidea03915e2014-07-01 18:39:52 -070066 */
Toshio Koide80db1842014-08-11 17:08:32 -070067 public Match getMatch() {
68 return match;
Toshio Koidea03915e2014-07-01 18:39:52 -070069 }
70
71 /**
72 * Gets the list of actions of the match-action.
73 *
Toshio Koide80db1842014-08-11 17:08:32 -070074 * @return the list of actions
Toshio Koidea03915e2014-07-01 18:39:52 -070075 */
Toshio Koided8b077a2014-08-13 10:47:21 -070076 public List<Action> getActions() {
Toshio Koidea03915e2014-07-01 18:39:52 -070077 return actions;
78 }
Ray Milkeyc127a5a2014-08-20 11:22:12 -070079
80 @Override
81 public int hashCode() {
82 return id.hashCode();
83 }
84
85 @Override
86 public boolean equals(Object obj) {
87 if (obj instanceof MatchAction) {
88 MatchAction other = (MatchAction) obj;
89 return (id.equals(other.id));
90 }
91 return false;
92 }
Toshio Koidea03915e2014-07-01 18:39:52 -070093}