Class Validator


  • public final class Validator
    extends java.lang.Object
    Date: 12.08.2011
    • Field Detail

      • AVAILABLE_LANGUAGES

        private static final java.util.Collection<java.lang.String> AVAILABLE_LANGUAGES
      • processingEnv

        private final javax.annotation.processing.ProcessingEnvironment processingEnv
      • elements

        private final javax.lang.model.util.Elements elements
      • types

        private final javax.lang.model.util.Types types
    • Constructor Detail

      • Validator

        public Validator​(javax.annotation.processing.ProcessingEnvironment processingEnv)
    • Method Detail

      • validate

        public final java.util.Collection<ValidationMessage> validate​(MessageInterface messageInterface)
        Validates the message interface and returns a collection of validation messages or an empty collection.
        Parameters:
        messageInterface - the message interface to validate.
        Returns:
        a collection of validation messages or an empty collection.
      • validateCommon

        private java.util.Collection<ValidationMessage> validateCommon​(MessageInterface messageInterface,
                                                                       java.util.Set<MessageMethod> messageMethods)
        Validate common attributes to all interfaces.
        Parameters:
        messageInterface - the interface.
        messageMethods - the messageMethods to validate.
        Returns:
        a collection of validation messages.
      • validateBundle

        private java.util.Collection<ValidationMessage> validateBundle​(java.util.Set<MessageMethod> messageMethods)
        Validate message bundle messageMethods.
        Parameters:
        messageMethods - the messageMethods to validate.
        Returns:
        a collection of the validation messages.
      • validateLogger

        private java.util.Collection<ValidationMessage> validateLogger​(java.util.Set<MessageMethod> messageMethods)
        Validate message logger messageMethods.
        Parameters:
        messageMethods - the messageMethods to validate.
        Returns:
        a collection of the validation messages.
      • getAllMethods

        private java.util.Set<MessageMethod> getAllMethods​(MessageInterface messageInterface)
        Finds all methods for the given interface, but ignores logger interface methods.
        Parameters:
        messageInterface - the interface to find all methods for.
        Returns:
        a set of all the methods (exception logger interface methods) the interface must implement.
      • isTypeAssignableFrom

        private boolean isTypeAssignableFrom​(javax.lang.model.element.Element element,
                                             java.lang.Class<?> type)
        Checks the element type, if an array the type of the array is checked, against the class. If the element type is assignable to the class type.
        Parameters:
        element - the element to test
        type - the type the element needs to be assignable to
        Returns:
        true if the element type is assignable to the class type, otherwise false
      • isTypeAssignableFrom

        private boolean isTypeAssignableFrom​(javax.lang.model.type.TypeMirror typeMirror,
                                             java.lang.Class<?> type)
        Checks the type, if an array the type of the array is checked, against the class. If the element type is assignable to the class type.
        Parameters:
        typeMirror - the type to test
        type - the type the element needs to be assignable to
        Returns:
        true if the element type is assignable to the class type, otherwise false
      • isTypeAssignableFrom

        private boolean isTypeAssignableFrom​(javax.lang.model.type.TypeMirror typeMirror,
                                             javax.lang.model.type.TypeMirror type)
        Checks the type, if an array the type of the array is checked, against the class. If the element type is assignable to the class type.
        Parameters:
        typeMirror - the type to test
        type - the type the element needs to be assignable to
        Returns:
        true if the element type is assignable to the class type, otherwise false