public class ConstraintGroup<T> extends AbstractConstraint<T>
Modifier and Type | Field and Description |
---|---|
private java.util.Set<AnyConstraint<T>> |
constraints |
Constructor and Description |
---|
ConstraintGroup() |
Modifier and Type | Method and 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(AnyConstraint<T> c)
Checks if the constraint is in the group.
|
boolean |
contains(int errorCode)
Checks if the errorCode 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
private java.util.Set<AnyConstraint<T>> constraints
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.
public void add(AnyConstraint<T> c)
Set
, so every constraint can only added onces.c
- public boolean remove(AnyConstraint<T> constraint)
constraint
- true
if constraint was in grouppublic boolean contains(int errorCode)
Notice that every ConstraintGroup
uses the same error code
CoreSpecialErrorCodes.ID_GROUP
. Use
contains(AnyConstraint)
instead.
errorCode
- true
if the error code is in the groupcontains(AnyConstraint)
public boolean contains(AnyConstraint<T> c)
c
- public AnyConstraint<T>[] getConstraints()
public int getConstraintsCount()