// 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)); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private void assertParseUniqueConstraintRule(String serialized, String name) throws org.neo4j.internal.kernel.api.exceptions.schema.MalformedSchemaRuleException private void AssertParseUniqueConstraintRule(string serialized, string name) { // GIVEN long ruleId = 1; int propertyKey = 3; int labelId = 55; long ownedIndexId = 2; UniquenessConstraintDescriptor constraint = ConstraintDescriptorFactory.uniqueForLabel(labelId, propertyKey); sbyte[] bytes = DecodeBase64(serialized); // WHEN ConstraintRule deserialized = AssertConstraintRule(SchemaRuleSerialization.Deserialize(ruleId, ByteBuffer.wrap(bytes))); // THEN assertThat(deserialized.Id, equalTo(ruleId)); assertThat(deserialized.ConstraintDescriptor, equalTo(constraint)); assertThat(deserialized.Schema(), equalTo(constraint.Schema())); assertThat(deserialized.OwnedIndex, equalTo(ownedIndexId)); assertThat(deserialized.Name, @is(name)); }
public abstract ConstraintRule CreateUniquenessConstraintRule(long ruleId, UniquenessConstraintDescriptor descriptor, long indexId);
public override ConstraintRule CreateUniquenessConstraintRule(long ruleId, UniquenessConstraintDescriptor descriptor, long indexId) { return(ConstraintRule.constraintRule(ruleId, descriptor, indexId)); }