org.coode.oppl.utils.VariableRecogniser Maven / Gradle / Ivy
package org.coode.oppl.utils;
import static org.coode.oppl.utils.ArgCheck.checkNotNull;
import org.coode.oppl.Variable;
import org.coode.oppl.VariableVisitorEx;
import org.coode.oppl.generated.GeneratedVariable;
import org.coode.oppl.generated.RegexpGeneratedVariable;
import org.coode.oppl.variabletypes.InputVariable;
import org.semanticweb.owlapi.model.OWLObject;
/** @author Luigi Iannone */
public class VariableRecogniser {
/** input recognizer */
public static VariableRecogniser INPUT_VARIABLE_RECOGNISER = new VariableRecogniser(
new AbstractVariableVisitorExAdapter(false) {
@Override
public Boolean visit(InputVariable
v) {
return true;
}
});
/** generated recognizer */
public static VariableRecogniser GENERATED_VARIABLE_RECOGNISER = new VariableRecogniser(
new AbstractVariableVisitorExAdapter(false) {
@Override
public Boolean visit(GeneratedVariable
v) {
return true;
}
});
/** regexp recognizer */
public static VariableRecogniser REGEXP_VARIABLE_RECOGNISER = new VariableRecogniser(
new AbstractVariableVisitorExAdapter(false) {
@Override
public Boolean visit(
RegexpGeneratedVariable
regExpGenerated) {
return true;
}
});
private final VariableVisitorEx recogniser;
/** @return the recogniser */
public VariableVisitorEx getRecogniser() {
return recogniser;
}
/** @param recogniser
* recogniser */
VariableRecogniser(VariableVisitorEx recogniser) {
this.recogniser = checkNotNull(recogniser, "recogniser");
}
/** @param v
* v
* @return true if recognised */
public boolean recognise(Variable> v) {
return v.accept(getRecogniser());
}
}