Package com.helixframework.rules.rule
Class BaseRule
java.lang.Object
com.helixframework.rules.rule.BaseRule
- All Implemented Interfaces:
Rule
Base rule that provides a default timeout for rule subclasses.
-
Field Summary
Fields inherited from interface com.helixframework.rules.rule.Rule
DEFAULT_MAX_RETRIES, DEFAULT_TIMEOUT -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidapply(RuleContext<?> ctx) Executes the rule with a default timeout.<T> Tapply(RuleContext<?> ctx, Class<T> outputType) Executes the rules and returns a result.<T> Tapply(RuleContext<?> ctx, Class<T> outputType, Duration timeout) Executes the rules, with a custom timeout, and returns a result.voidapply(RuleContext<?> ctx, Duration timeout) Executes the rule with a custom timeout.protected abstract voidapplyInternal(RuleContext<?> ctx) Applies the logic of the implementing rule and modifies the root object in the context.protected abstract <T> TapplyInternal(RuleContext<?> ctx, Class<T> outputType) Applies the logic of the implementing rule and returns the result.Gets the classification of the rule.Gets a set of rules for which this rule depends upon.Gets the description of the rule.Gets the number of times the rule should be retried in the event of a failure.getName()Gets the name of the rule.getTags()Gets the rule's tags.Gets the timeout.
-
Constructor Details
-
BaseRule
public BaseRule(String name, String classification, Set<Rule> dependencies, String description, Map<String, String> tags, Duration timeout, Integer maxRetries) Creates a new instance ofBaseRule.- Parameters:
name- rule nameclassification- rule classificationdependencies- rule dependenciesdescription- rule descriptiontags- rule tagstimeout- rule timeoutmaxRetries- rule max retry count
-
-
Method Details
-
applyInternal
Applies the logic of the implementing rule and modifies the root object in the context.- Parameters:
ctx- rule context
-
applyInternal
Applies the logic of the implementing rule and returns the result.- Type Parameters:
T- type of rule output- Parameters:
ctx- rule contextoutputType- type of rule output- Returns:
- rule result
-
apply
Description copied from interface:RuleExecutes the rule with a default timeout. -
apply
Description copied from interface:RuleExecutes the rule with a custom timeout. -
apply
Description copied from interface:RuleExecutes the rules and returns a result. -
apply
Description copied from interface:RuleExecutes the rules, with a custom timeout, and returns a result. -
getName
Description copied from interface:RuleGets the name of the rule. -
getClassification
Description copied from interface:RuleGets the classification of the rule.- Specified by:
getClassificationin interfaceRule- Returns:
- rule classification
-
getDependencies
Description copied from interface:RuleGets a set of rules for which this rule depends upon.- Specified by:
getDependenciesin interfaceRule- Returns:
- rule dependencies
-
getDescription
Description copied from interface:RuleGets the description of the rule.- Specified by:
getDescriptionin interfaceRule- Returns:
- rule description
-
getTags
Description copied from interface:RuleGets the rule's tags. -
getTimeout
Description copied from interface:RuleGets the timeout.- Specified by:
getTimeoutin interfaceRule- Returns:
- timeout
-
getMaxRetries
Description copied from interface:RuleGets the number of times the rule should be retried in the event of a failure.- Specified by:
getMaxRetriesin interfaceRule- Returns:
- max retries
-