Пример #1
0
        // READ CONSTRAINT

//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private static ConstraintRule readConstraintRule(long id, ByteBuffer source) throws org.neo4j.internal.kernel.api.exceptions.schema.MalformedSchemaRuleException
        private static ConstraintRule ReadConstraintRule(long id, ByteBuffer source)
        {
            SchemaDescriptor schema;
            sbyte            constraintRuleType = source.get();
            string           name;

            switch (constraintRuleType)
            {
            case EXISTS_CONSTRAINT:
                schema = ReadSchema(source);
                name   = ReadRuleName(source).orElse(null);
                return(ConstraintRule.ConstraintRuleConflict(id, ConstraintDescriptorFactory.existsForSchema(schema), name));

            case UNIQUE_CONSTRAINT:
                long ownedUniqueIndex = source.Long;
                schema = ReadSchema(source);
                UniquenessConstraintDescriptor descriptor = ConstraintDescriptorFactory.uniqueForSchema(schema);
                name = ReadRuleName(source).orElse(null);
                return(ConstraintRule.ConstraintRuleConflict(id, descriptor, ownedUniqueIndex, name));

            case UNIQUE_EXISTS_CONSTRAINT:
                long ownedNodeKeyIndex = source.Long;
                schema = ReadSchema(source);
                NodeKeyConstraintDescriptor nodeKeyConstraintDescriptor = ConstraintDescriptorFactory.nodeKeyForSchema(schema);
                name = ReadRuleName(source).orElse(null);
                return(ConstraintRule.ConstraintRuleConflict(id, nodeKeyConstraintDescriptor, ownedNodeKeyIndex, name));

            default:
                throw new MalformedSchemaRuleException(format("Got unknown constraint rule type '%d'.", constraintRuleType));
            }
        }
Пример #2
0
 internal override NodeKeyConstraintDescriptor NewConstraintObject(LabelSchemaDescriptor descriptor)
 {
     return(ConstraintDescriptorFactory.nodeKeyForSchema(descriptor));
 }