Example usage for org.apache.commons.collections4 PredicateUtils allPredicate

List of usage examples for org.apache.commons.collections4 PredicateUtils allPredicate

Introduction

In this page you can find the example usage for org.apache.commons.collections4 PredicateUtils allPredicate.

Prototype

public static <T> Predicate<T> allPredicate(final Collection<? extends Predicate<T>> predicates) 

Source Link

Document

Create a new Predicate that returns true only if all of the specified predicates are true.

Usage

From source file:br.usp.poli.lta.cereda.aa.model.actions.ElementaryActions.java

/**
 * Consulta as transies de acordo com os parmetros informados e preenche
 * as variveis./*  w w  w.  j av  a 2s .co m*/
 * @param priorAction Ao anterior.
 * @param source Estado de origem.
 * @param submachine Submquina a ser chamada.
 * @param target Estado de destino.
 */
public void query(ActionQuery priorAction, Variable source, SubmachineQuery submachine, Variable target) {

    // validaes
    Validate.notNull(priorAction, "A varivel no pode ser nula.");
    Validate.notNull(source, "A varivel no pode ser nula.");
    Validate.notNull(submachine, "A varivel no pode ser nula.");
    Validate.notNull(target, "A varivel no pode ser nula.");

    // predicado da ao anterior
    Predicate priorActionPredicate;

    // tratamento do nome da ao anterior
    Predicate priorActionNamePredicate;
    if (!priorAction.getName().isAvailable()) {
        Collection priorActionNamePredicateList = new ArrayList();
        for (Object currentPriorActionName : priorAction.getName().getValues()) {
            priorActionNamePredicateList.add(new PriorActionPredicate((String) currentPriorActionName));
        }
        priorActionNamePredicate = PredicateUtils.anyPredicate(priorActionNamePredicateList);
    } else {
        priorActionNamePredicate = new PriorActionCallPredicate();
    }

    // tratamento dos argumentos da ao anterior
    if (priorAction.hasArguments()) {
        List<Variable> priorActionArguments = priorAction.getArguments();
        Collection priorActionArgumentsPredicateList = new ArrayList();
        Collection priorActionArgumentPredicateList;
        for (int i = 0; i < priorActionArguments.size(); i++) {
            if (!priorActionArguments.get(i).isAvailable()) {
                priorActionArgumentPredicateList = new ArrayList();
                for (Object currentPriorActionArgument : priorActionArguments.get(i).getValues()) {
                    priorActionArgumentPredicateList
                            .add(new PriorActionCheckArgumentPredicate(i, currentPriorActionArgument));
                }
                priorActionArgumentsPredicateList
                        .add(PredicateUtils.anyPredicate(priorActionArgumentPredicateList));
            } else {
                priorActionArgumentsPredicateList.add(TruePredicate.truePredicate());
            }
        }
        priorActionArgumentsPredicateList
                .add(new PriorActionCountArgumentsPredicate(priorActionArguments.size()));
        priorActionArgumentsPredicateList.add(priorActionNamePredicate);
        priorActionPredicate = PredicateUtils.allPredicate(priorActionArgumentsPredicateList);
    } else {
        priorActionPredicate = priorActionNamePredicate;
    }

    // predicado do estado de origem
    Predicate sourcePredicate;
    if (!source.isAvailable()) {
        Collection sourcePredicateList = new ArrayList();
        for (Object currentSource : source.getValues()) {
            sourcePredicateList.add(new SourceStatePredicate((State) currentSource));
        }
        sourcePredicate = PredicateUtils.anyPredicate(sourcePredicateList);
    } else {
        sourcePredicate = TruePredicate.truePredicate();
    }

    // predicado da chamada de submquina
    Predicate submachinePredicate;
    if (!submachine.getVariable().isAvailable()) {
        Collection submachinePredicateList = new ArrayList();
        for (Object currentSubmachine : submachine.getVariable().getValues()) {
            submachinePredicateList.add(new SubmachinePredicate((String) currentSubmachine));
        }
        submachinePredicate = PredicateUtils.anyPredicate(submachinePredicateList);
    } else {
        submachinePredicate = new SubmachineCallPredicate();
    }

    // predicado do estado de destino
    Predicate targetPredicate;
    if (!target.isAvailable()) {
        Collection targetPredicateList = new ArrayList();
        for (Object currentTarget : target.getValues()) {
            targetPredicateList.add(new TargetStatePredicate((State) currentTarget));
        }
        targetPredicate = PredicateUtils.anyPredicate(targetPredicateList);
    } else {
        targetPredicate = TruePredicate.truePredicate();
    }

    // a consulta  a interseco dos predicados
    Collection<Transition> query = CollectionUtils.select(transitions.getTransitions(),
            PredicateUtils.allPredicate(new Predicate[] { sourcePredicate, submachinePredicate, targetPredicate,
                    priorActionPredicate }));

    // conjuntos de resultados
    Set<Object> sourceResult = new HashSet<>();
    Set<Object> submachineResult = new HashSet<>();
    Set<Object> targetResult = new HashSet<>();
    Set<Object> priorActionNameResult = new HashSet<>();
    List<HashSet<Object>> priorActionArgumentsResult = new ArrayList<>();

    // existem argumentos da ao anterior,
    // inicializa cada conjunto
    if (priorAction.hasArguments()) {
        for (Variable argument : priorAction.getArguments()) {
            priorActionArgumentsResult.add(new HashSet<>());
        }
    }

    // preenche os conjuntos de resultados
    for (Transition transition : query) {
        sourceResult.add(transition.getSourceState());
        submachineResult.add(transition.getSubmachineCall());
        targetResult.add(transition.getTargetState());
        priorActionNameResult.add(transition.getPriorActionCall());
        if (priorAction.hasArguments()) {
            for (int i = 0; i < priorAction.getArguments().size(); i++) {
                priorActionArgumentsResult.get(i).add(transition.getPriorActionArguments()[i]);
            }
        }
    }

    // preenche o estado de origem
    if (source.isAvailable()) {
        source.setValues(sourceResult);
    }

    // preenche a chamada de submquina
    if (submachine.getVariable().isAvailable()) {
        submachine.getVariable().setValues(submachineResult);
    }

    // preenche o estado de destino
    if (target.isAvailable()) {
        target.setValues(targetResult);
    }

    // preenche o nome da ao anterior
    if (priorAction.getName().isAvailable()) {
        priorAction.getName().setValues(priorActionNameResult);
    }

    // preenche os argumentos da ao anterior
    if (priorAction.hasArguments()) {
        for (int i = 0; i < priorAction.getArguments().size(); i++) {
            if (priorAction.getArguments().get(i).isAvailable()) {
                priorAction.getArguments().get(i).setValues(priorActionArgumentsResult.get(i));
            }
        }
    }

}

From source file:br.usp.poli.lta.cereda.aa.model.actions.ElementaryActions.java

/**
 * Consulta as transies de acordo com os parmetros informados e preenche
 * as variveis./*from w ww  . jav  a 2s . com*/
 * @param priorAction Ao anterior.
 * @param source Estado de origem.
 * @param submachine Submquina a ser chamada.
 * @param target Estado de destino.
 * @param postAction Ao posterior.
 */
