Package com.tnsai.context.decision
Class DecisionPolicy
java.lang.Object
com.tnsai.context.decision.DecisionPolicy
Represents the rules and policies that guided a decision.
DecisionPolicy captures which business rules, guidelines, or constraints influenced the decision. This enables understanding why certain choices were made over others.
Usage Example
DecisionPolicy policy = DecisionPolicy.builder()
.rule("Max discount for premium customers is 25%")
.rule("Discounts over $100 require manager approval")
.guideline("Prefer customer retention over short-term profit")
.constraint("Total discount cannot exceed order margin")
.build();
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBuilder for DecisionPolicy.static final recordRepresents a policy rule. -
Method Summary
Modifier and TypeMethodDescriptionstatic DecisionPolicy.Builderbuilder()Creates a new builder.static DecisionPolicyempty()Creates an empty policy (no rules).getParameter(String key) Gets a parameter value.intReturns the total policy element count.getRules()getRulesByCategory(String category) Finds rules by category.booleanReturns true if there are any constraints.booleanReturns true if any rules were overridden.toString()
-
Method Details
-
builder
Creates a new builder. -
empty
Creates an empty policy (no rules). -
getRules
-
getGuidelines
-
getConstraints
-
getAppliedRules
-
getOverriddenRules
-
getParameters
-
getParameter
Gets a parameter value.- Parameters:
key- parameter key- Returns:
- Optional containing the value if present
-
getRulesByCategory
Finds rules by category.- Parameters:
category- rule category- Returns:
- list of rules in that category
-
hasOverrides
public boolean hasOverrides()Returns true if any rules were overridden. -
hasConstraints
public boolean hasConstraints()Returns true if there are any constraints. -
getPolicyCount
public int getPolicyCount()Returns the total policy element count. -
toString
-