Class Transformer
java.lang.Object
com.northconcepts.datapipeline.transform.Transformer
- Direct Known Subclasses:
CopyField,FastRenameField,FieldTransformer,FlattenRecord,GetUrlQueryParam,LookupTransformer,MoveFieldAfter,MoveFieldBefore,MoveFieldToIndex,Ngrams,RemoveDuplicateFields,RemoveFields,RenameField,SchemaTransformer,SelectFields,SetBatchSequenceNumberField,SetCalculatedField,SetField,SetGroupSequenceNumberField,SetSequenceNumberField,SetUuidField,SplitArrayField,SplitWords
Base class for transformations that modify each record passing through a
TransformingReader or TransformingWriter.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddExceptionProperties(DataException exception) Adds this transformer's details to an exception raised by its host reader or writer; returns the same exception.protected voidclose()Called byTransformingReaderorTransformingWriterwhen theirclose()method is called (after reading or writing ends).Deprecated.Returns the reader or writer this transformer was added to (the reader if both) or null if neither.Returns theTransformingReaderthis transformer was added to or null if none.Returns theTransformingWriterthis transformer was added to or null if none.static TransformerCreates a Transformer from a Java Function.protected voidopen()Called byTransformingReaderorTransformingWriterwhen theiropen()method is called (before reading or writing starts).voidsetWriter(TransformingWriter writer) Sets the host writer; called byTransformingWriterwhen this transformer is added to it.abstract booleanApplies this transformer to a record on its way through aTransformingReaderorTransformingWriter.
-
Constructor Details
-
Transformer
public Transformer()
-
-
Method Details
-
getEndpoint
Returns the reader or writer this transformer was added to (the reader if both) or null if neither. -
geEndpoint
Deprecated.UsegetEndpoint()instead. -
getReader
Returns theTransformingReaderthis transformer was added to or null if none. -
getWriter
Returns theTransformingWriterthis transformer was added to or null if none. -
setWriter
Sets the host writer; called byTransformingWriterwhen this transformer is added to it. -
addExceptionProperties
Adds this transformer's details to an exception raised by its host reader or writer; returns the same exception. -
open
protected void open()Called byTransformingReaderorTransformingWriterwhen theiropen()method is called (before reading or writing starts). -
close
protected void close()Called byTransformingReaderorTransformingWriterwhen theirclose()method is called (after reading or writing ends). -
transform
Applies this transformer to a record on its way through aTransformingReaderorTransformingWriter.Contract for subclasses (see also
docs/authoring/Transformer.md):- Mutate
recordin place as needed. - Return
trueto keep the record in the pipeline. - Return
falseto drop the record (the host routes it to a discard writer if one is configured, otherwise it disappears). - Throw to fail (or route to a discard writer, depending on host configuration).
- Do not call
incrementRecordCount()on the host endpoint; the host handles it.
- Throws:
Throwable
- Mutate
-
of
Creates a Transformer from a Java Function. This allows creation of transformers using lambda expressions or method references.- Parameters:
function- the function that transforms records, returning true to continue or false to discard the record- Returns:
- a Transformer that delegates to the function
-
getEndpoint()instead.