T
- the type of object to checkAnyConstraint<T>
CategoryConstraintGroup
public class ConstraintGroup<T> extends AbstractConstraint<T>
Constructor | Description |
---|---|
ConstraintGroup() |
Creates a new
ConstraintGroup instance. |
Modifier and Type | Method | Description |
---|---|---|
void |
add(AnyConstraint<T> c) |
Adds a constraint to the group.
|
boolean |
check(ValidationContext context,
T object) |
Checks if the object conforms to the specific rule in the given context.
|
boolean |
contains(int errorCode) |
Checks if the errorCode is in the group.
|
boolean |
contains(AnyConstraint<T> c) |
Checks if the constraint is in the group.
|
AnyConstraint<T>[] |
getConstraints() |
Returns the members of the group.
|
int |
getConstraintsCount() |
Returns the number of constraints in this group
|
boolean |
remove(AnyConstraint<T> constraint) |
Removes the constraint from the group.
|
getErrorCode
public ConstraintGroup()
ConstraintGroup
instance.public boolean check(ValidationContext context, T object)
AnyConstraint
If the rule behaves different for each level/version, the level and version of the context will be used.
context
- the validation contextobject
- the object to validatefalse
if the object does not respect the constraintpublic void add(AnyConstraint<T> c)
The constraints are collected in a
Set
, so every constraint can only be added once.
c
- the constraint to addpublic boolean remove(AnyConstraint<T> constraint)
constraint
- the constraint to removetrue
if constraint was in this group and was removedpublic boolean contains(int errorCode)
Notice that every ConstraintGroup
uses the same error code
CoreSpecialErrorCodes.ID_GROUP
. Use
contains(AnyConstraint)
instead.
errorCode
- the error code to search fortrue
if the error code is in the groupcontains(AnyConstraint)
public boolean contains(AnyConstraint<T> c)
c
- the constraint to search fortrue
if the constraint is in the grouppublic AnyConstraint<T>[] getConstraints()
public int getConstraintsCount()