Search in sources :

Example 1 with NodePropertyExistenceConstraint

use of org.neo4j.kernel.api.constraints.NodePropertyExistenceConstraint in project neo4j by neo4j.

the class GraphDbStructureGuide method showUniqueConstraints.

private void showUniqueConstraints(DbStructureVisitor visitor, ReadOperations read, TokenNameLookup nameLookup) {
    Iterator<ConstraintDescriptor> constraints = read.constraintsGetAll();
    while (constraints.hasNext()) {
        PropertyConstraint constraint = ConstraintBoundary.map(constraints.next());
        String userDescription = constraint.userDescription(nameLookup);
        if (constraint instanceof UniquenessConstraint) {
            visitor.visitUniqueConstraint((UniquenessConstraint) constraint, userDescription);
        } else if (constraint instanceof NodePropertyExistenceConstraint) {
            NodePropertyExistenceConstraint existenceConstraint = (NodePropertyExistenceConstraint) constraint;
            visitor.visitNodePropertyExistenceConstraint(existenceConstraint, userDescription);
        } else if (constraint instanceof RelationshipPropertyExistenceConstraint) {
            RelationshipPropertyExistenceConstraint existenceConstraint = (RelationshipPropertyExistenceConstraint) constraint;
            visitor.visitRelationshipPropertyExistenceConstraint(existenceConstraint, userDescription);
        } else {
            throw new IllegalArgumentException("Unknown constraint type: " + constraint.getClass() + ", " + "constraint: " + constraint);
        }
    }
}
Also used : PropertyConstraint(org.neo4j.kernel.api.constraints.PropertyConstraint) ConstraintDescriptor(org.neo4j.kernel.api.schema_new.constaints.ConstraintDescriptor) RelationshipPropertyExistenceConstraint(org.neo4j.kernel.api.constraints.RelationshipPropertyExistenceConstraint) NodePropertyExistenceConstraint(org.neo4j.kernel.api.constraints.NodePropertyExistenceConstraint) UniquenessConstraint(org.neo4j.kernel.api.constraints.UniquenessConstraint)

Aggregations

NodePropertyExistenceConstraint (org.neo4j.kernel.api.constraints.NodePropertyExistenceConstraint)1 PropertyConstraint (org.neo4j.kernel.api.constraints.PropertyConstraint)1 RelationshipPropertyExistenceConstraint (org.neo4j.kernel.api.constraints.RelationshipPropertyExistenceConstraint)1 UniquenessConstraint (org.neo4j.kernel.api.constraints.UniquenessConstraint)1 ConstraintDescriptor (org.neo4j.kernel.api.schema_new.constaints.ConstraintDescriptor)1