Class ChainRule
java.lang.Object
com.streamconverter.command.rule.impl.composite.ChainRule
- All Implemented Interfaces:
IRule
Chains multiple transformation rules to be applied in sequence.
This rule allows combining multiple IRule instances to create complex transformations
by applying them one after another. The output of each rule becomes the input for the next rule
in the chain.
Examples:
// Trim whitespace then convert to snake_case
IRule chainedRule = ChainRule.builder()
.addRule(new TrimRule())
.addRule(CamelToSnakeCaseRule.create())
.build();
// Multiple transformations
IRule complexRule = ChainRule.of(
new TrimRule(),
new LowerCaseRule(),
CamelToSnakeCaseRule.create()
);
Thread Safety: This class is thread-safe as long as the individual rules in the chain are thread-safe.
- Since:
- 1.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBuilder class for ChainRule configuration. -
Method Summary
Modifier and TypeMethodDescriptionルールの適用を実行します。static ChainRule.Builderbuilder()Creates a builder for configuring the ChainRule.booleangetRules()Gets an unmodifiable view of the rules in this chain.inthashCode()static ChainRuleCreates a ChainRule with the specified rules.static ChainRuleCreates a ChainRule with the specified rules.intsize()Gets the number of rules in this chain.toString()
-
Method Details
-
apply
Description copied from interface:IRuleルールの適用を実行します。このメソッドは、ストリーム変換の際にルールを適用するために使用されます。 具体的なルールの実装は、このメソッドをオーバーライドして定義します。 変換対象とする箇所を特定したあとにこのメソッドを呼び出すことを想定しています。
-
size
Gets the number of rules in this chain.- Returns:
- number of rules
-
getRules
Gets an unmodifiable view of the rules in this chain.- Returns:
- unmodifiable list of rules
-
builder
Creates a builder for configuring the ChainRule.- Returns:
- new builder instance
-
of
Creates a ChainRule with the specified rules.- Parameters:
rules- rules to chain together- Returns:
- new ChainRule instance
- Throws:
IllegalArgumentException- if rules array is null or empty
-
of
Creates a ChainRule with the specified rules.- Parameters:
rules- list of rules to chain together- Returns:
- new ChainRule instance
- Throws:
IllegalArgumentException- if rules list is null or empty
-
toString
-
equals
-
hashCode
-