コード例 #1
0
        private static SchemaRule NewRule(SchemaRule_Kind kind, long id, int labelId, ByteBuffer buffer)
        {
            switch (kind.innerEnumValue)
            {
            case SchemaRule_Kind.InnerEnum.INDEX_RULE:
                return(ReadIndexRule(id, false, labelId, buffer));

            case SchemaRule_Kind.InnerEnum.CONSTRAINT_INDEX_RULE:
                return(ReadIndexRule(id, true, labelId, buffer));

            case SchemaRule_Kind.InnerEnum.UNIQUENESS_CONSTRAINT:
                return(ReadUniquenessConstraintRule(id, labelId, buffer));

            case SchemaRule_Kind.InnerEnum.NODE_PROPERTY_EXISTENCE_CONSTRAINT:
                return(ReadNodePropertyExistenceConstraintRule(id, labelId, buffer));

            case SchemaRule_Kind.InnerEnum.RELATIONSHIP_PROPERTY_EXISTENCE_CONSTRAINT:
                return(ReadRelPropertyExistenceConstraintRule(id, labelId, buffer));

            default:
                throw new System.ArgumentException(kind.name());
            }
        }
コード例 #2
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: static org.neo4j.storageengine.api.schema.SchemaRule deserialize(long id, int labelId, byte kindByte, ByteBuffer buffer) throws org.neo4j.internal.kernel.api.exceptions.schema.MalformedSchemaRuleException
        internal static SchemaRule Deserialize(long id, int labelId, sbyte kindByte, ByteBuffer buffer)
        {
            SchemaRule_Kind kind = SchemaRule_Kind.forId(kindByte);

            try
            {
                SchemaRule rule = NewRule(kind, id, labelId, buffer);
                if (null == rule)
                {
                    throw new MalformedSchemaRuleException(null, "Deserialized null schema rule for id %d with kind %s", id, kind.name());
                }
                return(rule);
            }
            catch (Exception e)
            {
                throw new MalformedSchemaRuleException(e, "Could not deserialize schema rule for id %d with kind %s", id, kind.name());
            }
        }