org.etlunit.feature.PatternedClassDirectorFeature Maven / Gradle / Ivy
package org.etlunit.feature;
import org.etlunit.ClassDirector;
import org.etlunit.NullClassDirector;
import org.etlunit.parser.ETLTestClass;
import org.etlunit.parser.ETLTestMethod;
import org.etlunit.parser.ETLTestOperation;
import java.util.regex.Pattern;
public class PatternedClassDirectorFeature extends AbstractFeature
{
private final Pattern clsNamePattern;
private final Pattern mthdNamePattern;
private final Pattern operNamePattern;
private final String instanceName;
private final class PatternClassDirector extends NullClassDirector
{
@Override
public response_code accept(ETLTestClass cl)
{
if (clsNamePattern != null)
{
return clsNamePattern.matcher(cl.getQualifiedName()).find() ? response_code.accept : response_code.reject;
}
return response_code.defer;
}
@Override
public response_code accept(ETLTestMethod mt)
{
if (mthdNamePattern != null)
{
return mthdNamePattern.matcher(mt.getName()).find() ? response_code.accept : response_code.reject;
}
return response_code.defer;
}
@Override
public response_code accept(ETLTestOperation op)
{
if (operNamePattern != null)
{
return operNamePattern.matcher(op.getQualifiedName()).find() ? response_code.accept : response_code.reject;
}
return response_code.defer;
}
}
private final PatternClassDirector patternClassDirector = new PatternClassDirector();
public PatternedClassDirectorFeature(String instanceName, String clsNamePattern, String mthdNamePattern, String operNamePattern)
{
this.clsNamePattern = clsNamePattern != null ? Pattern.compile(clsNamePattern, Pattern.CASE_INSENSITIVE) : null;
this.mthdNamePattern = mthdNamePattern != null ? Pattern.compile(mthdNamePattern, Pattern.CASE_INSENSITIVE) : null;
this.operNamePattern = operNamePattern != null ? Pattern.compile(operNamePattern, Pattern.CASE_INSENSITIVE) : null;
this.instanceName = instanceName;
}
@Override
public String getFeatureName()
{
return "pattern-class-director_" + instanceName;
}
@Override
public ClassDirector getDirector()
{
return patternClassDirector;
}
@Override
public long getPriorityLevel()
{
return -1L;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy