All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.coode.patterns.VisitedPatternReferenceResolver Maven / Gradle / Ivy

There is a newer version: 5.0.0
Show newest version
package org.coode.patterns;

import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import org.coode.parsers.oppl.OPPLSyntaxTree;
import org.coode.parsers.oppl.patterns.OPPLPatternsSymbolTable;
import org.coode.patterns.OPPLPatternParser.PatternReferenceResolver;

/** @author Luigi Iannone */
public final class VisitedPatternReferenceResolver implements PatternReferenceResolver {
    private final Set visited = new HashSet();

    /** @param visitedPatterns
     *            visitedPatterns */
    public VisitedPatternReferenceResolver(Collection visitedPatterns) {
        assert visitedPatterns != null;
        visited.addAll(visitedPatterns);
    }

    @Override
    public void resolvePattern(OPPLSyntaxTree reference, String patternName,
            PatternConstraintSystem constraintSystem,
            OPPLPatternsSymbolTable symbolTable, List... args) {
        symbolTable.resolvePattern(reference, patternName, constraintSystem, visited,
                args);
    }

    /** @return the visited */
    public Set getVisited() {
        return new HashSet(visited);
    }
}