public void query(ActionQuery priorAction, Variable source, SubmachineQuery submachine, Variable target,
        ActionQuery postAction) {

    // validaes
    Validate.notNull(source, "A varivel no pode ser nula.");
    Validate.notNull(submachine, "A varivel no pode ser nula.");
    Validate.notNull(target, "A varivel no pode ser nula.");
    Validate.notNull(priorAction, "A varivel no pode ser nula.");
    Validate.notNull(postAction, "A varivel no pode ser nula.");

    // predicado da ao anterior
    Predicate priorActionPredicate;

    // tratamento do nome da ao anterior
    Predicate priorActionNamePredicate;
    if (!priorAction.getName().isAvailable()) {
        Collection priorActionNamePredicateList = new ArrayList();
        for (Object currentPriorActionName : priorAction.getName().getValues()) {
            priorActionNamePredicateList.add(new PriorActionPredicate((String) currentPriorActionName));
        }
        priorActionNamePredicate = PredicateUtils.anyPredicate(priorActionNamePredicateList);
    } else {
        priorActionNamePredicate = new PriorActionCallPredicate();
    }

    // tratamento dos argumentos da
    // ao anterior, se existirem
    if (priorAction.hasArguments()) {
        List<Variable> priorActionArguments = priorAction.getArguments();
        Collection priorActionArgumentsPredicateList = new ArrayList();
        Collection priorActionArgumentPredicateList;
        for (int i = 0; i < priorActionArguments.size(); i++) {
            if (!priorActionArguments.get(i).isAvailable()) {
                priorActionArgumentPredicateList = new ArrayList();
                for (Object currentPriorActionArgument : priorActionArguments.get(i).getValues()) {
                    priorActionArgumentPredicateList
                            .add(new PriorActionCheckArgumentPredicate(i, currentPriorActionArgument));
                }
                priorActionArgumentsPredicateList
                        .add(PredicateUtils.anyPredicate(priorActionArgumentPredicateList));
            } else {
                priorActionArgumentsPredicateList.add(TruePredicate.truePredicate());
            }
        }
        priorActionArgumentsPredicateList
                .add(new PriorActionCountArgumentsPredicate(priorActionArguments.size()));
        priorActionArgumentsPredicateList.add(priorActionNamePredicate);
        priorActionPredicate = PredicateUtils.allPredicate(priorActionArgumentsPredicateList);
    } else {
        priorActionPredicate = priorActionNamePredicate;
    }

    // predicado da ao posterior
    Predicate postActionPredicate;

    // tratamento do nome da ao posterior
    Predicate postActionNamePredicate;
    if (!postAction.getName().isAvailable()) {
        Collection postActionNamePredicateList = new ArrayList();
        for (Object currentPostActionName : postAction.getName().getValues()) {
            postActionNamePredicateList.add(new PostActionPredicate((String) currentPostActionName));
        }
        postActionNamePredicate = PredicateUtils.anyPredicate(postActionNamePredicateList);
    } else {
        postActionNamePredicate = new PostActionCallPredicate();
    }

    // tratamento dos argumentos da
    // ao posterior, se existirem
    if (postAction.hasArguments()) {
        List<Variable> postActionArguments = postAction.getArguments();
        Collection postActionArgumentsPredicateList = new ArrayList();
        Collection postActionArgumentPredicateList;
        for (int i = 0; i < postActionArguments.size(); i++) {
            if (!postActionArguments.get(i).isAvailable()) {
                postActionArgumentPredicateList = new ArrayList();
                for (Object currentPostActionArgument : postActionArguments.get(i).getValues()) {
                    postActionArgumentPredicateList
                            .add(new PostActionCheckArgumentPredicate(i, currentPostActionArgument));
                }
                postActionArgumentsPredicateList
                        .add(PredicateUtils.anyPredicate(postActionArgumentPredicateList));
            } else {
                postActionArgumentsPredicateList.add(TruePredicate.truePredicate());
            }
        }
        postActionArgumentsPredicateList.add(new PostActionCountArgumentsPredicate(postActionArguments.size()));
        postActionArgumentsPredicateList.add(postActionNamePredicate);
        postActionPredicate = PredicateUtils.allPredicate(postActionArgumentsPredicateList);
    } else {
        postActionPredicate = postActionNamePredicate;
    }

    // predicado do estado de origem
    Predicate sourcePredicate;
    if (!source.isAvailable()) {
        Collection sourcePredicateList = new ArrayList();
        for (Object currentSource : source.getValues()) {
            sourcePredicateList.add(new SourceStatePredicate((State) currentSource));
        }
        sourcePredicate = PredicateUtils.anyPredicate(sourcePredicateList);
    } else {
        sourcePredicate = TruePredicate.truePredicate();
    }

    // predicado da chamada de submquina
    Predicate submachinePredicate;
    if (!submachine.getVariable().isAvailable()) {
        Collection submachinePredicateList = new ArrayList();
        for (Object currentSubmachine : submachine.getVariable().getValues()) {
            submachinePredicateList.add(new SubmachinePredicate((String) currentSubmachine));
        }
        submachinePredicate = PredicateUtils.anyPredicate(submachinePredicateList);
    } else {
        submachinePredicate = new SubmachineCallPredicate();
    }

    // predicado do estado de destino
    Predicate targetPredicate;
    if (!target.isAvailable()) {
        Collection targetPredicateList = new ArrayList();
        for (Object currentTarget : target.getValues()) {
            targetPredicateList.add(new TargetStatePredicate((State) currentTarget));
        }
        targetPredicate = PredicateUtils.anyPredicate(targetPredicateList);
    } else {
        targetPredicate = TruePredicate.truePredicate();
    }

    // a consulta  a interseco dos predicados
    Collection<Transition> query = CollectionUtils.select(transitions.getTransitions(),
            PredicateUtils.allPredicate(new Predicate[] { sourcePredicate, submachinePredicate, targetPredicate,
                    priorActionPredicate, postActionPredicate }));

    // conjuntos de resultados
    Set<Object> sourceResult = new HashSet<>();
    Set<Object> submachineResult = new HashSet<>();
    Set<Object> targetResult = new HashSet<>();
    Set<Object> priorActionNameResult = new HashSet<>();
    List<HashSet<Object>> priorActionArgumentsResult = new ArrayList<>();
    Set<Object> postActionNameResult = new HashSet<>();
    List<HashSet<Object>> postActionArgumentsResult = new ArrayList<>();

    // inicializa conjunto dos argumentos
    // da ao anterior
    if (priorAction.hasArguments()) {
        for (Variable argument : priorAction.getArguments()) {
            priorActionArgumentsResult.add(new HashSet<>());
        }
    }

    // inicializa conjunto dos argumentos
    // da ao posterior
    if (postAction.hasArguments()) {
        for (Variable argument : postAction.getArguments()) {
            postActionArgumentsResult.add(new HashSet<>());
        }
    }

    // preenche os conjuntos de resultados
    for (Transition transition : query) {
        sourceResult.add(transition.getSourceState());
        submachineResult.add(transition.getSubmachineCall());
        targetResult.add(transition.getTargetState());
        priorActionNameResult.add(transition.getPriorActionCall());
        if (priorAction.hasArguments()) {
            for (int i = 0; i < priorAction.getArguments().size(); i++) {
                priorActionArgumentsResult.get(i).add(transition.getPriorActionArguments()[i]);
            }
        }
        postActionNameResult.add(transition.getPostActionCall());
        if (postAction.hasArguments()) {
            for (int i = 0; i < postAction.getArguments().size(); i++) {
                postActionArgumentsResult.get(i).add(transition.getPostActionArguments()[i]);
            }
        }
    }

    // insere os valores do estado de origem
    if (source.isAvailable()) {
        source.setValues(sourceResult);
    }

    // insere os valores das chamadas de submquinas
    if (submachine.getVariable().isAvailable()) {
        submachine.getVariable().setValues(submachineResult);
    }

    // insere os valores do estado de destino
    if (target.isAvailable()) {
        target.setValues(targetResult);
    }

    // insere os valores do nome da ao anterior
    if (priorAction.getName().isAvailable()) {
        priorAction.getName().setValues(priorActionNameResult);
    }

    // insere os valores dos argumentos da
    // ao anterior, se existirem
    if (priorAction.hasArguments()) {
        for (int i = 0; i < priorAction.getArguments().size(); i++) {
            if (priorAction.getArguments().get(i).isAvailable()) {
                priorAction.getArguments().get(i).setValues(priorActionArgumentsResult.get(i));
            }
        }
    }

    // insere os valores do nome da ao posterior
    if (postAction.getName().isAvailable()) {
        postAction.getName().setValues(postActionNameResult);
    }

    // insere os valores dos argumentos da
    // ao posterior, se existirem
    if (postAction.hasArguments()) {
        for (int i = 0; i < postAction.getArguments().size(); i++) {
            if (postAction.getArguments().get(i).isAvailable()) {
                postAction.getArguments().get(i).setValues(postActionArgumentsResult.get(i));
            }
        }
    }

}

