use of com.vaticle.typeql.lang.pattern.variable.BoundVariable in project grakn by graknlabs.
the class Conjunction method create.
public static Conjunction create(com.vaticle.typeql.lang.pattern.Conjunction<Conjunctable> typeql, @Nullable VariableRegistry bounds) {
try (ThreadTrace ignored = traceOnThread(TRACE_PREFIX + "create")) {
List<BoundVariable> typeQLVariables = new ArrayList<>();
List<com.vaticle.typeql.lang.pattern.Negation<?>> typeQLNegations = new ArrayList<>();
typeql.patterns().forEach(conjunctable -> {
if (conjunctable.isVariable())
typeQLVariables.add(conjunctable.asVariable());
else if (conjunctable.isNegation())
typeQLNegations.add(conjunctable.asNegation());
else
throw TypeDBException.of(ILLEGAL_STATE);
});
if (typeQLVariables.isEmpty() && !typeQLNegations.isEmpty())
throw TypeDBException.of(UNBOUNDED_NEGATION);
VariableRegistry registry = VariableRegistry.createFromVariables(typeQLVariables, bounds);
List<Negation> typeDBNegations = typeQLNegations.isEmpty() ? list() : typeQLNegations.stream().map(n -> Negation.create(n, registry)).collect(toList());
return new Conjunction(registry.variables(), typeDBNegations);
}
}
Aggregations