Class TransformedRecordSerializer.Builder<M extends Message>
- java.lang.Object
-
- com.apple.foundationdb.record.provider.common.TransformedRecordSerializer.Builder<M>
-
- Type Parameters:
M
- type ofMessage
that underlying records will use
- Direct Known Subclasses:
TransformedRecordSerializerJCE.Builder
- Enclosing class:
- TransformedRecordSerializer<M extends Message>
public static class TransformedRecordSerializer.Builder<M extends Message> extends Object
Builder class for theTransformedRecordSerializer
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.
-
-
Field Summary
Fields Modifier and Type Field Description protected int
compressionLevel
protected boolean
compressWhenSerializing
protected boolean
encryptWhenSerializing
protected RecordSerializer<M>
inner
-
Constructor Summary
Constructors Modifier Constructor Description protected
Builder(RecordSerializer<M> inner)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description TransformedRecordSerializer<M>
build()
Construct aTransformedRecordSerializer
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.
-
-
-
Field Detail
-
inner
@Nonnull protected final RecordSerializer<M extends Message> inner
-
compressWhenSerializing
protected boolean compressWhenSerializing
-
compressionLevel
protected int compressionLevel
-
encryptWhenSerializing
protected boolean encryptWhenSerializing
-
-
Constructor Detail
-
Builder
protected Builder(@Nonnull RecordSerializer<M> inner)
-
-
Method Detail
-
setCompressWhenSerializing
public TransformedRecordSerializer.Builder<M> setCompressWhenSerializing(boolean compressWhenSerializing)
Whether to compress records after serializing. Should compression and encryption both be set, then the data will be compressed before they are encrypted. By default, records are not compressed. The compression level can be specified withsetCompressionLevel(int)
.- Parameters:
compressWhenSerializing
-true
if records should be compressed andfalse
otherwise- Returns:
- this
Builder
-
setCompressionLevel
public TransformedRecordSerializer.Builder<M> setCompressionLevel(int level)
Compression level to use if compressing. These should be the same levels as used by theDeflater
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 9. Setting this does not automatically enable compression when serializing.- Parameters:
level
- the compression level (0-9)- Returns:
- this
Builder
- See Also:
Deflater
-
setEncryptWhenSerializing
public TransformedRecordSerializer.Builder<M> setEncryptWhenSerializing(boolean encryptWhenSerializing)
Whether to encrypt records after serializing. Should compression and encryption both be set, then data will be compressed before they are encrypted. By default, records are not encrypted. The baseTransformedRecordSerializer
class does not support encryption, sobuild()
will throw on exception. But subclasses such asTransformedRecordSerializerJCE
do support it. When using those builders and enabling encryption, the user must also call appropriate methods to specify the encryption key.- Parameters:
encryptWhenSerializing
-true
if records should be encrypted andfalse
otherwise- Returns:
- this
Builder
-
build
public TransformedRecordSerializer<M> build()
Construct aTransformedRecordSerializer
from the parameters specified by this builder. If one has enabled encryption at serialization time, then this will fail with anRecordCoreArgumentException
.- Returns:
- a
TransformedRecordSerializer
from thisBuilder
- Throws:
RecordCoreArgumentException
- if encryption is enabled when serializing but no encryption is specified
-
-