Package org.apache.beam.sdk.schemas
Class JavaFieldSchema
java.lang.Object
org.apache.beam.sdk.schemas.GetterBasedSchemaProvider
org.apache.beam.sdk.schemas.GetterBasedSchemaProviderV2
org.apache.beam.sdk.schemas.JavaFieldSchema
- All Implemented Interfaces:
Serializable
,SchemaProvider
A
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.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
FieldValueTypeSupplier
that's based on public fields. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<T> List
<FieldValueGetter<@NonNull T, Object>> fieldValueGetters
(TypeDescriptor<T> targetTypeDescriptor, Schema schema) Delegates to theGetterBasedSchemaProvider.fieldValueGetters(Class, Schema)
for backwards compatibility, override it if you want to use the richer type signature contained in theTypeDescriptor
not subject to the type erasure.fieldValueTypeInformations
(TypeDescriptor<?> targetTypeDescriptor, Schema schema) Delegates to theGetterBasedSchemaProvider.fieldValueTypeInformations(Class, Schema)
for backwards compatibility, override it if you want to use the richer type signature contained in theTypeDescriptor
not subject to the type erasure.<T> Schema
schemaFor
(TypeDescriptor<T> typeDescriptor) Lookup a schema for the given type.schemaTypeCreator
(TypeDescriptor<?> targetTypeDescriptor, Schema schema) Delegates to theGetterBasedSchemaProvider.schemaTypeCreator(Class, Schema)
for backwards compatibility, override it if you want to use the richer type signature contained in theTypeDescriptor
not subject to the type erasure.Methods inherited from class org.apache.beam.sdk.schemas.GetterBasedSchemaProviderV2
fieldValueGetters, fieldValueTypeInformations, schemaTypeCreator
Methods inherited from class org.apache.beam.sdk.schemas.GetterBasedSchemaProvider
equals, fromRowFunction, hashCode, toRowFunction
-
Constructor Details
-
JavaFieldSchema
public JavaFieldSchema()
-
-
Method Details
-
schemaFor
Description copied from interface:SchemaProvider
Lookup a schema for the given type. If no schema exists, returns null. -
fieldValueGetters
public <T> List<FieldValueGetter<@NonNull T,Object>> fieldValueGetters(TypeDescriptor<T> targetTypeDescriptor, Schema schema) Description copied from class:GetterBasedSchemaProvider
Delegates to theGetterBasedSchemaProvider.fieldValueGetters(Class, Schema)
for backwards compatibility, override it if you want to use the richer type signature contained in theTypeDescriptor
not subject to the type erasure.- Specified by:
fieldValueGetters
in classGetterBasedSchemaProviderV2
-
fieldValueTypeInformations
public List<FieldValueTypeInformation> fieldValueTypeInformations(TypeDescriptor<?> targetTypeDescriptor, Schema schema) Description copied from class:GetterBasedSchemaProvider
Delegates to theGetterBasedSchemaProvider.fieldValueTypeInformations(Class, Schema)
for backwards compatibility, override it if you want to use the richer type signature contained in theTypeDescriptor
not subject to the type erasure.- Specified by:
fieldValueTypeInformations
in classGetterBasedSchemaProviderV2
-
schemaTypeCreator
public SchemaUserTypeCreator schemaTypeCreator(TypeDescriptor<?> targetTypeDescriptor, Schema schema) Description copied from class:GetterBasedSchemaProvider
Delegates to theGetterBasedSchemaProvider.schemaTypeCreator(Class, Schema)
for backwards compatibility, override it if you want to use the richer type signature contained in theTypeDescriptor
not subject to the type erasure.- Specified by:
schemaTypeCreator
in classGetterBasedSchemaProviderV2
-