Class Reflections


  • public final class Reflections
    extends Object
    Reflection utilities.
    Author:
    Pete Muir, Martin Kouba
    • Method Detail

      • containsAnnotation

        public static boolean containsAnnotation​(Class<?> javaClass,
                                                 Class<? extends Annotation> requiredAnnotation)
      • cast

        public static <T> T cast​(Object obj)
      • isClassLoadable

        public static boolean isClassLoadable​(org.jboss.weld.resources.spi.ResourceLoader resourceLoader,
                                              String className)
        Parameters:
        resourceLoader -
        className -
        Returns:
        true if a class with the given name can be loaded, false otherwise
        See Also:
        loadClass(ResourceLoader, String)
      • loadClass

        public static <T> Class<T> loadClass​(org.jboss.weld.resources.spi.ResourceLoader resourceLoader,
                                             String className)
        Parameters:
        resourceLoader -
        className -
        Returns:
        the loaded class or null if the given class cannot be loaded
        See Also:
        classForName(ResourceLoader, String)
      • classForName

        public static <T> Class<T> classForName​(org.jboss.weld.resources.spi.ResourceLoader resourceLoader,
                                                String className)
        First try to load a class using the specified ResourceLoader. If not successful, try Class.forName(String) as a fallback.
        Parameters:
        resourceLoader -
        className -
        Returns:
        the loaded class
      • hasBeanDefiningMetaAnnotationSpecified

        public static boolean hasBeanDefiningMetaAnnotationSpecified​(Annotation[] annotations,
                                                                     Class<? extends Annotation> metaAnnotationType)
        Parameters:
        annotations -
        metaAnnotationType -
        Returns:
        true if any of the annotations specified has the given meta annotation type specified, false otherwise
      • containsAnnotations

        public static boolean containsAnnotations​(Annotation[] annotations,
                                                  Class<? extends Annotation> requiredAnnotation)
      • hasBeanDefiningAnnotation

        public static boolean hasBeanDefiningAnnotation​(Class<?> clazz,
                                                        Set<Class<? extends Annotation>> initialBeanDefiningAnnotations)