Class AbstractAnnotationValidator

java.lang.Object
com.vaadin.flow.server.startup.AbstractAnnotationValidator
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
AnnotationValidator, WebComponentExporterAwareValidator

public abstract class AbstractAnnotationValidator extends Object implements Serializable
Validation class that contains common logic to checks that specific annotations are not configured wrong.

For internal use only. May be renamed or removed in a future release.

Since:
1.0
See Also:
  • Field Details

  • Constructor Details

    • AbstractAnnotationValidator

      public AbstractAnnotationValidator()
  • Method Details

    • validateClasses

      protected void validateClasses(Collection<Class<?>> classSet)
      Validate the correctness of the annotations returned by the getAnnotations() method applied to the classSet.
      Parameters:
      classSet - the classes to validate
    • getAnnotations

      protected abstract List<Class<?>> getAnnotations()
      Gets the annotations that are subject to validate.
      Returns:
      a list of target annotations
    • handleNonRouterLayout

      protected Optional<String> handleNonRouterLayout(Class<?> clazz)
      Handles the clazz which is not a top level route and not a router layout. Returns an optional message which describes the error having an annotation for the class.
      Parameters:
      clazz - class to validate annotations
      Returns:
      an optional error message or empty if there is no error
    • getErrorHint

      protected String getErrorHint()
      Returns a hint for the discovered validation errors.
      Returns:
      the error hint
    • getClassAnnotations

      protected String getClassAnnotations(Class<?> clazz)
      Returns the validation annotations declared for the clazz.
      Parameters:
      clazz - the type to get validation annotations
      Returns:
      comma separated list of validation annotation declared for the clazz
    • getClassAnnotations

      public static String getClassAnnotations(Class<?> clazz, List<Class<?>> annotations)
      Returns annotations declared for the clazz.
      Parameters:
      clazz - the type
      annotations - the annotation list
      Returns:
      a comma separated string with the annotation names
    • removeHandleTypesSelfReferences

      public static Set<Class<?>> removeHandleTypesSelfReferences(Set<Class<?>> classSet, Object handlesTypesAnnotated)
      Filters the given set and removes classes (interfaces) which are mentioned in a @HandlesTypes annotation on the given object.
      Parameters:
      classSet - the classes to filter
      handlesTypesAnnotated - the object with a @HandlesTypes annotation
      Returns:
      a filtered set of classes