com.datastax.insight.core.action.Action Maven / Gradle / Ivy
package com.datastax.insight.core.action;
import com.datastax.insight.core.conf.Component;
import com.datastax.insight.core.conf.Components;
import com.datastax.insight.core.dag.DAG;
import com.datastax.insight.core.dag.Parameter;
import com.google.common.base.Strings;
import java.util.*;
public class Action extends Component {
private final static String DELIMITER=";";
private int level;
private List nextActions=new ArrayList<>();
private List preActions=new ArrayList<>();
private Map preActionOrder = new HashMap<>();
private Object[] paramValues;
private long[] paramOrders;
private Object result;
private long[] actions;
private DAG dag;
public List getNextActions() {
return nextActions;
}
public void setNextActions(List nextActions) {
this.nextActions = nextActions;
}
public List getPreActions() {
return preActions;
}
public void setPreActions(List preActions) {
this.preActions = preActions;
}
public Object getResult() {
return result;
}
public void setResult(Object result) {
this.result = result;
}
public long[] getActions() {
return actions;
}
public void setActions(long[] actions) {
this.actions = actions;
}
public boolean containsNextAction(Action action) {
return this.nextActions.stream().filter(a->a.getId() == action.getId()).findAny().isPresent();
}
public boolean containsPreAction(Action action) {
return this.preActions.stream().filter(a->a.getId() == action.getId()).findAny().isPresent();
}
public void sortPreActions(){
if(preActions.size()<=1) return;
Collections.sort(preActions, (o1, o2) -> (int)(o1.getLevel()-o2.getLevel()));
}
public Object[] getParamValues() {
if(paramValues!=null) {
return paramValues;
}else {
if(getParameters()!=null && getParameters().length>0){
Object[] values=new Object[getParameters().length];
for(int i=0;i