private static void getSupportedVariablesInLiteral(GdlLiteral literal,
Collection<GdlVariable> variables) {
if(literal instanceof GdlRelation) {
getVariablesInBody(((GdlRelation) literal).getBody(), variables);
} else if(literal instanceof GdlOr) {
GdlOr or = (GdlOr) literal;
if(or.arity() == 0)
return;
LinkedList<GdlVariable> vars = new LinkedList<GdlVariable>();
getSupportedVariablesInLiteral(or.get(0), vars);
for(int i = 1; i < or.arity(); i++) {
Set<GdlVariable> newVars = new HashSet<GdlVariable>();
getSupportedVariablesInLiteral(or.get(i), newVars);
vars.retainAll(newVars);
}
variables.addAll(vars);
}
}