|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.springframework.rules.constraint.property.AbstractPropertyConstraint
org.springframework.rules.constraint.property.ConditionalPropertyConstraint
public class ConditionalPropertyConstraint
Provides a way to trigger rules for propertyB when propertyA satisfies a certain condition:
if (propertyA satisfies the conditional constraint) { check the rules for propertyB }with an optional part:
else { check the rules for propertyC }
More complex situations are possible by using compound constraints which leverages the previous to:
if (constraint(propertyA, propertyB,...) == true) { checkConstraint(property1, property2,...); } \\ optional part else { checkConstraint(propertyX, propertyY,...); }
This class can be compared to the IfTrue
class: it applies the same
pattern but on different properties instead of on a property value.
Constructor Summary | |
---|---|
ConditionalPropertyConstraint(PropertyConstraint ifConstraint,
PropertyConstraint thenConstraint)
|
|
ConditionalPropertyConstraint(PropertyConstraint ifConstraint,
PropertyConstraint thenConstraint,
PropertyConstraint elseConstraint)
|
|
ConditionalPropertyConstraint(PropertyConstraint ifConstraint,
PropertyConstraint thenConstraint,
PropertyConstraint elseConstraint,
String type)
Create a constraint which simulates the if...then...else pattern applied on separate properties. |
|
ConditionalPropertyConstraint(PropertyConstraint ifConstraint,
PropertyConstraint thenConstraint,
String type)
Create a constraint which simulates the if...then pattern applied on separate properties. |
Method Summary | |
---|---|
String |
getType()
Returns this object's logical type identifier. |
boolean |
isCompoundRule()
Does this property constraint effect more than one property? |
boolean |
isDependentOn(String propertyName)
Returns true if this property constraint is dependent on
the provided propertyName for test evaluation; that is, it should be retested
when propertyName changes. |
void |
setType(String type)
|
protected boolean |
test(PropertyAccessStrategy domainObjectAccessStrategy)
|
Methods inherited from class org.springframework.rules.constraint.property.AbstractPropertyConstraint |
---|
getPropertyName, setPropertyName, test, toString |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public ConditionalPropertyConstraint(PropertyConstraint ifConstraint, PropertyConstraint thenConstraint)
ConditionalPropertyConstraint(PropertyConstraint, PropertyConstraint, String)
public ConditionalPropertyConstraint(PropertyConstraint ifConstraint, PropertyConstraint thenConstraint, String type)
ifConstraint
- the PropertyConstraint that triggers the test
(satisfying a certain condition).thenConstraint
- the PropertyConstraint to test in the specified
condition.public ConditionalPropertyConstraint(PropertyConstraint ifConstraint, PropertyConstraint thenConstraint, PropertyConstraint elseConstraint)
ConditionalPropertyConstraint(PropertyConstraint, PropertyConstraint, PropertyConstraint, String)
public ConditionalPropertyConstraint(PropertyConstraint ifConstraint, PropertyConstraint thenConstraint, PropertyConstraint elseConstraint, String type)
ifConstraint
- the PropertyConstraint that triggers the test
(satisfying a certain condition).thenConstraint
- the PropertyConstraint to test in the specified
condition.elseConstraint
- the PropertyConstraint to test if the condition is
NOT satisfied. May be null
.type
- the messageCode used to fetch the message.Method Detail |
---|
public boolean isCompoundRule()
PropertyConstraint
isCompoundRule
in interface PropertyConstraint
isCompoundRule
in class AbstractPropertyConstraint
public boolean isDependentOn(String propertyName)
PropertyConstraint
true
if this property constraint is dependent on
the provided propertyName for test evaluation; that is, it should be retested
when propertyName changes.
isDependentOn
in interface PropertyConstraint
isDependentOn
in class AbstractPropertyConstraint
protected boolean test(PropertyAccessStrategy domainObjectAccessStrategy)
test
in class AbstractPropertyConstraint
public String getType()
TypeResolvable
getType
in interface TypeResolvable
public void setType(String type)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |