public class ConstraintStateUtils extends Object
Constructor and Description |
---|
ConstraintStateUtils() |
Modifier and Type | Method and Description |
---|---|
static boolean |
constraintAppliesForState(String applicableState,
Constraint constraint,
StateMapping stateMapping)
Determines if the constraint passed in applies for the applicableState, based on the stateMapping
|
static <T extends Constraint> |
getApplicableConstraint(T constraint,
String validationState,
StateMapping stateMapping)
Gets the constraint that applies for the validationState passed in with the appropriate StateMapping (which
should include validationState as one of its states).
|
static String |
getClientViewValidationState(Object model,
View view)
Gets the client validation state.
|
public ConstraintStateUtils()
public static boolean constraintAppliesForState(String applicableState, Constraint constraint, StateMapping stateMapping)
Note: this method will automatically return TRUE if the stateMapping is null, the Constraint is not a BaseConstraint, if there are no states defined on the Constraint, or if the state it applies to cannot be found in the stateMapping, because in all these cases the Constraint is considered stateless and will apply to any state
applicableState
- the state to check to see if the constraint appliesconstraint
- the Constraint to checkstateMapping
- the StateMapping object containing state informationpublic static <T extends Constraint> T getApplicableConstraint(T constraint, String validationState, StateMapping stateMapping)
This method will essentially return the constraint passed in, in most cases, if the constraint applies. In cases where there are constraintStateOverrides set for the constraint, those will be evaluated to get the appropriate replacement. If the constraint does not apply for the validationState (as well as none of the replacements), this method will return null. If stateMapping passed in is null, the constraint is not a BaseConstraint, or validationState is blank, the original constraint will be returned (assumed stateless).
T
- constraint typeconstraint
- the original constraintvalidationState
- the validation statestateMapping
- the state information for the model being evaluatedRuntimeException
- if the type of constraint passed in cannot be cast to the replacement constraintpublic static String getClientViewValidationState(Object model, View view)
model
- view
- Copyright © 2005–2016 The Kuali Foundation. All rights reserved.