Interface RecordService
-
public interface RecordService
Helping class to build records.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Record
create(Schema schema, Record fallbackRecord, BiFunction<Schema.Entry,Record.Builder,Boolean> customHandler, BiConsumer<Record.Builder,Boolean> beforeFinish)
Shortcut to build a record usingtoRecord(Schema, Record, BiFunction, BiConsumer)
.boolean
forwardEntry(Record source, Record.Builder builder, String sourceColumn, Schema.Entry entry)
Forward an entry from the source record if it exists.<T> T
toObject(Record data, Class<T> expected)
Simple mapper of record to pojo.Collector<Schema.Entry,Record.Builder,Record>
toRecord(Schema schema, Record fallbackRecord, BiFunction<Schema.Entry,Record.Builder,Boolean> customHandler, BiConsumer<Record.Builder,Boolean> beforeFinish)
Method providing a collector enabling to create a record from another one in a custom fashion.<T> Record
toRecord(T data)
Simple mapper of data to record.<T> T
visit(RecordVisitor<T> visitor, Record record)
Visit a record with a custom visitor.
-
-
-
Method Detail
-
toObject
<T> T toObject(Record data, Class<T> expected)
Simple mapper of record to pojo.- Type Parameters:
T
- the pojo type (optional).- Parameters:
data
- record to map to pojo.expected
- : class expected.- Returns:
- a pojo representing the data record.
-
toRecord
<T> Record toRecord(T data)
Simple mapper of data to record.- Type Parameters:
T
- the pojo type (optional).- Parameters:
data
- pojo to map to record.- Returns:
- a record representing the pojo.
-
forwardEntry
boolean forwardEntry(Record source, Record.Builder builder, String sourceColumn, Schema.Entry entry)
Forward an entry from the source record if it exists.- Parameters:
source
- the source record to read data from.builder
- the current builder to fill.sourceColumn
- the column name.entry
- the entry to use for the output column.- Returns:
- true if the entry was forwarded.
-
toRecord
Collector<Schema.Entry,Record.Builder,Record> toRecord(Schema schema, Record fallbackRecord, BiFunction<Schema.Entry,Record.Builder,Boolean> customHandler, BiConsumer<Record.Builder,Boolean> beforeFinish)
Method providing a collector enabling to create a record from another one in a custom fashion.- Parameters:
schema
- the schema of the record being built.fallbackRecord
- the source record used when the custom handler does not handle current entry.customHandler
- a processor of entry enabling to inject custom data in the record being built.beforeFinish
- a callback before the record is actually built, it enables to add data if not already there.- Returns:
- a collector enabling to build a record.
-
create
Record create(Schema schema, Record fallbackRecord, BiFunction<Schema.Entry,Record.Builder,Boolean> customHandler, BiConsumer<Record.Builder,Boolean> beforeFinish)
Shortcut to build a record usingtoRecord(Schema, Record, BiFunction, BiConsumer)
.- Parameters:
schema
- the schema of the record being built.fallbackRecord
- the source record used when the custom handler does not handle current entry.customHandler
- a processor of entry enabling to inject custom data in the record being built.beforeFinish
- a callback before the record is actually built, it enables to add data if not already there.- Returns:
- a collector enabling to build a record.
-
visit
<T> T visit(RecordVisitor<T> visitor, Record record)
Visit a record with a custom visitor.- Type Parameters:
T
- the visitor returned type.- Parameters:
visitor
- the visitor to use to browse the record.record
- record to visit.- Returns:
- the visitor value.
-
-