org.javalid.annotations.validation
Annotation Type LovConstraint


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

Checks if annotated method returns a value that is either 'in' or 'not in' the Lov (List Of Values). The Lov supports dynamic retrieval of its values through the use of @Lookup. Please check the documentation of the properties of this annotations for details.

Note you can also use this annotation to see if a method's return value simply equals another value (or not), just let the lov have just 1 value then (array of size 1 or collection of size 1).

Since:
1.0
Version:
1.0
Author:
M.Reuvers
See Also:
Lookup

Optional Element Summary
 java.lang.String[] applyToGroups
          Specify for which groups this annotation must be applied.
 java.lang.String customCodeLovIn
          Optional custom code (property from a properties file) for operator=LovConstraint.OPERATOR_IN.
 java.lang.String customCodeLovNotIn
          Optional custom code (property from a properties file) for operator=LovConstraint.OPERATOR_NOT_IN.
 boolean dynamic
          If set to true, you must specify the lookup property of this annotation where to get the values from (hence it is dynamic).
 boolean globalMessage
          If this annotation's message must be added as global message instead of real validation path.
 Lookup lookup
          You can specify what must be used to lookup an array or collection for the LovConstraint (if dynamic=true).
 int operator
          The operator represents how to check the value against the lov annotations values.
 java.lang.String type
          The type that should be used for the values[] property during validation.
 java.lang.String[] values
          The values in the LOV.
 

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_"

operator

public abstract int operator
The operator represents how to check the value against the lov annotations values.

Valid values are: Use one of the constants OPERATOR_* of this class.

Default value is Lov.OPERATOR_IN.

Default:
0

values

public abstract java.lang.String[] values
The values in the LOV. Each value is represented as a String, however you can support any primitive type - if you set the type property of this annotation. Note that each value in the array is assumed to have the SAME type as the methods return value as 'equals' will be used for comparison.

For instance if your method returns java.lang.Integer, the values in this array must be convertable to type java.lang.Integer.

If you want dynamic input for your Lov, set dynamic property to true (and read there for info), you should not use this property in that case.

Default value is an empty array.

Default:
{}

type

public abstract java.lang.String type
The type that should be used for the values[] property during validation. Type is relevant for the values[] property. You can use any primitive related ones: And the primitive equivalents (byte,short,int,long,float,double)

Default value is java.lang.String.

Default:
"java.lang.String"

dynamic

public abstract boolean dynamic
If set to true, you must specify the lookup property of this annotation where to get the values from (hence it is dynamic). If set to false you must specify the values property instead.

Default value is false.

Default:
false

lookup

public abstract Lookup lookup
You can specify what must be used to lookup an array or collection for the LovConstraint (if dynamic=true).

Whatever lookup you choose, the object being returned by the lookup (either the object iself or the method being called on that object), it must return one of: java.util.Collection (any class implementing this interface) or a real array (Object[], String[] etc.).

Note that the array must return actual objects, thus no primitive array! The latter is currently NOT supported. For the collection an iterator is created, and traversed that way. The array is traversed as an array.

Default value is useless, change if required.

Default:
@org.javalid.annotations.helper.Lookup

customCodeLovIn

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

This way you can override the default message if needed.

Default:
""

customCodeLovNotIn

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

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