org.javalid.annotations.validation
Annotation Type EmptyOrNotEmptyAll


@Target(value=TYPE)
@Retention(value=RUNTIME)
@Documented
@Inherited
public @interface EmptyOrNotEmptyAll

Use this annotation to specify that methods and/or fields must be all EMPTY or NOT EMPTY. For instance: @EmptyOrNotEmpty(values="#{me.anotherProperty}","#{me.child.name}") means that both field/method's value must be non-empty or both must empty (empty as is defined below).

Can be applied to fields/methods of type: String, StringBuffer, StringBuilder, any array, java.utilMap (or subclasses) and java.util.Collection (or subclasses).

String/StringBuffer/StringBuilder are seen as empty if they are null, or contain no text (trim may or may not be applied). Arrays, maps and collections are seen as 'empty' if they have a size / length of 0.

It is recommended to use the customMessage attribute to define a useful message to present to your users.

Class level annotation!

Note: As this is a classlevel annotation the message is global by DEFAULT.

Since:
1.2
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.
 boolean trim
          Trim the String first, then check for non-empty.
 java.lang.String[] values
          Values is required.
 

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 (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.

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 true as this is a classlevel annotation.

Default:
true

values

public abstract java.lang.String[] values
Values is required. Set each entry to an expression that resolves to a method/field value. For example: {"#{me.anotherMethod}"}, where me refers to the object (class) itself (remember this is a class annotation).

You are recommended to specify a custom code message (for the sake of your users).

Default:
{}

trim

public abstract boolean trim
Trim the String first, then check for non-empty. Set to false if trim should not be done (not relevant for Collection or arrays).

Defaults to true.

Default:
true