/** * Register a POJO type for automatic schema inference. * * <p>Currently schema field names will match field names in the POJO, and all fields must be * mutable (i.e. no final fields). The Java object is expected to have implemented a correct * .equals() and .hashCode methods The equals method must be completely determined by the schema * fields. i.e. if the object has hidden fields that are not reflected in the schema but are * compared in equals, then results will be incorrect. */ public <T> void registerPOJO(TypeDescriptor<T> typeDescriptor) { registerSchemaProvider(typeDescriptor, new JavaFieldSchema()); }
/** * Register a JavaBean type for automatic schema inference. * * <p>Currently schema field names will match getter names in the bean, and all getters must have * matching setters. */ public <T> void registerJavaBean(TypeDescriptor<T> typeDescriptor) { registerSchemaProvider(typeDescriptor, new JavaBeanSchema()); }
/** Register a {@link SchemaProvider} to be used for a specific type. * */ public <T> void registerSchemaProvider(Class<T> clazz, SchemaProvider schemaProvider) { registerSchemaProvider(TypeDescriptor.of(clazz), schemaProvider); }
@Test public void testRegisterProvider() throws NoSuchSchemaException { SchemaRegistry registry = SchemaRegistry.createDefault(); registry.registerSchemaProvider(new Provider()); tryGetters(registry); }