blob: d7d5d73bcf09f2f39d5c5623914910a452b2a8a2 [file] [log] [blame]
package net.onrc.onos.core.matchaction;
import java.util.List;
import net.onrc.onos.api.batchoperation.BatchOperationTarget;
import net.onrc.onos.core.matchaction.action.Action;
import net.onrc.onos.core.matchaction.match.Match;
import net.onrc.onos.core.util.SwitchPort;
/**
* A filter and actions for traffic. Objects of this class are immutable.
*/
public final class MatchAction implements BatchOperationTarget {
private final MatchActionId id;
private final SwitchPort port;
private final Match match;
private final List<Action> actions;
/**
* Constructor.
*
* @param id ID for this MatchAction object
* @param port switch port to apply changes to
* @param match the Match object as match condition on the port
* @param actions the list of Action objects as actions on the switch
*/
public MatchAction(MatchActionId id, SwitchPort port, Match match, List<Action> actions) {
this.id = id;
this.port = port;
this.match = match;
this.actions = actions;
}
/**
* no-arg constructor for Kryo.
*/
protected MatchAction() {
id = null;
port = null;
match = null;
actions = null;
}
/**
* Gets ID for this object.
*
* @return the ID for this object
*/
public MatchActionId getId() {
return id;
}
/**
* Gets the switch-port which is the target of this match-action.
*
* @return the target switch-port of this match-action
*/
public SwitchPort getSwitchPort() {
return port;
}
/**
* Gets the traffic filter of the match-action.
*
* @return the traffic filter
*/
public Match getMatch() {
return match;
}
/**
* Gets the list of actions of the match-action.
*
* @return the list of actions
*/
public List<Action> getActions() {
return actions;
}
@Override
public int hashCode() {
return id.hashCode();
}
@Override
public boolean equals(Object obj) {
if (obj instanceof MatchAction) {
MatchAction other = (MatchAction) obj;
return (id.equals(other.id));
}
return false;
}
}