From source file:br.usp.poli.lta.cereda.aa.model.actions.ElementaryActions.java

/**
 * Remove transies de acordo com o padro informado.
 * @param source Estado de origem./*from   w  ww . j  av a  2s . c om*/
 * @param symbol Smbolo a ser consumido.
 * @param target Estado de destino.
 */
public void remove(Variable source, Variable symbol, Variable target) {

    // validaes
    Validate.notNull(source, "A varivel no pode ser nula.");
    Validate.notNull(symbol, "A varivel no pode ser nula.");
    Validate.notNull(target, "A varivel no pode ser nula.");

    // validao de contedo
    Validate.isTrue(!source.isAvailable(), "A varivel deve estar inicializada.");

    // retorna se o conjunto estiver vazio
    if (source.getValues().isEmpty()) {
        return;
    }

    // predicado do estado de origem
    Collection sourcePredicateList = new ArrayList();
    for (Object currentSource : source.getValues()) {
        sourcePredicateList.add(new SourceStatePredicate((State) currentSource));
    }
    Predicate sourcePredicate = PredicateUtils.anyPredicate(sourcePredicateList);

    // validao de contedo
    Validate.isTrue(!symbol.isAvailable(), "A varivel deve estar inicializada.");

    // retorna se o conjunto for vazio
    if (symbol.getValues().isEmpty()) {
        return;
    }

    // predicado do smbolo
    Collection symbolPredicateList = new ArrayList();
    for (Object currentSymbol : symbol.getValues()) {
        if (currentSymbol != null) {
            symbolPredicateList.add(new SymbolPredicate((Symbol) currentSymbol));
        } else {
            symbolPredicateList.add(new EpsilonPredicate());
        }
    }
    Predicate symbolPredicate = PredicateUtils.anyPredicate(symbolPredicateList);

    // validao de contedo
    Validate.isTrue(!target.isAvailable(), "A varivel deve estar inicializada.");

    // retorna se o conjunto for vazio
    if (target.getValues().isEmpty()) {
        return;
    }

    // predicado do estado de destino
    Collection targetPredicateList = new ArrayList();
    for (Object currentTarget : target.getValues()) {
        targetPredicateList.add(new TargetStatePredicate((State) currentTarget));
    }
    Predicate targetPredicate = PredicateUtils.anyPredicate(targetPredicateList);

    // a consulta  a interseco dos predicados
    Collection<Transition> query = CollectionUtils.select(transitions.getTransitions(),
            PredicateUtils.allPredicate(new Predicate[] { sourcePredicate, symbolPredicate, targetPredicate }));

    // lista de identificadores para remoo
    ArrayList<Integer> removals = new ArrayList<>();

    // percorre o resultado da consulta
    // e adiciona os identificadores na
    // lista de remoo
    for (Transition transition : query) {
        removals.add(transition.getIdentifier());
    }

    // remove as transies de acordo
    // com seus identificadores
    for (int id : removals) {
        transitions.removeFromIdentifier(id);
    }
}

From source file:br.usp.poli.lta.cereda.aa.model.actions.ElementaryActions.java

/**
 * Remove transies de acordo com o padro informado.
 * @param priorAction Ao anterior./*  w  w  w.ja va2 s  . co m*/
 * @param source Estado de origem.
 * @param symbol Smbolo a ser consumido.
 * @param target Estado de destino.
 */
