/** * Parse a SchemaRule from the provided buffer. * * @param id the id to give the returned Schema Rule * @param source the buffer to parse from * @return a SchemaRule * @throws MalformedSchemaRuleException if bytes in the buffer do encode a valid SchemaRule */ public static SchemaRule deserialize( long id, ByteBuffer source ) throws MalformedSchemaRuleException { int legacyLabelOrRelTypeId = source.getInt(); byte schemaRuleType = source.get(); switch ( schemaRuleType ) { case INDEX_RULE: return readIndexRule( id, source ); case CONSTRAINT_RULE: return readConstraintRule( id, source ); default: if ( SchemaRuleDeserializer2_0to3_1.isLegacySchemaRule( schemaRuleType ) ) { return SchemaRuleDeserializer2_0to3_1.deserialize( id, legacyLabelOrRelTypeId, schemaRuleType, source ); } throw new MalformedSchemaRuleException( format( "Got unknown schema rule type '%d'.", schemaRuleType ) ); } }
/** * Parse a SchemaRule from the provided buffer. * * @param id the id to give the returned Schema Rule * @param source the buffer to parse from * @return a SchemaRule * @throws MalformedSchemaRuleException if bytes in the buffer do encode a valid SchemaRule */ public static SchemaRule deserialize( long id, ByteBuffer source ) throws MalformedSchemaRuleException { int legacyLabelOrRelTypeId = source.getInt(); byte schemaRuleType = source.get(); switch ( schemaRuleType ) { case INDEX_RULE: return readIndexRule( id, source ); case CONSTRAINT_RULE: return readConstraintRule( id, source ); default: if ( SchemaRuleDeserializer2_0to3_1.isLegacySchemaRule( schemaRuleType ) ) { return SchemaRuleDeserializer2_0to3_1.deserialize( id, legacyLabelOrRelTypeId, schemaRuleType, source ); } throw new MalformedSchemaRuleException( format( "Got unknown schema rule type '%d'.", schemaRuleType ) ); } }