package de.renew.net.inscription.transition;

import java.util.Collection;
import java.util.List;
import java.util.Vector;

import de.renew.engine.searcher.Occurrence;
import de.renew.engine.searcher.Searcher;
import de.renew.expression.Expression;
import de.renew.expression.VariableMapper;
import de.renew.net.NetInstance;
import de.renew.net.Transition;
import de.renew.net.inscription.TransitionInscription;
import de.renew.unify.Impossible;

/**
 * Usage of this class is unclear, apparently it is no longer in use.
 */
public class SimpleEnumeratorInscription implements TransitionInscription {
    /**
     * The {@code Expression} that will be evaluated.
     */
    private final Expression _expression;

    /**
     * True if bound should be checked.
     */
    private final boolean _checkBound;

    /**
     * The Collection of Objects.
     */
    private final Collection<Object> _collection;

    /**
     * The Transition that contains the SimpleEnumeratorInscription.
     */
    private final Transition _transition;

    /**
     * Constructs a new SimpleEnumeratorInscription with the given parameters.
     * Usage of this class is unclear, apparently it is no longer in use.
     *
     * @param expr the {@code Expression} that will be evaluated
     * @param collection the Collection of Objects
     * @param checkBound true if bound should be checked
     * @param transition the Transition that contains the SimpleEnumeratorInscription
     */
    public SimpleEnumeratorInscription(
        Expression expr, Collection<Object> collection, boolean checkBound, Transition transition)
    {
        _expression = expr;
        _collection = collection;
        _checkBound = checkBound;
        _transition = transition;
    }

    @Override
    public java.util.Collection<Occurrence> makeOccurrences(
        VariableMapper mapper, NetInstance netInstance, Searcher searcher) throws Impossible
    {
        return new Vector<>(
            List.of(
                new SimpleEnumeratorOccurrence(
                    _expression, _checkBound, mapper, _collection,
                    netInstance.getInstance(_transition))));
    }
}