-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classA mapping directive to be applied to a source field. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic FieldRemappings.DirectiveDeclares a source field is to be omitted from the result.static FieldRemappings.DirectiveDeclares a source field is to be preserved in the result, keeping the same name.static FieldRemappings.DirectiveDefines a name mapping from a source to a target field.static FieldRemappingpatternRename(String format, String... excludedFields) Defines a simple pattern-based renaming fields of a record schema.static FieldRemappingrename(FieldRemappings.Directive... directives) Defines a transformation renaming fields of a record schema.static FieldRemappingrenameAndDrop(FieldRemappings.Directive... directives) Defines a transformation renaming fields of a record schema, dropping source fields without an explicit directive.static FieldRemappingreorder(FieldRemappings.Directive... directives) Defines a transformation reordering and possibly renaming fields of a record schema.static FieldRemappingreorderAndDrop(FieldRemappings.Directive... directives) Defines a transformation reordering and possibly renaming fields of a record schema, dropping source fields without an explicit directive.
-
Constructor Details
-
FieldRemappings
public FieldRemappings()
-
-
Method Details
-
drop
Declares a source field is to be omitted from the result.This is useful is forcibly removing fields from the source when they otherwise would be kept, for example when using
rename(Directive...)orreorder(Directive...).If the only actions being done are the dropping of unwanted fields, consider using one of
SelectFields,RetainFields, orRemoveFields.- Parameters:
name- the name of the source field to drop from the target- Returns:
- the declared directive
-
keep
Declares a source field is to be preserved in the result, keeping the same name.This is useful if renaming is not desired, but a mapping is needed to produce desired ordering or preserve a field in a type mapping.
- Parameters:
name- the name of the source field to keep in the target- Returns:
- the declared directive
-
map
Defines a name mapping from a source to a target field.- Parameters:
from- the name of the field in the sourceto- the name of the field in the target- Returns:
- the defined mapping
-
patternRename
Defines a simple pattern-based renaming fields of a record schema. The relative order of fields is unchanged. For all fields not explicitly excluded, a supplied formatting pattern is applied to produce the new name.- Parameters:
format- a pattern for renaming of fields. This is in the syntax supported byMessageFormat. There will be exactly one argument to format - the name of the field.excludedFields- names of fields which should not be be renamed.- Returns:
- a transform applying the specified pattern-based renaming
-
rename
Defines a transformation renaming fields of a record schema. The relative order of fields is unchanged.For example, if the source schema is {"a", "b", "c"} and the directives [ "c"->"Z", "a"->"X" ] are applied, the result is { "X", "b", "Z" }.
Note that in this context, a
keep(java.lang.String)directive is a no-op.- Parameters:
directives- the field mapping operations to apply.- Returns:
- a transform applying the supplied directives
-
renameAndDrop
Defines a transformation renaming fields of a record schema, dropping source fields without an explicit directive. The relative order of fields is unchanged.For example, if the source schema is {"a", "b", "c"} and the directives [ "c"->"Z", "a"->"X" ] are applied, the result is { "X", "Z" }.
Note that in this context, a
drop(java.lang.String)directive is a no-op. Further, this transformation is equivalent to combining a rename operation with aRetainFields.- Parameters:
directives- the field mapping operations to apply.- Returns:
- a transform applying the supplied directives
-
reorder
Defines a transformation reordering and possibly renaming fields of a record schema. Source fields can be referenced multiple times (using different target names), producing "aliases" of the same field in the result. The order of fields in the result is determined as described below:- Source fields specified in the directives will appear in the same order they are referenced in the directive list.
- Source fields not referenced by any directive will appear after fields specified in the directives, in the same relative order as in the source.
Unlike
rename(Directive...), akeep(java.lang.String)directive does exhibit an effect, controlling the ordering of a field in the result.- Parameters:
directives- the field mapping operations to apply.- Returns:
- a transform applying the supplied directives
-
reorderAndDrop
Defines a transformation reordering and possibly renaming fields of a record schema, dropping source fields without an explicit directive. Source fields can be referenced multiple times (using different target names), producing "aliases" of the same field in the result. The order of fields in the result is the same order they are referenced in the directive list.As an example, if the source schema is {"a", "b", "c"} and the directives [ "c"->"Z", "a"->"X" ] are applied, the result is { "Z", "X" }.
Note that in this context, a
drop(java.lang.String)directive is a no-op. Further, this transformation is equivalent to combining a renaming operation with aSelectFields.- Parameters:
directives- the field mapping operations to apply.- Returns:
- a transform applying the supplied directives
-