public void remove(ActionQuery priorAction, Variable source, Variable symbol, Variable target) {

    // validaes
    Validate.notNull(source, "A varivel no pode ser nula.");
    Validate.notNull(symbol, "A varivel no pode ser nula.");
    Validate.notNull(target, "A varivel no pode ser nula.");
    Validate.notNull(priorAction, "A varivel no pode ser nula.");

    // validao de contedo
    Validate.isTrue(!priorAction.getName().isAvailable(), "A varivel deve estar inicializada.");

    // validao de contedo
    if (priorAction.hasArguments()) {
        for (Variable test : priorAction.getArguments()) {
            Validate.isTrue(!test.isAvailable(), "A varivel deve estar inicializada.");
        }
    }

    // retorna se o conjunto for vazio
    if (priorAction.getName().getValues().isEmpty()) {
        return;
    }

    // retorna se o conjunto for vazio
    if (priorAction.hasArguments()) {
        for (Variable test : priorAction.getArguments()) {
            if (test.getValues().isEmpty()) {
                return;
            }
        }
    }

    // predicado da ao anterior
    Predicate priorActionPredicate;
    Predicate priorActionNamePredicate;
    Collection priorActionNamePredicateList = new ArrayList();
    for (Object currentPriorActionName : priorAction.getName().getValues()) {
        priorActionNamePredicateList.add(new PriorActionPredicate((String) currentPriorActionName));
    }
    priorActionNamePredicate = PredicateUtils.anyPredicate(priorActionNamePredicateList);
    if (priorAction.hasArguments()) {
        List<Variable> priorActionArguments = priorAction.getArguments();
        Collection priorActionArgumentsPredicateList = new ArrayList();
        Collection priorActionArgumentPredicateList;
        for (int i = 0; i < priorActionArguments.size(); i++) {
            priorActionArgumentPredicateList = new ArrayList();
            for (Object currentPriorActionArgument : priorActionArguments.get(i).getValues()) {
                priorActionArgumentPredicateList
                        .add(new PriorActionCheckArgumentPredicate(i, currentPriorActionArgument));
            }
            priorActionArgumentsPredicateList
                    .add(PredicateUtils.anyPredicate(priorActionArgumentPredicateList));
        }
        priorActionArgumentsPredicateList
                .add(new PriorActionCountArgumentsPredicate(priorActionArguments.size()));
        priorActionArgumentsPredicateList.add(priorActionNamePredicate);
        priorActionPredicate = PredicateUtils.allPredicate(priorActionArgumentsPredicateList);
    } else {
        priorActionPredicate = priorActionNamePredicate;
    }

    // validao de contedo
    Validate.isTrue(!source.isAvailable(), "A varivel deve estar inicializada.");

    // retorna se o conjunto for vazio
    if (source.getValues().isEmpty()) {
        return;
    }

    // predicado do estado de origem
    Collection sourcePredicateList = new ArrayList();
    for (Object currentSource : source.getValues()) {
        sourcePredicateList.add(new SourceStatePredicate((State) currentSource));
    }
    Predicate sourcePredicate = PredicateUtils.anyPredicate(sourcePredicateList);

    // validao de contedo
    Validate.isTrue(!symbol.isAvailable(), "A varivel deve estar inicializada.");

    // retorna se o conjunto for vazio
    if (symbol.getValues().isEmpty()) {
        return;
    }

    // predicado do smbolo
    Collection symbolPredicateList = new ArrayList();
    for (Object currentSymbol : symbol.getValues()) {
        if (currentSymbol != null) {
            symbolPredicateList.add(new SymbolPredicate((Symbol) currentSymbol));
        } else {
            symbolPredicateList.add(new EpsilonPredicate());
        }
    }
    Predicate symbolPredicate = PredicateUtils.anyPredicate(symbolPredicateList);

    // validao de contedo
    Validate.isTrue(!target.isAvailable(), "A varivel deve estar inicializada.");

    // retorna se o conjunto for vazio
    if (target.getValues().isEmpty()) {
        return;
    }

    // predicado do estado de destino
    Collection targetPredicateList = new ArrayList();
    for (Object currentTarget : target.getValues()) {
        targetPredicateList.add(new TargetStatePredicate((State) currentTarget));
    }
    Predicate targetPredicate = PredicateUtils.anyPredicate(targetPredicateList);

    // a consulta  a interseco dos predicados
    Collection<Transition> query = CollectionUtils.select(transitions.getTransitions(),
            PredicateUtils.allPredicate(new Predicate[] { sourcePredicate, symbolPredicate, targetPredicate,
                    priorActionPredicate }));

    // lista de identificadores
    // para remoo
    ArrayList<Integer> removals = new ArrayList<>();

    // percorre as transies da
    // consulta e adiciona os
    // identificadores
    for (Transition transition : query) {
        removals.add(transition.getIdentifier());
    }

    // remove as transies de acordo
    // com seus identificadores
    for (int id : removals) {
        transitions.removeFromIdentifier(id);
    }
}

From source file:br.usp.poli.lta.cereda.aa.model.actions.ElementaryActions.java

/**
 * Remove transies de acordo com o padro informado.
 * @param source Estado de origem./*  w  w  w.  ja  v  a  2s.c  om*/
 * @param symbol Smbolo a ser consumido.
 * @param target Estado de destino.
 * @param postAction Ao posterior.
 */
public void remove(Variable source, Variable symbol, Variable target, ActionQuery postAction) {

    // validaes
    Validate.notNull(source, "A varivel no pode ser nula.");
    Validate.notNull(symbol, "A varivel no pode ser nula.");
    Validate.notNull(target, "A varivel no pode ser nula.");
    Validate.notNull(postAction, "A varivel no pode ser nula.");

    // validao de contedo
    Validate.isTrue(!postAction.getName().isAvailable(), "A varivel deve estar inicializada.");

    // validao de contedo
    if (postAction.hasArguments()) {
        for (Variable test : postAction.getArguments()) {
            Validate.isTrue(!test.isAvailable(), "A varivel deve estar inicializada.");
        }
    }

    // retorna se conjunto for vazio
    if (postAction.getName().getValues().isEmpty()) {
        return;
    }

    // retorna se conjunto for vazio
    if (postAction.hasArguments()) {
        for (Variable test : postAction.getArguments()) {
            if (test.getValues().isEmpty()) {
                return;
            }
        }
    }

    // predicado da ao posterior
    Predicate postActionPredicate;
    Predicate postActionNamePredicate;
    Collection postActionNamePredicateList = new ArrayList();
    for (Object currentPostActionName : postAction.getName().getValues()) {
        postActionNamePredicateList.add(new PostActionPredicate((String) currentPostActionName));
    }
    postActionNamePredicate = PredicateUtils.anyPredicate(postActionNamePredicateList);
    if (postAction.hasArguments()) {
        List<Variable> postActionArguments = postAction.getArguments();
        Collection postActionArgumentsPredicateList = new ArrayList();
        Collection postActionArgumentPredicateList;
        for (int i = 0; i < postActionArguments.size(); i++) {
            postActionArgumentPredicateList = new ArrayList();
            for (Object currentPostActionArgument : postActionArguments.get(i).getValues()) {
                postActionArgumentPredicateList
                        .add(new PostActionCheckArgumentPredicate(i, currentPostActionArgument));
            }
            postActionArgumentsPredicateList.add(PredicateUtils.anyPredicate(postActionArgumentPredicateList));
        }
        postActionArgumentsPredicateList.add(new PostActionCountArgumentsPredicate(postActionArguments.size()));
        postActionArgumentsPredicateList.add(postActionNamePredicate);
        postActionPredicate = PredicateUtils.allPredicate(postActionArgumentsPredicateList);
    } else {
        postActionPredicate = postActionNamePredicate;
    }

    // validao de contedo
    Validate.isTrue(!source.isAvailable(), "A varivel deve estar inicializada.");

    // retorna se o conjunto for vazio
    if (source.getValues().isEmpty()) {
        return;
    }

    // predicado do estado de origem
    Collection sourcePredicateList = new ArrayList();
    for (Object currentSource : source.getValues()) {
        sourcePredicateList.add(new SourceStatePredicate((State) currentSource));
    }
    Predicate sourcePredicate = PredicateUtils.anyPredicate(sourcePredicateList);

    // validao do contedo
    Validate.isTrue(!symbol.isAvailable(), "A varivel deve estar inicializada.");

    // retorna se o conjunto estiver vazio
    if (symbol.getValues().isEmpty()) {
        return;
    }

    // predicado do smbolo
    Collection symbolPredicateList = new ArrayList();
    for (Object currentSymbol : symbol.getValues()) {
        if (currentSymbol != null) {
            symbolPredicateList.add(new SymbolPredicate((Symbol) currentSymbol));
        } else {
            symbolPredicateList.add(new EpsilonPredicate());
        }
    }
    Predicate symbolPredicate = PredicateUtils.anyPredicate(symbolPredicateList);

    // validao de contedo
    Validate.isTrue(!target.isAvailable(), "A varivel deve estar inicializada.");

    // retorna se o conjunto for vazio
    if (target.getValues().isEmpty()) {
        return;
    }

    // predicado do estado de destino
    Collection targetPredicateList = new ArrayList();
    for (Object currentTarget : target.getValues()) {
        targetPredicateList.add(new TargetStatePredicate((State) currentTarget));
    }
    Predicate targetPredicate = PredicateUtils.anyPredicate(targetPredicateList);

    // a consulta  a interseco dos predicados
    Collection<Transition> query = CollectionUtils.select(transitions.getTransitions(),
            PredicateUtils.allPredicate(new Predicate[] { sourcePredicate, symbolPredicate, targetPredicate,
                    postActionPredicate }));

    // lista de identificadores
    // para remoo
    List<Integer> removals = new ArrayList<>();

    // percorre o resultado da
    // consulta e adiciona os
    // identificadores na lista
    for (Transition transition : query) {
        removals.add(transition.getIdentifier());
    }

    // remove as transies de acordo
    // com seus identificadores
    for (int id : removals) {
        transitions.removeFromIdentifier(id);
    }
}

