Class TransformedRecordSerializer.Builder<M extends Message>

  • Type Parameters:
    M - type of Message 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 the 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.
    • Field Detail

      • compressWhenSerializing

        protected boolean compressWhenSerializing
      • compressionLevel

        protected int compressionLevel
      • encryptWhenSerializing

        protected boolean encryptWhenSerializing
    • 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 with setCompressionLevel(int).
        Parameters:
        compressWhenSerializing - true if records should be compressed and false 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 the 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 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 base 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.
        Parameters:
        encryptWhenSerializing - true if records should be encrypted and false otherwise
        Returns:
        this Builder