Search in sources :

Example 1 with SchemaDescriptor

use of org.neo4j.kernel.api.schema_new.SchemaDescriptor in project neo4j by neo4j.

the class SchemaRuleSerialization method readConstraintRule.

// READ CONSTRAINT
private static ConstraintRule readConstraintRule(long id, ByteBuffer source) throws MalformedSchemaRuleException {
    SchemaDescriptor schema;
    byte constraintRuleType = source.get();
    String name;
    switch(constraintRuleType) {
        case EXISTS_CONSTRAINT:
            schema = readSchema(source);
            name = readRuleName(id, ConstraintRule.class, source);
            return ConstraintRule.constraintRule(id, ConstraintDescriptorFactory.existsForSchema(schema), name);
        case UNIQUE_CONSTRAINT:
            long ownedIndex = source.getLong();
            schema = readSchema(source);
            UniquenessConstraintDescriptor descriptor = ConstraintDescriptorFactory.uniqueForSchema(schema);
            name = readRuleName(id, ConstraintRule.class, source);
            return ConstraintRule.constraintRule(id, descriptor, ownedIndex, name);
        default:
            throw new MalformedSchemaRuleException(format("Got unknown constraint rule type '%d'.", constraintRuleType));
    }
}
Also used : RelationTypeSchemaDescriptor(org.neo4j.kernel.api.schema_new.RelationTypeSchemaDescriptor) LabelSchemaDescriptor(org.neo4j.kernel.api.schema_new.LabelSchemaDescriptor) SchemaDescriptor(org.neo4j.kernel.api.schema_new.SchemaDescriptor) MalformedSchemaRuleException(org.neo4j.kernel.api.exceptions.schema.MalformedSchemaRuleException) UniquenessConstraintDescriptor(org.neo4j.kernel.api.schema_new.constaints.UniquenessConstraintDescriptor)

Aggregations

MalformedSchemaRuleException (org.neo4j.kernel.api.exceptions.schema.MalformedSchemaRuleException)1 LabelSchemaDescriptor (org.neo4j.kernel.api.schema_new.LabelSchemaDescriptor)1 RelationTypeSchemaDescriptor (org.neo4j.kernel.api.schema_new.RelationTypeSchemaDescriptor)1 SchemaDescriptor (org.neo4j.kernel.api.schema_new.SchemaDescriptor)1 UniquenessConstraintDescriptor (org.neo4j.kernel.api.schema_new.constaints.UniquenessConstraintDescriptor)1