From source file:br.usp.poli.lta.cereda.aa.model.actions.ElementaryActions.java

/**
 * Remove transies de acordo com o padro informado.
 * @param priorAction Ao anterior./*from   w  ww. jav  a  2  s.c  o m*/
 * @param source Estado de origem.
 * @param symbol Smbolo a ser consumido.
 * @param target Estado de destino.
 * @param postAction Ao posterior.
 */
public void remove(ActionQuery priorAction, Variable source, Variable symbol, Variable target,
        ActionQuery postAction) {

    // validaes
    Validate.notNull(source, "A varivel no pode ser nula.");
    Validate.notNull(symbol, "A varivel no pode ser nula.");
    Validate.notNull(target, "A varivel no pode ser nula.");
    Validate.notNull(priorAction, "A varivel no pode ser nula.");
    Validate.notNull(postAction, "A varivel no pode ser nula.");

    // validao de contedo
    Validate.isTrue(!priorAction.getName().isAvailable(), "A varivel deve estar inicializada.");

    // validao de contedo
    if (priorAction.hasArguments()) {
        for (Variable test : priorAction.getArguments()) {
            Validate.isTrue(!test.isAvailable(), "Variavel tem que t inicializada!");
        }
    }

    // retorna se o conjunto estiver vazio
    if (priorAction.getName().getValues().isEmpty()) {
        return;
    }

    // retorna se o conjunto estiver vazio
    if (priorAction.hasArguments()) {
        for (Variable test : priorAction.getArguments()) {
            if (test.getValues().isEmpty()) {
                return;
            }
        }
    }

    // predicado da ao anterior
    Predicate priorActionPredicate;
    Predicate priorActionNamePredicate;
    Collection priorActionNamePredicateList = new ArrayList();
    for (Object currentPriorActionName : priorAction.getName().getValues()) {
        priorActionNamePredicateList.add(new PriorActionPredicate((String) currentPriorActionName));
    }
    priorActionNamePredicate = PredicateUtils.anyPredicate(priorActionNamePredicateList);
    if (priorAction.hasArguments()) {
        List<Variable> priorActionArguments = priorAction.getArguments();
        Collection priorActionArgumentsPredicateList = new ArrayList();
        Collection priorActionArgumentPredicateList;
        for (int i = 0; i < priorActionArguments.size(); i++) {
            priorActionArgumentPredicateList = new ArrayList();
            for (Object currentPriorActionArgument : priorActionArguments.get(i).getValues()) {
                priorActionArgumentPredicateList
                        .add(new PriorActionCheckArgumentPredicate(i, currentPriorActionArgument));
            }
            priorActionArgumentsPredicateList
                    .add(PredicateUtils.anyPredicate(priorActionArgumentPredicateList));
        }
        priorActionArgumentsPredicateList
                .add(new PriorActionCountArgumentsPredicate(priorActionArguments.size()));
        priorActionArgumentsPredicateList.add(priorActionNamePredicate);
        priorActionPredicate = PredicateUtils.allPredicate(priorActionArgumentsPredicateList);
    } else {
        priorActionPredicate = priorActionNamePredicate;
    }

    // validao de contedo
    Validate.isTrue(!postAction.getName().isAvailable(), "A varivel deve estar inicializada.");

    // validao de contedo
    if (postAction.hasArguments()) {
        for (Variable test : postAction.getArguments()) {
            Validate.isTrue(!test.isAvailable(), "A varivel deve estar inicializada.");
        }
    }

    // retorna se conjunto for vazio
    if (postAction.getName().getValues().isEmpty()) {
        return;
    }

    // retorna se conjunto for vazio
    if (postAction.hasArguments()) {
        for (Variable test : postAction.getArguments()) {
            if (test.getValues().isEmpty()) {
                return;
            }
        }
    }

    // predicado da ao posterior
    Predicate postActionPredicate;
    Predicate postActionNamePredicate;
    Collection postActionNamePredicateList = new ArrayList();
    for (Object currentPostActionName : postAction.getName().getValues()) {
        postActionNamePredicateList.add(new PostActionPredicate((String) currentPostActionName));
    }
    postActionNamePredicate = PredicateUtils.anyPredicate(postActionNamePredicateList);
    if (postAction.hasArguments()) {
        List<Variable> postActionArguments = postAction.getArguments();
        Collection postActionArgumentsPredicateList = new ArrayList();
        Collection postActionArgumentPredicateList;
        for (int i = 0; i < postActionArguments.size(); i++) {
            postActionArgumentPredicateList = new ArrayList();
            for (Object currentPostActionArgument : postActionArguments.get(i).getValues()) {
                postActionArgumentPredicateList
                        .add(new PostActionCheckArgumentPredicate(i, currentPostActionArgument));
            }
            postActionArgumentsPredicateList.add(PredicateUtils.anyPredicate(postActionArgumentPredicateList));
        }
        postActionArgumentsPredicateList.add(new PostActionCountArgumentsPredicate(postActionArguments.size()));
        postActionArgumentsPredicateList.add(postActionNamePredicate);
        postActionPredicate = PredicateUtils.allPredicate(postActionArgumentsPredicateList);
    } else {
        postActionPredicate = postActionNamePredicate;
    }

    // validao de contedo
    Validate.isTrue(!source.isAvailable(), "A varivel deve estar inicializada.");

    // retorna se o conjunto estiver vazio
    if (source.getValues().isEmpty()) {
        return;
    }

    // predicado do estado de origem
    Collection sourcePredicateList = new ArrayList();
    for (Object currentSource : source.getValues()) {
        sourcePredicateList.add(new SourceStatePredicate((State) currentSource));
    }
    Predicate sourcePredicate = PredicateUtils.anyPredicate(sourcePredicateList);

    // validao de contedo
    Validate.isTrue(!symbol.isAvailable(), "A varivel deve estar inicializada.");

    // retorna se o conjunto for vazio
    if (symbol.getValues().isEmpty()) {
        return;
    }

    // predicado do smbolo
    Collection symbolPredicateList = new ArrayList();
    for (Object currentSymbol : symbol.getValues()) {
        if (currentSymbol != null) {
            symbolPredicateList.add(new SymbolPredicate((Symbol) currentSymbol));
        } else {
            symbolPredicateList.add(new EpsilonPredicate());
        }
    }
    Predicate symbolPredicate = PredicateUtils.anyPredicate(symbolPredicateList);

    // validao de contedo
    Validate.isTrue(!target.isAvailable(), "A varivel deve estar inicializada.");

    // retorna se o conjunto for vazio
    if (target.getValues().isEmpty()) {
        return;
    }

    // predicado do estado de destino
    Collection targetPredicateList = new ArrayList();
    for (Object currentTarget : target.getValues()) {
        targetPredicateList.add(new TargetStatePredicate((State) currentTarget));
    }
    Predicate targetPredicate = PredicateUtils.anyPredicate(targetPredicateList);

    // a consulta  a interseco dos predicados
    Collection<Transition> query = CollectionUtils.select(transitions.getTransitions(),
            PredicateUtils.allPredicate(new Predicate[] { sourcePredicate, symbolPredicate, targetPredicate,
                    priorActionPredicate, postActionPredicate }));

    // lista de identificadores
    // para remoo
    List<Integer> removals = new ArrayList<>();

    // percorre o resultado da consulta
    // e adiciona os identificadores na lista
    for (Transition transition : query) {
        removals.add(transition.getIdentifier());
    }

    // remove as transies de acordo
    // com seus identificadores
    for (int id : removals) {
        transitions.removeFromIdentifier(id);
    }
}

