use of com.vaticle.typedb.core.pattern.variable.TypeVariable in project grakn by graknlabs.
the class Definer method validateTypeHierarchyIsNotCyclic.
private void validateTypeHierarchyIsNotCyclic(Set<TypeVariable> variables) {
Set<TypeVariable> visited = new HashSet<>();
for (TypeVariable variable : variables) {
if (visited.contains(variable))
continue;
assert variable.label().isPresent();
LinkedHashSet<String> hierarchy = new LinkedHashSet<>();
hierarchy.add(variable.label().get().scopedLabel());
visited.add(variable);
while (variable.sub().isPresent()) {
variable = variable.sub().get().type();
assert variable.label().isPresent();
if (!hierarchy.add(variable.label().get().scopedLabel())) {
throw TypeDBException.of(CYCLIC_TYPE_HIERARCHY, hierarchy);
}
}
}
}
use of com.vaticle.typedb.core.pattern.variable.TypeVariable in project grakn by graknlabs.
the class OwnsConstraint method of.
static OwnsConstraint of(TypeVariable owner, OwnsConstraint clone, VariableCloner cloner) {
TypeVariable attributeType = cloner.clone(clone.attribute());
TypeVariable overriddenType = clone.overridden().map(cloner::clone).orElse(null);
return new OwnsConstraint(owner, attributeType, overriddenType, clone.isKey());
}
use of com.vaticle.typedb.core.pattern.variable.TypeVariable in project grakn by graknlabs.
the class PlaysConstraint method of.
static PlaysConstraint of(TypeVariable owner, PlaysConstraint role, VariableCloner cloner) {
TypeVariable roleType = cloner.clone(role.role());
TypeVariable relationType = role.relation().map(cloner::clone).orElse(null);
TypeVariable overriddenType = role.overridden().map(cloner::clone).orElse(null);
return new PlaysConstraint(owner, relationType, roleType, overriddenType);
}
use of com.vaticle.typedb.core.pattern.variable.TypeVariable in project grakn by graknlabs.
the class RelatesConstraint method of.
static RelatesConstraint of(TypeVariable owner, RelatesConstraint constraint, VariableCloner cloner) {
TypeVariable roleType = cloner.clone(constraint.role());
TypeVariable overriddenRoleType = constraint.overridden().map(cloner::clone).orElse(null);
return new RelatesConstraint(owner, roleType, overriddenRoleType);
}
use of com.vaticle.typedb.core.pattern.variable.TypeVariable in project grakn by graknlabs.
the class OwnsConstraint method of.
static OwnsConstraint of(TypeVariable owner, com.vaticle.typeql.lang.pattern.constraint.TypeConstraint.Owns constraint, VariableRegistry registry) {
TypeVariable attributeType = registry.register(constraint.attribute());
TypeVariable overriddenType = constraint.overridden().map(registry::register).orElse(null);
return new OwnsConstraint(owner, attributeType, overriddenType, constraint.isKey());
}
Aggregations