Class ValidatorLibrary

java.lang.Object
name.matthewgreet.strutscommons.util.ValidatorLibrary

public class ValidatorLibrary extends Object
Static functions used by validators.
  • Constructor Details

    • ValidatorLibrary

      public ValidatorLibrary()
  • Method Details

    • checkFieldClass

      public static boolean checkFieldClass(Class<?> conversionClass, Class<?> fieldClass)
      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

      public static boolean checkRecipientDataType(Field recipientField, Class<?> recipientClass)
      Returns whether converting validator can convert form field value to the recipient field's type.
    • fieldIsNotForm

      public static boolean fieldIsNotForm(Field actionField)
      Returns whether a viewer Action's member field is definitely not a form.
    • fieldReceivedStoredForm

      public static boolean fieldReceivedStoredForm(Field actionField)
      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

      public static String getDefaultRecipientName(String fieldName)
      Returns the default field name to receive a converted form field.
    • getProperties

      public static Collection<Field> getProperties(Class<?> type)
      Returns all properties of a class, whether directly declared or inherited.
    • getStoredForm

      public static FormStoreInterceptor.StoredForm getStoredForm()
      Returns a processed form stored in session.
    • getTypeFromCollectionField

      public static <T> Class<T> getTypeFromCollectionField(Field recipientField)
      Returns element type of a collection-based form field.
    • getPolicies

      public static List<ValidatorLibrary.PolicyEntry<?,?>> getPolicies()
      Returns list of all built-in adjusters, converters, and validators.
    • formatForm

      public static void formatForm(Object form)
      Formats form fields from the associated, unformatted values. Form fields that have no associated, unformatted value are expected to be already set. See BooleanConversion, EnumConversion, IntegerConversion etc.
    • formatForms

      public static void formatForms()
      Formats form fields of the current Action's forms, which are annotated with Form, 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. See BooleanConversion, EnumConversion, IntegerConversion etc.
    • makeCollectionForRecipient

      public static <T> Collection<T> makeCollectionForRecipient(Class<?> recipientClass)
      Returns an empty, modifiable collection from a collection type.