Search in sources :

Example 6 with IndexBackedConstraintDescriptor

use of org.neo4j.internal.schema.constraints.IndexBackedConstraintDescriptor in project neo4j by neo4j.

the class RandomSchema method schemaDeepEquals.

public static boolean schemaDeepEquals(SchemaRule a, SchemaRule b) {
    if (!a.equals(b)) {
        return false;
    }
    if (a.getId() != b.getId()) {
        return false;
    }
    if (!a.getName().equals(b.getName())) {
        return false;
    }
    if (a.getClass() != b.getClass()) {
        return false;
    }
    if (a instanceof IndexDescriptor) {
        IndexDescriptor indexA = (IndexDescriptor) a;
        IndexDescriptor indexB = (IndexDescriptor) b;
        return indexA.getCapability().equals(indexB.getCapability()) && indexA.isUnique() == indexB.isUnique() && indexA.getIndexProvider().equals(indexB.getIndexProvider()) && indexA.getIndexType() == indexB.getIndexType() && indexA.getOwningConstraintId().equals(indexB.getOwningConstraintId()) && schemaDeepEquals(indexA.schema(), indexB.schema());
    } else {
        ConstraintDescriptor constraintA = (ConstraintDescriptor) a;
        ConstraintDescriptor constraintB = (ConstraintDescriptor) b;
        if (constraintA.isIndexBackedConstraint() && constraintB.isIndexBackedConstraint()) {
            IndexBackedConstraintDescriptor ibcA = constraintA.asIndexBackedConstraint();
            IndexBackedConstraintDescriptor ibcB = constraintB.asIndexBackedConstraint();
            return ibcA.hasOwnedIndexId() == ibcB.hasOwnedIndexId() && (!ibcA.hasOwnedIndexId() || ibcA.ownedIndexId() == ibcB.ownedIndexId()) && ibcA.equals(ibcB) && schemaDeepEquals(ibcA.schema(), ibcB.schema());
        } else {
            return constraintA.isIndexBackedConstraint() == constraintB.isIndexBackedConstraint() && constraintA.equals(constraintB) && schemaDeepEquals(constraintA.schema(), constraintB.schema());
        }
    }
}
Also used : IndexBackedConstraintDescriptor(org.neo4j.internal.schema.constraints.IndexBackedConstraintDescriptor) ConstraintDescriptor(org.neo4j.internal.schema.ConstraintDescriptor) IndexBackedConstraintDescriptor(org.neo4j.internal.schema.constraints.IndexBackedConstraintDescriptor) IndexDescriptor(org.neo4j.internal.schema.IndexDescriptor)

Aggregations

IndexBackedConstraintDescriptor (org.neo4j.internal.schema.constraints.IndexBackedConstraintDescriptor)6 Test (org.junit.jupiter.api.Test)3 IndexDescriptor (org.neo4j.internal.schema.IndexDescriptor)3 OptionalLong (java.util.OptionalLong)1 RepeatedTest (org.junit.jupiter.api.RepeatedTest)1 InternalIndexState (org.neo4j.internal.kernel.api.InternalIndexState)1 SchemaRead (org.neo4j.internal.kernel.api.SchemaRead)1 SchemaWrite (org.neo4j.internal.kernel.api.SchemaWrite)1 IndexNotFoundKernelException (org.neo4j.internal.kernel.api.exceptions.schema.IndexNotFoundKernelException)1 ConstraintDescriptor (org.neo4j.internal.schema.ConstraintDescriptor)1 IndexPrototype (org.neo4j.internal.schema.IndexPrototype)1 UniquenessConstraintDescriptor (org.neo4j.internal.schema.constraints.UniquenessConstraintDescriptor)1 KernelIntegrationTest (org.neo4j.kernel.impl.api.integrationtest.KernelIntegrationTest)1