Package rife.validation
Class ConstrainedBean
java.lang.Object
rife.validation.ConstrainedBean
A
ConstrainedBean
object makes it possible to define all
constraints for a bean instance that are not related to a single property.
The constraints here are global for the entire bean and either involve
several properties or are even totally unrelated to properties.
It's possible to add constraints to a ConstrainedBean instance through regular setters, but chainable setters are also available to make it possible to easily define a series of constraints, for example:
var constrained = new ConstrainedBean() .unique("firstName", "lastName") .defaultOrder("city") .defaultOrder("lastName") .defaultOrder("firstName");
A constrained bean is typically added to a Constrained
bean in
its constructor. These are the static constraints that will be set for each
and every instance of the bean. You'll however most of the time use the
Validation
abstract class that provides the activateValidation
method which initializes
the constraints on a need-to-have basis. This dramatically reduces memory
usage since otherwise all constraints will be initialized for every bean
instance, even though you don't use them.
- Since:
- 1.0
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
static class
-
Field Summary
Modifier and TypeFieldDescriptionstatic final ConstrainedBean.Direction
static final String
static final String
static final ConstrainedBean.Direction
static final String
static final String
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionassociations
(Class... associations) defaultOrder
(String propertyName) defaultOrder
(String propertyName, ConstrainedBean.Direction direction) defaultOrdering
(List<ConstrainedBean.Order> ordering) Class[]
boolean
boolean
boolean
boolean
void
setAssociations
(Class... associations) void
setDefaultOrdering
(List<ConstrainedBean.Order> ordering) void
setTextualIdentifier
(TextualIdentifierGenerator identifier) void
setUniques
(List<String[]> unique) textualIdentifier
(TextualIdentifierGenerator identifier)
-
Field Details
-
ASC
-
DESC
-
ASSOCIATIONS
- See Also:
-
UNIQUE
- See Also:
-
TEXTUAL_IDENTIFIER
- See Also:
-
DEFAULT_ORDERING
- See Also:
-
constraints_
-
-
Constructor Details
-
ConstrainedBean
public ConstrainedBean()Creates a newConstrainedBean
.- Since:
- 1.0
-
-
Method Details
-
associations
-
setAssociations
-
getAssociations
-
hasAssociations
public boolean hasAssociations() -
unique
-
uniques
-
setUniques
-
getUniques
-
hasUniques
public boolean hasUniques() -
textualIdentifier
-
setTextualIdentifier
-
getTextualIdentifier
-
hasTextualIdentifier
public boolean hasTextualIdentifier() -
defaultOrder
-
defaultOrder
-
defaultOrder
-
defaultOrdering
-
setDefaultOrdering
-
getDefaultOrdering
-
hasDefaultOrdering
public boolean hasDefaultOrdering()
-