Package org.apache.beam.sdk.schemas
Class JavaFieldSchema
- java.lang.Object
-
- org.apache.beam.sdk.schemas.GetterBasedSchemaProvider
-
- org.apache.beam.sdk.schemas.JavaFieldSchema
-
- All Implemented Interfaces:
java.io.Serializable
,SchemaProvider
@Experimental(SCHEMAS) public class JavaFieldSchema extends GetterBasedSchemaProvider
ASchemaProvider
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.
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
JavaFieldSchema.JavaFieldTypeSupplier
FieldValueTypeSupplier
that's based on public fields.
-
Constructor Summary
Constructors Constructor Description JavaFieldSchema()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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.<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.-
Methods inherited from class org.apache.beam.sdk.schemas.GetterBasedSchemaProvider
equals, fromRowFunction, hashCode, toRowFunction
-
-
-
-
Method Detail
-
schemaFor
public <T> Schema schemaFor(TypeDescriptor<T> typeDescriptor)
Description copied from interface:SchemaProvider
Lookup a schema for the given type. If no schema exists, returns null.
-
fieldValueGetters
public java.util.List<FieldValueGetter> fieldValueGetters(java.lang.Class<?> targetClass, Schema schema)
Description copied from class:GetterBasedSchemaProvider
Implementing class should override to return FieldValueGetters.- Specified by:
fieldValueGetters
in classGetterBasedSchemaProvider
-
fieldValueTypeInformations
public java.util.List<FieldValueTypeInformation> fieldValueTypeInformations(java.lang.Class<?> targetClass, Schema schema)
Description copied from class:GetterBasedSchemaProvider
Implementing class should override to return a list of type-informations.- Specified by:
fieldValueTypeInformations
in classGetterBasedSchemaProvider
-
schemaTypeCreator
public SchemaUserTypeCreator schemaTypeCreator(java.lang.Class<?> targetClass, Schema schema)
Description copied from class:GetterBasedSchemaProvider
Implementing class should override to return a constructor.- Specified by:
schemaTypeCreator
in classGetterBasedSchemaProvider
-
-