Class MoreTypes


  • public final class MoreTypes
    extends java.lang.Object
    More utility methods for types.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static javax.lang.model.type.ExecutableType asExecutable​(javax.lang.model.type.TypeMirror maybeExecutableType)
      Returns a ExecutableType if the TypeMirror represents an executable type such as a method, constructor, or initializer or throws an IllegalArgumentException.
      static javax.lang.model.element.TypeElement asTypeElement​(javax.lang.model.type.DeclaredType type)
      Returns the TypeElement corresponding to a DeclaredType.
      static javax.lang.model.element.TypeElement asTypeElement​(javax.lang.model.type.TypeMirror type)
      Returns the TypeElement corresponding to a TypeMirror.
      static java.util.Optional<javax.lang.model.element.ExecutableElement> findInheritedMethod​(javax.lang.model.util.Types types, javax.lang.model.element.TypeElement classElement, javax.lang.model.element.ExecutableElement method)
      Returns the first matching method, if one exists (starting with classElement, then searching each sub classes).
      static java.util.Optional<javax.lang.model.element.ExecutableElement> findMethod​(javax.lang.model.util.Types types, javax.lang.model.element.TypeElement classElement, javax.lang.model.element.ExecutableElement method)
      Returns a method with a matching signature in classElement if one exists.
      static java.util.Set<javax.lang.model.element.ExecutableElement> findMethods​(javax.lang.model.element.TypeElement classElement, java.lang.String name)
      Returns methods with a matching name in classElement.
      static javax.lang.model.type.DeclaredType getDeclaredType​(javax.lang.model.type.TypeMirror type)
      If the received mirror represents a declared type or an array of declared types, this returns the represented declared type.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • getDeclaredType

        public static javax.lang.model.type.DeclaredType getDeclaredType​(javax.lang.model.type.TypeMirror type)
        If the received mirror represents a declared type or an array of declared types, this returns the represented declared type. Otherwise throws an IllegalStateException.
      • asTypeElement

        public static javax.lang.model.element.TypeElement asTypeElement​(javax.lang.model.type.TypeMirror type)
        Returns the TypeElement corresponding to a TypeMirror.
      • asTypeElement

        public static javax.lang.model.element.TypeElement asTypeElement​(javax.lang.model.type.DeclaredType type)
        Returns the TypeElement corresponding to a DeclaredType.
      • asExecutable

        public static javax.lang.model.type.ExecutableType asExecutable​(javax.lang.model.type.TypeMirror maybeExecutableType)
        Returns a ExecutableType if the TypeMirror represents an executable type such as a method, constructor, or initializer or throws an IllegalArgumentException.
      • findInheritedMethod

        public static java.util.Optional<javax.lang.model.element.ExecutableElement> findInheritedMethod​(javax.lang.model.util.Types types,
                                                                                                         javax.lang.model.element.TypeElement classElement,
                                                                                                         javax.lang.model.element.ExecutableElement method)
        Returns the first matching method, if one exists (starting with classElement, then searching each sub classes).
      • findMethod

        public static java.util.Optional<javax.lang.model.element.ExecutableElement> findMethod​(javax.lang.model.util.Types types,
                                                                                                javax.lang.model.element.TypeElement classElement,
                                                                                                javax.lang.model.element.ExecutableElement method)
        Returns a method with a matching signature in classElement if one exists.
      • findMethods

        public static java.util.Set<javax.lang.model.element.ExecutableElement> findMethods​(javax.lang.model.element.TypeElement classElement,
                                                                                            java.lang.String name)
        Returns methods with a matching name in classElement.