Interface DataContentChainBuilder

All Known Implementing Classes:
DataContentChainBuilder.DefaultDataContentChainBuilder

public interface DataContentChainBuilder
A builder interface for constructing a chain of DataContent components, where each content unit passes its output as the input to the next one.

This builder simplifies the composition of processing pipelines such as:

  • Encryption with multiple layers (e.g., compression → encryption → signing)
  • Decryption chains (e.g., verification → decryption → decompression)

The builder supports both encryption and decryption modes, which are applied consistently across all DataContentBuilder instances in the chain.

Usage example:

DataContent chain = DataContentChainBuilder.encrypt()
    .add(PlainStringBuilder.builder().value("hello"))
    .add(DerivedAesParametersBuilder.builder().password("secret"))
    .build();
  • Method Details

    • add

      Adds a DataContentBuilder to the chain and links its output to the input of the previously added DataContent, if any.

      The DataContent produced by this builder becomes the new tail of the chain.

      Parameters:
      builder - the builder producing the next DataContent; must not be null
      Returns:
      this chain builder instance, allowing for fluent chaining
      Throws:
      NullPointerException - if builder is null
    • build

      DataContent build()
      Finalizes the chain and returns the tail DataContent instance.

      The returned content may internally reference earlier content via DataContent.setInput(DataContent) chaining.

      Returns:
      the last DataContent in the chain, or null if no builders were added
    • encrypt

      static DataContentChainBuilder encrypt()
      Creates a new DataContentChainBuilder configured for encryption mode.

      All added DataContentBuilder instances will receive true for their build(boolean encrypt) method, indicating encryption behavior.

      Returns:
      a new chain builder in encryption mode
    • decrypt

      static DataContentChainBuilder decrypt()
      Creates a new DataContentChainBuilder configured for decryption mode.

      All added DataContentBuilder instances will receive false for their build(boolean encrypt) method, indicating decryption behavior.

      Returns:
      a new chain builder in decryption mode