From source file:br.usp.poli.lta.cereda.aa.model.actions.ElementaryActions.java

/**
 * Remove transies de acordo com o padro informado.
 * @param source Estado de origem.//  ww  w . j  a  va2 s.c  o  m
 * @param submachine Submquina a ser chamada.
 * @param target Estado de destino.
 */
public void remove(Variable source, SubmachineQuery submachine, Variable target) {

    // validaes
    Validate.notNull(source, "A varivel no pode ser nula.");
    Validate.notNull(submachine, "A varivel no pode ser nula.");
    Validate.notNull(target, "A varivel no pode ser nula.");

    // validao de contedo
    Validate.isTrue(!source.isAvailable(), "A varivel deve estar inicializada.");

    // retorna se o conjunto for vazio
    if (source.getValues().isEmpty()) {
        return;
    }

    // predicado do estado de origem
    Collection sourcePredicateList = new ArrayList();
    for (Object currentSource : source.getValues()) {
        sourcePredicateList.add(new SourceStatePredicate((State) currentSource));
    }
    Predicate sourcePredicate = PredicateUtils.anyPredicate(sourcePredicateList);

    // validao de contedo
    Validate.isTrue(!submachine.getVariable().isAvailable(), "A varivel deve estar inicializada.");

    // retorna se o conjunto for vazio
    if (submachine.getVariable().getValues().isEmpty()) {
        return;
    }

    // predicado de chamada de submquina
    Collection submachinePredicateList = new ArrayList();
    for (Object currentSubmachine : submachine.getVariable().getValues()) {
        submachinePredicateList.add(new SubmachinePredicate((String) currentSubmachine));
    }
    Predicate submachinePredicate = PredicateUtils.anyPredicate(submachinePredicateList);

    // validao de contedo
    Validate.isTrue(!target.isAvailable(), "A varivel deve estar inicializada.");

    // retorna se o conjunto for vazio
    if (target.getValues().isEmpty()) {
        return;
    }

    // predicado do estado de destino
    Collection targetPredicateList = new ArrayList();
    for (Object currentTarget : target.getValues()) {
        targetPredicateList.add(new TargetStatePredicate((State) currentTarget));
    }
    Predicate targetPredicate = PredicateUtils.anyPredicate(targetPredicateList);

    // a consulta  a interseco dos predicados
    Collection<Transition> query = CollectionUtils.select(transitions.getTransitions(), PredicateUtils
            .allPredicate(new Predicate[] { sourcePredicate, submachinePredicate, targetPredicate }));

    // lista de identificadores
    // para remoo
    List<Integer> removals = new ArrayList<>();

    // percorre o resultado da consulta,
    // adicionando os identificadores na lista
    for (Transition transition : query) {
        removals.add(transition.getIdentifier());
    }

    // remove as transies de acordo com
    // seus identificadores
    for (int id : removals) {
        transitions.removeFromIdentifier(id);
    }
}

From source file:br.usp.poli.lta.cereda.aa.model.actions.ElementaryActions.java

/**
 * Remove transies de acordo com o padro informado.
 * @param source Estado de origem.//from www. j  av a 2 s .co m
 * @param submachine Submquina a ser chamada.
 * @param target Estado de destino.
 * @param postAction Ao posterior.
 */
public void remove(Variable source, SubmachineQuery submachine, Variable target, ActionQuery postAction) {

    // validaes
    Validate.notNull(source, "A varivel no pode ser nula.");
    Validate.notNull(submachine, "A varivel no pode ser nula.");
    Validate.notNull(target, "A varivel no pode ser nula.");
    Validate.notNull(postAction, "A varivel no pode ser nula.");

    // validao de contedo
    Validate.isTrue(!postAction.getName().isAvailable(), "A varivel deve estar inicializada.");

    // validao de contedo
    if (postAction.hasArguments()) {
        for (Variable test : postAction.getArguments()) {
            Validate.isTrue(!test.isAvailable(), "A varivel deve estar inicializada.");
        }
    }

    // retorna se o conjunto for vazio
    if (postAction.getName().getValues().isEmpty()) {
        return;
    }

    // retorna se o conjunto for vazio
    if (postAction.hasArguments()) {
        for (Variable test : postAction.getArguments()) {
            if (test.getValues().isEmpty()) {
                return;
            }
        }
    }

    // predicado da ao posterior
    Predicate postActionPredicate;
    Predicate postActionNamePredicate;
    Collection postActionNamePredicateList = new ArrayList();
    for (Object currentPostActionName : postAction.getName().getValues()) {
        postActionNamePredicateList.add(new PostActionPredicate((String) currentPostActionName));
    }
    postActionNamePredicate = PredicateUtils.anyPredicate(postActionNamePredicateList);
    if (postAction.hasArguments()) {
        List<Variable> postActionArguments = postAction.getArguments();
        Collection postActionArgumentsPredicateList = new ArrayList();
        Collection postActionArgumentPredicateList;
        for (int i = 0; i < postActionArguments.size(); i++) {
            postActionArgumentPredicateList = new ArrayList();
            for (Object currentPostActionArgument : postActionArguments.get(i).getValues()) {
                postActionArgumentPredicateList
                        .add(new PostActionCheckArgumentPredicate(i, currentPostActionArgument));
            }
            postActionArgumentsPredicateList.add(PredicateUtils.anyPredicate(postActionArgumentPredicateList));
        }
        postActionArgumentsPredicateList.add(new PostActionCountArgumentsPredicate(postActionArguments.size()));
        postActionArgumentsPredicateList.add(postActionNamePredicate);
        postActionPredicate = PredicateUtils.allPredicate(postActionArgumentsPredicateList);
    } else {
        postActionPredicate = postActionNamePredicate;
    }

    // validao de contedo
    Validate.isTrue(!source.isAvailable(), "A varivel deve estar inicializada.");

    // retorna se o conjunto for vazio
    if (source.getValues().isEmpty()) {
        return;
    }

    // predicado do estado de origem
    Collection sourcePredicateList = new ArrayList();
    for (Object currentSource : source.getValues()) {
        sourcePredicateList.add(new SourceStatePredicate((State) currentSource));
    }
    Predicate sourcePredicate = PredicateUtils.anyPredicate(sourcePredicateList);

    // validao de contedo
    Validate.isTrue(!submachine.getVariable().isAvailable(), "A varivel deve estar inicializada.");

    // retorna se o conjunto for vazio
    if (submachine.getVariable().getValues().isEmpty()) {
        return;
    }

    // predicado de chamada de submquina
    Collection submachinePredicateList = new ArrayList();
    for (Object currentSubmachine : submachine.getVariable().getValues()) {
        submachinePredicateList.add(new SubmachinePredicate((String) currentSubmachine));
    }
    Predicate submachinePredicate = PredicateUtils.anyPredicate(submachinePredicateList);

    // validao de contedo
    Validate.isTrue(!target.isAvailable(), "A varivel deve estar inicializada.");

    // retorna se o conjunto for vazio
    if (target.getValues().isEmpty()) {
        return;
    }

    // predicado do estado de destino
    Collection targetPredicateList = new ArrayList();
    for (Object currentTarget : target.getValues()) {
        targetPredicateList.add(new TargetStatePredicate((State) currentTarget));
    }
    Predicate targetPredicate = PredicateUtils.anyPredicate(targetPredicateList);

    // a consulta  a interseco dos predicados
    Collection<Transition> query = CollectionUtils.select(transitions.getTransitions(),
            PredicateUtils.allPredicate(new Predicate[] { sourcePredicate, submachinePredicate, targetPredicate,
                    postActionPredicate }));

    // lista de identificadores
    // para remoo
    List<Integer> removals = new ArrayList<>();

    // percorre todas as transies
    // da consulta, adicionando os
    // identificadores
    for (Transition transition : query) {
        removals.add(transition.getIdentifier());
    }

    // remove as transies de acordo com
    // seus identificadores
    for (int id : removals) {
        transitions.removeFromIdentifier(id);
    }
}

