Interface ElementUtils

  • All Superinterfaces:
    Utils

    public interface ElementUtils
    extends Utils
    The utility class for Element
    Since:
    1.0.0
    Author:
    Mercy
    See Also:
    Element, Enum
    • Method Summary

      Static Methods 
      Modifier and Type Method Description
      static <E extends javax.lang.model.element.Element>
      java.util.List<E>
      filterElements​(java.util.List<E> elements, java.util.function.Predicate<? super E>... elementPredicates)  
      static boolean hasModifiers​(javax.lang.model.element.Element member, javax.lang.model.element.Modifier... modifiers)  
      static boolean isClass​(javax.lang.model.element.ElementKind kind)
      Returns true if this is a kind of class: either CLASS or ENUM or RECORD.
      static boolean isDeclaredType​(javax.lang.model.element.ElementKind kind)
      {@return {@code true} if this is a kind of declared type, a {@linkplain ElementKind#isClass() class} or an {@linkplain ElementKind#isInterface() interface}, and {@code false} otherwise}
      static boolean isExecutable​(javax.lang.model.element.ElementKind kind)
      Returns true if this is a kind of executable: either METHOD or CONSTRUCTOR or STATIC_INIT or INSTANCE_INIT.
      static boolean isField​(javax.lang.model.element.ElementKind kind)
      Returns true if this is a kind of field: either FIELD or ENUM_CONSTANT.
      static boolean isInitializer​(javax.lang.model.element.ElementKind kind)
      Returns true if this is a kind of initializer: either STATIC_INIT or INSTANCE_INIT.
      static boolean isInterface​(javax.lang.model.element.ElementKind kind)
      Returns true if this is a kind of interface: either INTERFACE or ANNOTATION_TYPE.
      static boolean isMember​(javax.lang.model.element.ElementKind kind)
      {@return {@code true} if this is a kind of {@linkplain ElementKind#isField() field} or {@linkplain ElementKind#isExecutable() executable}, and {@code false} otherwise}
      static boolean isPublicNonStatic​(javax.lang.model.element.Element member)  
      static boolean isVariable​(javax.lang.model.element.ElementKind kind)
      Returns true if this is a kind of variable: including ENUM_CONSTANT, FIELD, PARAMETER, LOCAL_VARIABLE, EXCEPTION_PARAMETER, RESOURCE_VARIABLE, and BINDING_VARIABLE.
      static boolean matchesElementKind​(javax.lang.model.element.Element member, javax.lang.model.element.ElementKind kind)  
      static boolean matchesElementType​(javax.lang.model.element.ElementKind elementKind, java.lang.annotation.ElementType elementType)
      Checks whether the specified ElementKind matches the specified ElementType.
      static boolean matchesElementType​(javax.lang.model.element.ElementKind elementKind, java.lang.annotation.ElementType... elementTypes)
      Checks whether the specified ElementKind matches any of the specified ElementTypes.
      static boolean matchesElementType​(javax.lang.model.element.Element element, java.lang.annotation.ElementType... elementTypes)
      Checks whether the specified Element matches the specified ElementType.
      static boolean matchParameterTypeNames​(java.util.List<? extends javax.lang.model.element.VariableElement> parameters, java.lang.CharSequence... parameterTypeNames)  
      static boolean matchParameterTypes​(java.util.List<? extends javax.lang.model.element.VariableElement> parameters, java.lang.reflect.Type... parameterTypes)  
      static boolean matchParameterTypes​(javax.lang.model.element.ExecutableElement executableElement, java.lang.reflect.Type... parameterTypes)  
      static javax.lang.model.element.ElementKind toElementKind​(java.lang.annotation.ElementType elementType)
      Converts the specified ElementType to an equivalent ElementKind.
    • Method Detail

      • isClass

        static boolean isClass​(javax.lang.model.element.ElementKind kind)
        Returns true if this is a kind of class: either CLASS or ENUM or RECORD.
        Returns:
        true if this is a kind of class
        See Also:
        ElementKind.isClass()
      • isInterface

        static boolean isInterface​(javax.lang.model.element.ElementKind kind)
        Returns true if this is a kind of interface: either INTERFACE or ANNOTATION_TYPE.
        Parameters:
        kind - ElementKind
        Returns:
        true if this is a kind of interface
      • isDeclaredType

        static boolean isDeclaredType​(javax.lang.model.element.ElementKind kind)
        {@return {@code true} if this is a kind of declared type, a {@linkplain ElementKind#isClass() class} or an {@linkplain ElementKind#isInterface() interface}, and {@code false} otherwise}
        Parameters:
        kind - ElementKind
        See Also:
        ElementKind#isDeclaredType()
      • isField

        static boolean isField​(javax.lang.model.element.ElementKind kind)
        Returns true if this is a kind of field: either FIELD or ENUM_CONSTANT.
        Parameters:
        kind - ElementKind
        Returns:
        true if this is a kind of field
        See Also:
        ElementKind.isField()
      • isExecutable

        static boolean isExecutable​(javax.lang.model.element.ElementKind kind)
        Returns true if this is a kind of executable: either METHOD or CONSTRUCTOR or STATIC_INIT or INSTANCE_INIT.
        Parameters:
        kind - ElementKind
        Returns:
        true if this is a kind of executable
        See Also:
        ElementKind#isExecutable()
      • isMember

        static boolean isMember​(javax.lang.model.element.ElementKind kind)
        {@return {@code true} if this is a kind of {@linkplain ElementKind#isField() field} or {@linkplain ElementKind#isExecutable() executable}, and {@code false} otherwise}
        Parameters:
        kind - ElementKind
        kind -
        Returns:
        See Also:
        ElementKind#isDeclaredType()
      • isInitializer

        static boolean isInitializer​(javax.lang.model.element.ElementKind kind)
        Returns true if this is a kind of initializer: either STATIC_INIT or INSTANCE_INIT.
        Parameters:
        kind - ElementKind
        Returns:
        true if this is a kind of initializer
        See Also:
        ElementKind#isInitializer()
      • isVariable

        static boolean isVariable​(javax.lang.model.element.ElementKind kind)
        Returns true if this is a kind of variable: including ENUM_CONSTANT, FIELD, PARAMETER, LOCAL_VARIABLE, EXCEPTION_PARAMETER, RESOURCE_VARIABLE, and BINDING_VARIABLE.
        Parameters:
        kind - ElementKind
        Returns:
        true if this is a kind of variable
        See Also:
        ElementKind#isVariable()
      • toElementKind

        static javax.lang.model.element.ElementKind toElementKind​(java.lang.annotation.ElementType elementType)
        Converts the specified ElementType to an equivalent ElementKind.

        If the provided elementType is null, this method returns ElementKind.OTHER.

        Parameters:
        elementType - the ElementType to convert, may be null
        Returns:
        the corresponding ElementKind, never null
      • matchesElementType

        static boolean matchesElementType​(javax.lang.model.element.ElementKind elementKind,
                                          java.lang.annotation.ElementType elementType)
        Checks whether the specified ElementKind matches the specified ElementType.
        Parameters:
        elementKind - the ElementKind to check
        elementType - the ElementType to check
        Returns:
        true if the ElementKind matches the ElementType, false otherwise
      • matchesElementType

        static boolean matchesElementType​(javax.lang.model.element.ElementKind elementKind,
                                          java.lang.annotation.ElementType... elementTypes)
        Checks whether the specified ElementKind matches any of the specified ElementTypes.
        Parameters:
        elementKind - the ElementKind to check
        elementTypes - the ElementTypes to check
        Returns:
        true if the ElementKind matches any of the ElementTypes, false otherwise
      • matchesElementType

        static boolean matchesElementType​(javax.lang.model.element.Element element,
                                          java.lang.annotation.ElementType... elementTypes)
        Checks whether the specified Element matches the specified ElementType.
        Parameters:
        element - the Element to check
        elementTypes - the ElementTypes to check
        Returns:
        true if the Element matches the ElementType, false otherwise
      • matchesElementKind

        static boolean matchesElementKind​(javax.lang.model.element.Element member,
                                          javax.lang.model.element.ElementKind kind)
      • isPublicNonStatic

        static boolean isPublicNonStatic​(javax.lang.model.element.Element member)
      • hasModifiers

        static boolean hasModifiers​(javax.lang.model.element.Element member,
                                    javax.lang.model.element.Modifier... modifiers)
      • filterElements

        static <E extends javax.lang.model.element.Element> java.util.List<E> filterElements​(java.util.List<E> elements,
                                                                                             java.util.function.Predicate<? super E>... elementPredicates)
      • matchParameterTypes

        static boolean matchParameterTypes​(javax.lang.model.element.ExecutableElement executableElement,
                                           java.lang.reflect.Type... parameterTypes)
      • matchParameterTypes

        static boolean matchParameterTypes​(java.util.List<? extends javax.lang.model.element.VariableElement> parameters,
                                           java.lang.reflect.Type... parameterTypes)
      • matchParameterTypeNames

        static boolean matchParameterTypeNames​(java.util.List<? extends javax.lang.model.element.VariableElement> parameters,
                                               java.lang.CharSequence... parameterTypeNames)