Class JandexUtil


  • public final class JandexUtil
    extends Object
    A collection of Jandex utility methods.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static org.jboss.jandex.DotName DOTNAME_OBJECT  
      static org.jboss.jandex.DotName DOTNAME_RECORD  
    • Method Summary

      All Methods Static Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      static String getBoxedTypeName​(org.jboss.jandex.Type type)
      Deprecated, for removal: This API element is subject to removal in a future version.
      static org.jboss.jandex.ClassInfo getEnclosingClass​(org.jboss.jandex.AnnotationInstance annotationInstance)
      Returns the enclosing class of the given annotation instance.
      static boolean isSubclassOf​(org.jboss.jandex.IndexView index, org.jboss.jandex.ClassInfo info, org.jboss.jandex.DotName parentName)
      Returns true if the given Jandex ClassInfo is a subclass of the given parentName.
      static List<org.jboss.jandex.Type> resolveTypeParameters​(org.jboss.jandex.DotName input, org.jboss.jandex.DotName target, org.jboss.jandex.IndexView index)
      Returns the captured generic types of an interface given a class that at some point in the class hierarchy implements the interface.
    • Field Detail

      • DOTNAME_OBJECT

        public static final org.jboss.jandex.DotName DOTNAME_OBJECT
      • DOTNAME_RECORD

        public static final org.jboss.jandex.DotName DOTNAME_RECORD
    • Method Detail

      • resolveTypeParameters

        public static List<org.jboss.jandex.Type> resolveTypeParameters​(org.jboss.jandex.DotName input,
                                                                        org.jboss.jandex.DotName target,
                                                                        org.jboss.jandex.IndexView index)
        Returns the captured generic types of an interface given a class that at some point in the class hierarchy implements the interface. The list contains the types in the same order as they are generic parameters defined on the interface A result is only returned if and only if all the generics where captured. If any of them where not defined by the class an exception is thrown. Also note that all parts of the class/interface hierarchy must be in the supplied index As an example, imagine the following class:
        
         class MyList implements List<String> {
             ...
         }
        
         
        If we call
        
         JandexUtil.resolveTypeParameters(DotName.createSimple(MyList.class.getName()),
                 DotName.createSimple(List.class.getName()), index)
        
         
        then the result will contain a single element of class ClassType whose name() would return a DotName for String
      • getEnclosingClass

        public static org.jboss.jandex.ClassInfo getEnclosingClass​(org.jboss.jandex.AnnotationInstance annotationInstance)
        Returns the enclosing class of the given annotation instance. For field, method or record component annotations, this will return the enclosing class. For parameters, this will return the enclosing class of the enclosing method. For classes, it will return the class itself. For type annotations, it will return the class enclosing the annotated type usage.
        Parameters:
        annotationInstance - the annotation whose enclosing class to look up
        Returns:
        the enclosing class
      • isSubclassOf

        public static boolean isSubclassOf​(org.jboss.jandex.IndexView index,
                                           org.jboss.jandex.ClassInfo info,
                                           org.jboss.jandex.DotName parentName)
                                    throws BuildException
        Returns true if the given Jandex ClassInfo is a subclass of the given parentName. Note that this will not check interfaces.
        Parameters:
        index - the index to use to look up super classes.
        info - the ClassInfo we want to check.
        parentName - the name of the superclass we want to find.
        Returns:
        true if the given ClassInfo has parentName as a superclass.
        Throws:
        BuildException - if one of the superclasses is not indexed.
      • getBoxedTypeName

        @Deprecated(forRemoval=true,
                    since="2.13.3.Final")
        public static String getBoxedTypeName​(org.jboss.jandex.Type type)
        Deprecated, for removal: This API element is subject to removal in a future version.