From source file:br.usp.poli.lta.cereda.aa.model.actions.ElementaryActions.java

/**
 * Remove transies de acordo com o padro informado.
 * @param priorAction Ao anterior./*from  ww w.j a  va  2 s  .  co m*/
 * @param source Estado de origem.
 * @param submachine Submquina a ser chamada.
 * @param target Estado de destino.
 */
public void remove(ActionQuery priorAction, Variable source, SubmachineQuery submachine, Variable target) {

    // validaes
    Validate.notNull(priorAction, "A varivel no pode ser nula.");
    Validate.notNull(source, "A varivel no pode ser nula.");
    Validate.notNull(submachine, "A varivel no pode ser nula.");
    Validate.notNull(target, "A varivel no pode ser nula.");

    // validao de contedo
    Validate.isTrue(!priorAction.getName().isAvailable(), "A varivel deve estar inicializada.");

    // validao de contedo
    if (priorAction.hasArguments()) {
        for (Variable test : priorAction.getArguments()) {
            Validate.isTrue(!test.isAvailable(), "A varivel deve estar inicializada.");
        }
    }

    // retorna se o conjunto estiver vazio
    if (priorAction.getName().getValues().isEmpty()) {
        return;
    }

    // retorna se o conjunto estiver vazio
    if (priorAction.hasArguments()) {
        for (Variable test : priorAction.getArguments()) {
            if (test.getValues().isEmpty()) {
                return;
            }
        }
    }

    // predicado da ao anterior
    Predicate priorActionPredicate;
    Predicate priorActionNamePredicate;
    Collection priorActionNamePredicateList = new ArrayList();
    for (Object currentPriorActionName : priorAction.getName().getValues()) {
        priorActionNamePredicateList.add(new PriorActionPredicate((String) currentPriorActionName));
    }
    priorActionNamePredicate = PredicateUtils.anyPredicate(priorActionNamePredicateList);
    if (priorAction.hasArguments()) {
        List<Variable> priorActionArguments = priorAction.getArguments();
        Collection priorActionArgumentsPredicateList = new ArrayList();
        Collection priorActionArgumentPredicateList;
        for (int i = 0; i < priorActionArguments.size(); i++) {
            priorActionArgumentPredicateList = new ArrayList();
            for (Object currentPriorActionArgument : priorActionArguments.get(i).getValues()) {
                priorActionArgumentPredicateList
                        .add(new PriorActionCheckArgumentPredicate(i, currentPriorActionArgument));
            }
            priorActionArgumentsPredicateList
                    .add(PredicateUtils.anyPredicate(priorActionArgumentPredicateList));
        }
        priorActionArgumentsPredicateList
                .add(new PriorActionCountArgumentsPredicate(priorActionArguments.size()));
        priorActionArgumentsPredicateList.add(priorActionNamePredicate);
        priorActionPredicate = PredicateUtils.allPredicate(priorActionArgumentsPredicateList);
    } else {
        priorActionPredicate = priorActionNamePredicate;
    }

    // validao de contedo
    Validate.isTrue(!source.isAvailable(), "A varivel deve estar inicializada.");

    // retorna se o conjunto for vazio
    if (source.getValues().isEmpty()) {
        return;
    }

    // predicado do estado de origem
    Collection sourcePredicateList = new ArrayList();
    for (Object currentSource : source.getValues()) {
        sourcePredicateList.add(new SourceStatePredicate((State) currentSource));
    }
    Predicate sourcePredicate = PredicateUtils.anyPredicate(sourcePredicateList);

    // validao de contedo
    Validate.isTrue(!submachine.getVariable().isAvailable(), "A varivel deve estar inicializada.");

    // retorna se o conjunto for vazio
    if (submachine.getVariable().getValues().isEmpty()) {
        return;
    }

    // predicado da chamada de submquina
    Collection submachinePredicateList = new ArrayList();
    for (Object currentSubmachine : submachine.getVariable().getValues()) {
        submachinePredicateList.add(new SubmachinePredicate((String) currentSubmachine));
    }
    Predicate submachinePredicate = PredicateUtils.anyPredicate(submachinePredicateList);

    // validao de contedo
    Validate.isTrue(!target.isAvailable(), "A varivel deve estar inicializada.");

    // retorna se o conjunto for vazio
    if (target.getValues().isEmpty()) {
        return;
    }

    // predicado do estado de destino
    Collection targetPredicateList = new ArrayList();
    for (Object currentTarget : target.getValues()) {
        targetPredicateList.add(new TargetStatePredicate((State) currentTarget));
    }
    Predicate targetPredicate = PredicateUtils.anyPredicate(targetPredicateList);

    // a consulta  a interseco dos predicados
    Collection<Transition> query = CollectionUtils.select(transitions.getTransitions(),
            PredicateUtils.allPredicate(new Predicate[] { sourcePredicate, submachinePredicate, targetPredicate,
                    priorActionPredicate }));

    // lista de identificadore
    // para remoo
    List<Integer> removals = new ArrayList<>();

    // para cada transio da consulta,
    // adiciona identificador na lista
    for (Transition transition : query) {
        removals.add(transition.getIdentifier());
    }

    // remove as transies de
    // acordo com seus identificadores
    for (int id : removals) {
        transitions.removeFromIdentifier(id);
    }
}

From source file:br.usp.poli.lta.cereda.aa.model.actions.ElementaryActions.java

/**
 * Remove transies de acordo com o padro informado.
 * @param priorAction Ao anterior.//from  w  w  w.  jav  a2  s .co  m
 * @param source Estado de origem.
 * @param submachine Submquina a ser chamada.
 * @param target Estado de destino.
 * @param postAction Ao posterior.
 */
