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();
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final classDefault implementation ofDataContentChainBuilder. -
Method Summary
Modifier and TypeMethodDescriptionadd(DataContentBuilder<? extends DataContent> builder) Adds aDataContentBuilderto the chain and links its output to the input of the previously addedDataContent, if any.build()Finalizes the chain and returns the tailDataContentinstance.static DataContentChainBuilderdecrypt()Creates a newDataContentChainBuilderconfigured for decryption mode.static DataContentChainBuilderencrypt()Creates a newDataContentChainBuilderconfigured for encryption mode.
-
Method Details
-
add
Adds aDataContentBuilderto the chain and links its output to the input of the previously addedDataContent, if any.The
DataContentproduced by this builder becomes the new tail of the chain.- Parameters:
builder- the builder producing the nextDataContent; must not be null- Returns:
- this chain builder instance, allowing for fluent chaining
- Throws:
NullPointerException- ifbuilderis null
-
build
DataContent build()Finalizes the chain and returns the tailDataContentinstance.The returned content may internally reference earlier content via
DataContent.setInput(DataContent)chaining.- Returns:
- the last
DataContentin the chain, ornullif no builders were added
-
encrypt
Creates a newDataContentChainBuilderconfigured for encryption mode.All added
DataContentBuilderinstances will receivetruefor theirbuild(boolean encrypt)method, indicating encryption behavior.- Returns:
- a new chain builder in encryption mode
-
decrypt
Creates a newDataContentChainBuilderconfigured for decryption mode.All added
DataContentBuilderinstances will receivefalsefor theirbuild(boolean encrypt)method, indicating decryption behavior.- Returns:
- a new chain builder in decryption mode
-