@Experimental(value=SCHEMAS) public class JavaBeanSchema extends GetterBasedSchemaProvider
SchemaProvider
for Java Bean objects.
This provider finds (recursively) all public getters and setters in a Java object, and creates schemas and rows that bind to those fields. The field order in the schema is not guaranteed to match the method order in the class. 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.
TODO: Validate equals() method is provided, and if not generate a "slow" equals method based on the schema.
Modifier and Type | Class and Description |
---|---|
static class |
JavaBeanSchema.GetterTypeSupplier
FieldValueTypeSupplier that's based on getter methods. |
static class |
JavaBeanSchema.SetterTypeSupplier
FieldValueTypeSupplier that's based on setter methods. |
Constructor and Description |
---|
JavaBeanSchema() |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(@Nullable java.lang.Object obj) |
java.util.List<FieldValueGetter> |
fieldValueGetters(java.lang.Class<?> targetClass,
Schema schema)
Implementing class should override to return FieldValueGetters.
|
java.util.List<FieldValueTypeInformation> |
fieldValueTypeInformations(java.lang.Class<?> targetClass,
Schema schema)
Implementing class should override to return a list of type-informations.
|
int |
hashCode() |
<T> Schema |
schemaFor(TypeDescriptor<T> typeDescriptor)
Lookup a schema for the given type.
|
SchemaUserTypeCreator |
schemaTypeCreator(java.lang.Class<?> targetClass,
Schema schema)
Implementing class should override to return a constructor.
|
fromRowFunction, toRowFunction
public <T> Schema schemaFor(TypeDescriptor<T> typeDescriptor)
SchemaProvider
public java.util.List<FieldValueGetter> fieldValueGetters(java.lang.Class<?> targetClass, Schema schema)
GetterBasedSchemaProvider
fieldValueGetters
in class GetterBasedSchemaProvider
public java.util.List<FieldValueTypeInformation> fieldValueTypeInformations(java.lang.Class<?> targetClass, Schema schema)
GetterBasedSchemaProvider
fieldValueTypeInformations
in class GetterBasedSchemaProvider
public SchemaUserTypeCreator schemaTypeCreator(java.lang.Class<?> targetClass, Schema schema)
GetterBasedSchemaProvider
schemaTypeCreator
in class GetterBasedSchemaProvider
public int hashCode()
hashCode
in class GetterBasedSchemaProvider
public boolean equals(@Nullable java.lang.Object obj)
equals
in class GetterBasedSchemaProvider