public void remove(ActionQuery priorAction, Variable source, SubmachineQuery submachine, Variable target,
        ActionQuery postAction) {

    // validaes
    Validate.notNull(priorAction, "A varivel no pode ser nula.");
    Validate.notNull(source, "A varivel no pode ser nula.");
    Validate.notNull(submachine, "A varivel no pode ser nula.");
    Validate.notNull(target, "A varivel no pode ser nula.");
    Validate.notNull(postAction, "A varivel no pode ser nula.");

    // validaes em relao ao contedo
    Validate.isTrue(!priorAction.getName().isAvailable(), "A varivel deve estar inicializada.");
    if (priorAction.hasArguments()) {
        for (Variable test : priorAction.getArguments()) {
            Validate.isTrue(!test.isAvailable(), "A varivel deve estar inicializada.");
        }
    }

    // retorna para valores vazios
    if (priorAction.getName().getValues().isEmpty()) {
        return;
    }

    // retorna para valores vazios
    if (priorAction.hasArguments()) {
        for (Variable test : priorAction.getArguments()) {
            if (test.getValues().isEmpty()) {
                return;
            }
        }
    }

    // predicado da ao anterior
    Predicate priorActionPredicate;

    // tratamento do nome da ao anterior
    Predicate priorActionNamePredicate;
    Collection priorActionNamePredicateList = new ArrayList();
    for (Object currentPriorActionName : priorAction.getName().getValues()) {
        priorActionNamePredicateList.add(new PriorActionPredicate((String) currentPriorActionName));
    }
    priorActionNamePredicate = PredicateUtils.anyPredicate(priorActionNamePredicateList);

    // tratamento dos argumentos da
    // ao anterior, se existirem
    if (priorAction.hasArguments()) {
        List<Variable> priorActionArguments = priorAction.getArguments();
        Collection priorActionArgumentsPredicateList = new ArrayList();
        Collection priorActionArgumentPredicateList;
        for (int i = 0; i < priorActionArguments.size(); i++) {
            priorActionArgumentPredicateList = new ArrayList();
            for (Object currentPriorActionArgument : priorActionArguments.get(i).getValues()) {
                priorActionArgumentPredicateList
                        .add(new PriorActionCheckArgumentPredicate(i, currentPriorActionArgument));
            }
            priorActionArgumentsPredicateList
                    .add(PredicateUtils.anyPredicate(priorActionArgumentPredicateList));
        }
        priorActionArgumentsPredicateList
                .add(new PriorActionCountArgumentsPredicate(priorActionArguments.size()));
        priorActionArgumentsPredicateList.add(priorActionNamePredicate);
        priorActionPredicate = PredicateUtils.allPredicate(priorActionArgumentsPredicateList);
    } else {
        priorActionPredicate = priorActionNamePredicate;
    }

    // tratamento do contedo
    Validate.isTrue(!postAction.getName().isAvailable(), "A varivel deve estar inicializada.");
    if (postAction.hasArguments()) {
        for (Variable test : postAction.getArguments()) {
            Validate.isTrue(!test.isAvailable(), "A varivel deve estar inicializada.");
        }
    }

    // retorna com conjunto vazio
    if (postAction.getName().getValues().isEmpty()) {
        return;
    }

    // retorna com conjunto vazio
    if (postAction.hasArguments()) {
        for (Variable test : postAction.getArguments()) {
            if (test.getValues().isEmpty()) {
                return;
            }
        }
    }

    // predicado da ao posterior
    Predicate postActionPredicate;

    // tratamento do nome da ao posterior
    Predicate postActionNamePredicate;
    Collection postActionNamePredicateList = new ArrayList();
    for (Object currentPostActionName : postAction.getName().getValues()) {
        postActionNamePredicateList.add(new PostActionPredicate((String) currentPostActionName));
    }
    postActionNamePredicate = PredicateUtils.anyPredicate(postActionNamePredicateList);

    // tratamento dos argumentos da
    // ao anterior, se existirem
    if (postAction.hasArguments()) {
        List<Variable> postActionArguments = postAction.getArguments();
        Collection postActionArgumentsPredicateList = new ArrayList();
        Collection postActionArgumentPredicateList;
        for (int i = 0; i < postActionArguments.size(); i++) {
            postActionArgumentPredicateList = new ArrayList();
            for (Object currentPostActionArgument : postActionArguments.get(i).getValues()) {
                postActionArgumentPredicateList
                        .add(new PostActionCheckArgumentPredicate(i, currentPostActionArgument));
            }
            postActionArgumentsPredicateList.add(PredicateUtils.anyPredicate(postActionArgumentPredicateList));
        }
        postActionArgumentsPredicateList.add(new PostActionCountArgumentsPredicate(postActionArguments.size()));
        postActionArgumentsPredicateList.add(postActionNamePredicate);
        postActionPredicate = PredicateUtils.allPredicate(postActionArgumentsPredicateList);
    } else {
        postActionPredicate = postActionNamePredicate;
    }

    // tratamento do contedo
    Validate.isTrue(!source.isAvailable(), "A varivel deve estar inicializada.");

    // retorna se o conjunto est vazio
    if (source.getValues().isEmpty()) {
        return;
    }

    // predicado do estado de origem
    Collection sourcePredicateList = new ArrayList();
    for (Object currentSource : source.getValues()) {
        sourcePredicateList.add(new SourceStatePredicate((State) currentSource));
    }
    Predicate sourcePredicate = PredicateUtils.anyPredicate(sourcePredicateList);

    // tratamento do contedo
    Validate.isTrue(!submachine.getVariable().isAvailable(), "A varivel deve estar inicializada.");

    // retorna se o conjunto est vazio
    if (submachine.getVariable().getValues().isEmpty()) {
        return;
    }

    // predicado da chamada de submquina
    Collection submachinePredicateList = new ArrayList();
    for (Object currentSubmachine : submachine.getVariable().getValues()) {
        submachinePredicateList.add(new SubmachinePredicate((String) currentSubmachine));
    }
    Predicate submachinePredicate = PredicateUtils.anyPredicate(submachinePredicateList);

    // validao de contedo
    Validate.isTrue(!target.isAvailable(), "A varivel deve estar inicializada.");

    // retorna se o conjunto estiver vazio
    if (target.getValues().isEmpty()) {
        return;
    }

    // tratamento do estado de destino
    Collection targetPredicateList = new ArrayList();
    for (Object currentTarget : target.getValues()) {
        targetPredicateList.add(new TargetStatePredicate((State) currentTarget));
    }
    Predicate targetPredicate = PredicateUtils.anyPredicate(targetPredicateList);

    // a consulta  a unio dos predicados
    Collection<Transition> query = CollectionUtils.select(transitions.getTransitions(),
            PredicateUtils.allPredicate(new Predicate[] { sourcePredicate, submachinePredicate, targetPredicate,
                    priorActionPredicate, postActionPredicate }));

    // lista de identificadores de remoo
    List<Integer> removals = new ArrayList<>();

    // percorre as transies da consulta
    // e obtm seus identificadores
    for (Transition transition : query) {
        removals.add(transition.getIdentifier());
    }

    // remove as transies marcadas
    // com o identificador
    for (int id : removals) {
        transitions.removeFromIdentifier(id);
    }
}