M
- type of Message
that underlying records will usepublic static class TransformedRecordSerializer.Builder<M extends Message> extends Object
TransformedRecordSerializer
class. The methods
on this builder allows the user to specify parameters that can then be
used to specify which transformations should be applied before serializing
the record. It can also be used to specify parameters that will then be
applied to serialized data before deserializing, though the prefix of
records themselves are what specify the needed transformations.Modifier and Type | Field and Description |
---|---|
protected int |
compressionLevel |
protected boolean |
compressWhenSerializing |
protected boolean |
encryptWhenSerializing |
protected RecordSerializer<M> |
inner |
Modifier | Constructor and Description |
---|---|
protected |
Builder(RecordSerializer<M> inner) |
Modifier and Type | Method and Description |
---|---|
TransformedRecordSerializer<M> |
build()
Construct a
TransformedRecordSerializer from the
parameters specified by this builder. |
TransformedRecordSerializer.Builder<M> |
setCompressionLevel(int level)
Compression level to use if compressing.
|
TransformedRecordSerializer.Builder<M> |
setCompressWhenSerializing(boolean compressWhenSerializing)
Whether to compress records after serializing.
|
TransformedRecordSerializer.Builder<M> |
setEncryptWhenSerializing(boolean encryptWhenSerializing)
Whether to encrypt records after serializing.
|
@Nonnull protected final RecordSerializer<M extends Message> inner
protected boolean compressWhenSerializing
protected int compressionLevel
protected boolean encryptWhenSerializing
protected Builder(@Nonnull RecordSerializer<M> inner)
public TransformedRecordSerializer.Builder<M> setCompressWhenSerializing(boolean compressWhenSerializing)
setCompressionLevel(int)
.compressWhenSerializing
- true
if records should be compressed and false
otherwiseBuilder
public TransformedRecordSerializer.Builder<M> setCompressionLevel(int level)
Deflater
class (which
are the same levels as used by zlib). The higher the level,
the better the compression will be but the slower or more
CPU intensive it will be. The default level if none is
set here is . Setting
this does not automatically enable compression when
serializing.level
- the compression level (0-9)Builder
Deflater
public TransformedRecordSerializer.Builder<M> setEncryptWhenSerializing(boolean encryptWhenSerializing)
TransformedRecordSerializer
class
does not support encryption, so build()
will throw on exception.
But subclasses such as TransformedRecordSerializerJCE
do support it.
When using those builders and enabling encryption, the user must also call appropriate methods
to specify the encryption key.encryptWhenSerializing
- true
if records should be encrypted and false
otherwiseBuilder
public TransformedRecordSerializer<M> build()
TransformedRecordSerializer
from the
parameters specified by this builder. If one has enabled
encryption at serialization time, then this will fail
with an RecordCoreArgumentException
.TransformedRecordSerializer
from this Builder
RecordCoreArgumentException
- if encryption is enabled when serializing but no encryption is specified