public class FieldRemappings extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
FieldRemappings.Directive
A mapping directive to be applied to a source field.
|
| Constructor and Description |
|---|
FieldRemappings() |
| Modifier and Type | Method and Description |
|---|---|
static FieldRemappings.Directive |
drop(String name)
Declares a source field is to be omitted from the result.
|
static FieldRemappings.Directive |
keep(String name)
Declares a source field is to be preserved in the result,
keeping the same name.
|
static FieldRemappings.Directive |
map(String from,
String to)
Defines a name mapping from a source to a target field.
|
static FieldRemapping |
patternRename(String format,
String... excludedFields)
Defines a simple pattern-based renaming fields of a record schema.
|
static FieldRemapping |
rename(FieldRemappings.Directive... directives)
Defines a transformation renaming fields of a record schema.
|
static FieldRemapping |
renameAndDrop(FieldRemappings.Directive... directives)
Defines a transformation renaming fields of a record schema,
dropping source fields without an explicit directive.
|
static FieldRemapping |
reorder(FieldRemappings.Directive... directives)
Defines a transformation reordering and possibly renaming fields of
a record schema.
|
static FieldRemapping |
reorderAndDrop(FieldRemappings.Directive... directives)
Defines a transformation reordering and possibly renaming fields of
a record schema, dropping source fields without an explicit directive.
|
public static FieldRemappings.Directive drop(String name)
This is useful is forcibly removing fields from the source
when they otherwise would be kept, for example when using
rename(Directive...)
or reorder(Directive...).
If the only actions being done are the dropping of unwanted
fields, consider using one of SelectFields,
RetainFields, or RemoveFields.
name - the name of the source field to drop from the targetpublic static FieldRemappings.Directive keep(String 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.
name - the name of the source field to keep in the targetpublic static FieldRemappings.Directive map(String from, String to)
from - the name of the field in the sourceto - the name of the field in the targetpublic static FieldRemapping patternRename(String format, String... excludedFields)
format - a pattern for renaming of fields. This is in the
syntax supported by MessageFormat. There will be exactly
one argument to format - the name of the field.excludedFields - names of fields which should not be
be renamed.public static FieldRemapping rename(FieldRemappings.Directive... directives)
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.
directives - the field mapping operations to apply.public static FieldRemapping renameAndDrop(FieldRemappings.Directive... directives)
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 a RetainFields.
directives - the field mapping operations to apply.public static FieldRemapping reorder(FieldRemappings.Directive... directives)
Unlike rename(Directive...), a keep(java.lang.String)
directive does exhibit an effect, controlling the ordering
of a field in the result.
directives - the field mapping operations to apply.public static FieldRemapping reorderAndDrop(FieldRemappings.Directive... directives)
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 a SelectFields.
directives - the field mapping operations to apply.Copyright © 2024 Actian Corporation. All rights reserved.