org.javalid.annotations.core
Annotation Type JvGroup


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

Group annotation which specifies 1 or more groups and also automatically assures the method is validated. Specify on getXXX() methods. Thus a method *must* have this annotation if it requires validation (whatever that may be)

Maximum 1 annotation per method (same method in parent class can have 1 too).

Since:
1.0
Version:
1.0
Author:
M.Reuvers

Optional Element Summary
 java.lang.String[] disableRecursionForGroups
          You can disable recursion for a method by specifying which validation group(s) must NOT recurse, in other words: The validator will not recurse (thus validate the methods' return value) for the group in this array.
 boolean exposeInSubClass
          If set to true, it means that if a class specifies a JvGroup on one of its methods, its subclasses that override such method will be validated automatically too.
 java.lang.String[] groups
          Name of group, defaults to a group called 1.
 

groups

public abstract java.lang.String[] groups
Name of group, defaults to a group called 1. So you can quickly create a default group without specifying a groups. However as soon as you need different groups its recommended to specify all groups.

Defaults to JvGroup.DEFAULT_GROUP (1).

Default:
"1"

disableRecursionForGroups

public abstract java.lang.String[] disableRecursionForGroups
You can disable recursion for a method by specifying which validation group(s) must NOT recurse, in other words: The validator will not recurse (thus validate the methods' return value) for the group in this array. By default recursion takes place always when recursionLevel > 1 and a method is annotated with JvGroup (this annotation). Obviously if you use a validate(..) method without recursion, no recursion is done irrelevant of this property.

Use GROUP_APPLY_ALL of this annotation to disable any recursion for this method for all validation groups.

Note: If a group is specified in an inheritance relationship the most specialized class's groups disableRecursionForGroups() is taken. Assume: B extends A, on A you have a method with JvGroup telling recursion for group 1 is disabled, in B you have the same method telling recursion is allowed -> recursion is allowed then if you validate an instance of B. When you validate an instance of A, recursion is disabled for group 1, as A is now the 'highest' object.

Defaults to empty array (thus nothing is disabled).

Default:
{}

exposeInSubClass

public abstract boolean exposeInSubClass
If set to true, it means that if a class specifies a JvGroup on one of its methods, its subclasses that override such method will be validated automatically too. If not, one needs to specify JvGroup again. It's recommended to leave this to false unless you *know* what you are doing. Annotations defined on the same method as this group, and exposeInSubClass=true are visible in subclasses too, hence will be validated. Annotations where exposeSubClass of group is false are NOT visible for subclasses.

Defaults to false.

Default:
false