Package com.vaadin.flow.server.startup
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:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static String
ERROR_MESSAGE_BEGINNING
static String
MIDDLE_ROUTER_LAYOUT
static String
NON_PARENT
static String
NON_PARENT_ALIAS
static String
NON_ROUTER_LAYOUT
-
Constructor Summary
Constructors Constructor Description AbstractAnnotationValidator()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract List<Class<?>>
getAnnotations()
Gets the annotations that are subject to validate.protected String
getClassAnnotations(Class<?> clazz)
Returns the validation annotations declared for theclazz
.static String
getClassAnnotations(Class<?> clazz, List<Class<?>> annotations)
Returns annotations declared for theclazz
.protected String
getErrorHint()
Returns a hint for the discovered validation errors.protected Optional<String>
handleNonRouterLayout(Class<?> clazz)
Handles theclazz
which is not a top level route and not a router layout.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.protected void
validateClasses(Collection<Class<?>> classSet)
Validate the correctness of the annotations returned by thegetAnnotations()
method applied to theclassSet
.
-
-
-
Field Detail
-
ERROR_MESSAGE_BEGINNING
public static final String ERROR_MESSAGE_BEGINNING
- See Also:
- Constant Field Values
-
NON_PARENT
public static final String NON_PARENT
- See Also:
- Constant Field Values
-
NON_PARENT_ALIAS
public static final String NON_PARENT_ALIAS
- See Also:
- Constant Field Values
-
NON_ROUTER_LAYOUT
public static final String NON_ROUTER_LAYOUT
- See Also:
- Constant Field Values
-
MIDDLE_ROUTER_LAYOUT
public static final String MIDDLE_ROUTER_LAYOUT
- See Also:
- Constant Field Values
-
-
Method Detail
-
validateClasses
protected void validateClasses(Collection<Class<?>> classSet)
Validate the correctness of the annotations returned by thegetAnnotations()
method applied to theclassSet
.- 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 theclazz
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 theclazz
.- 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 theclazz
.- Parameters:
clazz
- the typeannotations
- 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 filterhandlesTypesAnnotated
- the object with a @HandlesTypes annotation- Returns:
- a filtered set of classes
-
-