@Experimental(value=SCHEMAS) public class JavaFieldSchema extends GetterBasedSchemaProvider
SchemaProvider
for Java POJO objects.
This provider finds all public fields (recursively) 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 field 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 |
JavaFieldSchema.JavaFieldTypeSupplier
FieldValueTypeSupplier that's based on public fields. |
Constructor and Description |
---|
JavaFieldSchema() |
Modifier and Type | Method and Description |
---|---|
FieldValueGetterFactory |
fieldValueGetterFactory()
Implementing class should override to return a getter factory.
|
FieldValueTypeInformationFactory |
fieldValueTypeInformationFactory()
Implementing class should override to return a type-information factory.
|
<T> Schema |
schemaFor(TypeDescriptor<T> typeDescriptor)
Lookup a schema for the given type.
|
fromRowFunction, toRowFunction
public <T> Schema schemaFor(TypeDescriptor<T> typeDescriptor)
SchemaProvider
public FieldValueGetterFactory fieldValueGetterFactory()
GetterBasedSchemaProvider
public FieldValueTypeInformationFactory fieldValueTypeInformationFactory()
GetterBasedSchemaProvider