package de.renew.net.inscription.transition;

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 RangeEnumeratorInscription implements TransitionInscription {
    /**
     * The {@code Expression} that will be evaluated.
     */
    private final Expression _expression;

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

    /**
     * The first index.
     */
    private final int _first;

    /**
     * The last index.
     */
    private final int _last;

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

    /**
     * Constructs a new RangeEnumeratorInscription with the given parameters.
     * Usage of this class is unclear, apparently it is no longer in use.
     *
     * @param expr the {@code Expression}
     * @param first the first index
     * @param last the last index
     * @param checkBound true if bound should be checked
     * @param transition the Transition that contains the RangeEnumeratorInscription
     */
    public RangeEnumeratorInscription(
        Expression expr, int first, int last, boolean checkBound, Transition transition)
    {
        _expression = expr;
        _first = first;
        _last = last;
        _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 RangeEnumeratorOccurrence(
                    _expression, _checkbound, mapper, _first, _last,
                    netInstance.getInstance(_transition))));
    }
}