org.javalid.annotations.validation
Annotation Type CollectionSize


@Target(value={METHOD,FIELD})
@Retention(value=RUNTIME)
@Documented
public @interface CollectionSize

This annotation can be used for size checks on java.util.Collection or java.util.Map related classes (e.g a list, map, tree ..), can be specified on get methods and fields. Specify the mode (defaults to equals) using one of the MODE_ constants. Read the docs with the constant to find out what else you need to fill in.

Since:
1.0
Version:
1.0
Author:
M.Reuvers

Optional Element Summary
 java.lang.String[] applyToGroups
          Specify for which groups this annotation must be applied.
 java.lang.String customCode
          Optional custom code (property from a properties file).
 boolean globalMessage
          If this annotation's message must be added as global message instead of real validation path.
 int maximumSize
          Maximum size of collection, only required/used if MODE_MAXIMUM or MODE_BETWEEN.
 int minimumSize
          Minimum size of collection, only required/used if MODE_MINIMUM or MODE_BETWEEN.
 int mode
          What mode the check is in, use one of the MODE constants defined in this class, defaults to MODE_EQUALS.
 int size
          Size of collection, only required/used if MODE_EQUALS.
 

mode

public abstract int mode
What mode the check is in, use one of the MODE constants defined in this class, defaults to MODE_EQUALS. Each mode requires other properties to be set, e.g the equals does require you to set size().

Default:
0

size

public abstract int size
Size of collection, only required/used if MODE_EQUALS.

Default:
1

minimumSize

public abstract int minimumSize
Minimum size of collection, only required/used if MODE_MINIMUM or MODE_BETWEEN.

Default:
1

maximumSize

public abstract int maximumSize
Maximum size of collection, only required/used if MODE_MAXIMUM or MODE_BETWEEN.

Default:
1

applyToGroups

public abstract java.lang.String[] applyToGroups
Specify for which groups this annotation must be applied. By default if you annotate without this variable, the annotation is applied for any group on that method / field (which is what you usually want). However by specifying the exact groups you can turn on/off a validation on a method depending on the group you validate. Defaults to JvGroup.GROUP_APPLY_ALL

Default:
"_all_"

customCode

public abstract java.lang.String customCode
Optional custom code (property from a properties file). If set, this one is used instead of the default one specified in MessageCodes for annotated method / field.

This way you can override the default message if needed.

Default:
""

globalMessage

public abstract boolean globalMessage
If this annotation's message must be added as global message instead of real validation path. Defaults to false (thus will be added with validation path if invalid).

Default:
false