Class ValidatorLibrary
java.lang.Object
name.matthewgreet.strutscommons.util.ValidatorLibrary
Static functions used by validators.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enum
static class
Describes a type of form field annotation and an instance of the policy it configures.static class
ValidatorLibrary.PolicyEntry<A extends Annotation,
P extends Policy<A>> Describes table entry that finds a policy class from the annotation class that configures it. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> boolean
checkCollectionRecipientDataType
(Field recipientField, Class<T> recipientClass) Returns whether converting validator can convert form field value to the recipient field's type.static boolean
checkFieldClass
(Class<?> conversionClass, Class<?> fieldClass) Returns whether a converter's target data type can convert to the form field's data type.static boolean
checkRecipientDataType
(Field recipientField, Class<?> recipientClass) Returns whether converting validator can convert form field value to the recipient field's type.static boolean
fieldIsNotForm
(Field actionField) Returns whether a viewer Action's member field is definitely not a form.static boolean
fieldReceivedStoredForm
(Field actionField) Returns whether field of an Action received a stored form.static void
formatForm
(Object form) Formats form fields from the associated, unformatted values.static void
Formats form fields of the current Action's forms, which are annotated withForm
, from the associated, unformatted values, except for any form that was retrieved and injected (usually a rejected form).static <T> ValidatorLibrary.AnnotationUsageResult
<T> getAnnotationUsage
(Annotation annotation) Returns validator (and formatter) that processes an annotated form field, or result of NA type if not recognised.static String
getDefaultRecipientName
(String fieldName) Returns the default field name to receive a converted form field.static List
<ValidatorLibrary.PolicyEntry<?, ?>> Returns list of all built-in adjusters, converters, and validators.static Collection
<Field> getProperties
(Class<?> type) Returns all properties of a class, whether directly declared or inherited.Returns a processed form stored in session.static <T> Class
<T> getTypeFromCollectionField
(Field recipientField) Returns element type of a collection-based form field.static <T> Collection
<T> makeCollectionForRecipient
(Class<?> recipientClass) Returns an empty, modifiable collection from a collection type.
-
Constructor Details
-
ValidatorLibrary
public ValidatorLibrary()
-
-
Method Details
-
checkFieldClass
Returns whether a converter's target data type can convert to the form field's data type. -
checkCollectionRecipientDataType
public static <T> boolean checkCollectionRecipientDataType(Field recipientField, Class<T> recipientClass) Returns whether converting validator can convert form field value to the recipient field's type. -
checkRecipientDataType
Returns whether converting validator can convert form field value to the recipient field's type. -
fieldIsNotForm
Returns whether a viewer Action's member field is definitely not a form. -
fieldReceivedStoredForm
Returns whether field of an Action received a stored form. -
getAnnotationUsage
public static <T> ValidatorLibrary.AnnotationUsageResult<T> getAnnotationUsage(Annotation annotation) throws Exception Returns validator (and formatter) that processes an annotated form field, or result of NA type if not recognised.- Throws:
Exception
-
getDefaultRecipientName
Returns the default field name to receive a converted form field. -
getProperties
Returns all properties of a class, whether directly declared or inherited. -
getStoredForm
Returns a processed form stored in session. -
getTypeFromCollectionField
Returns element type of a collection-based form field. -
getPolicies
Returns list of all built-in adjusters, converters, and validators. -
formatForm
Formats form fields from the associated, unformatted values. Form fields that have no associated, unformatted value are expected to be already set. SeeBooleanConversion
,EnumConversion
,IntegerConversion
etc. -
formatForms
public static void formatForms()Formats form fields of the current Action's forms, which are annotated withForm
, from the associated, unformatted values, except for any form that was retrieved and injected (usually a rejected form). Form fields that have no associated, unformatted value are expected to be already set. SeeBooleanConversion
,EnumConversion
,IntegerConversion
etc. -
makeCollectionForRecipient
Returns an empty, modifiable collection from a collection type.
-