Class Classes


  • public class Classes
    extends java.lang.Object
    Since:
    0.5.0
    • Constructor Summary

      Constructors 
      Constructor Description
      Classes()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <T> java.lang.Class<T> forName​(java.lang.String fqcn)
      Attempts to load the specified class name from the current thread's context class loader, then the current ClassLoader (Classes.class.getClassLoader()), then the system/application ClassLoader (ClassLoader.getSystemClassLoader(), in that order.
      static <T> java.lang.reflect.Constructor<T> getConstructor​(java.lang.Class<T> clazz, java.lang.Class... argTypes)  
      static java.io.InputStream getResourceAsStream​(java.lang.String name)
      Returns the specified resource by checking the current thread's context class loader, then the current ClassLoader (Classes.class.getClassLoader()), then the system/application ClassLoader (ClassLoader.getSystemClassLoader(), in that order, using getResourceAsStream(name).
      static <T> T instantiate​(java.lang.reflect.Constructor<T> ctor, java.lang.Object... args)  
      static boolean isAvailable​(java.lang.String fullyQualifiedClassName)  
      static <T> T loadFromService​(java.lang.Class<T> clazz)  
      static <T> T loadFromService​(java.lang.Class<T> clazz, java.lang.String errorMessage)  
      static <T> T newInstance​(java.lang.Class<T> clazz)  
      static <T> T newInstance​(java.lang.Class<T> clazz, java.lang.Object... args)  
      static <T> T newInstance​(java.lang.String fqcn)  
      static <T> T newInstance​(java.lang.String fqcn, java.lang.Object... args)  
      • Methods inherited from class java.lang.Object

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

      • Classes

        public Classes()
    • Method Detail

      • forName

        public static <T> java.lang.Class<T> forName​(java.lang.String fqcn)
                                              throws UnknownClassException
        Attempts to load the specified class name from the current thread's context class loader, then the current ClassLoader (Classes.class.getClassLoader()), then the system/application ClassLoader (ClassLoader.getSystemClassLoader(), in that order. If any of them cannot locate the specified class, an UnknownClassException is thrown (our RuntimeException equivalent of the JRE's ClassNotFoundException.
        Type Parameters:
        T - type of class
        Parameters:
        fqcn - the fully qualified class name to load
        Returns:
        the located class
        Throws:
        UnknownClassException - if the class cannot be found.
      • getResourceAsStream

        public static java.io.InputStream getResourceAsStream​(java.lang.String name)
        Returns the specified resource by checking the current thread's context class loader, then the current ClassLoader (Classes.class.getClassLoader()), then the system/application ClassLoader (ClassLoader.getSystemClassLoader(), in that order, using getResourceAsStream(name).
        Parameters:
        name - the name of the resource to acquire from the classloader(s).
        Returns:
        the InputStream of the resource found, or null if the resource cannot be found from any of the three mentioned ClassLoaders.
      • isAvailable

        public static boolean isAvailable​(java.lang.String fullyQualifiedClassName)
      • newInstance

        public static <T> T newInstance​(java.lang.String fqcn)
      • newInstance

        public static <T> T newInstance​(java.lang.String fqcn,
                                        java.lang.Object... args)
      • newInstance

        public static <T> T newInstance​(java.lang.Class<T> clazz)
      • newInstance

        public static <T> T newInstance​(java.lang.Class<T> clazz,
                                        java.lang.Object... args)
      • getConstructor

        public static <T> java.lang.reflect.Constructor<T> getConstructor​(java.lang.Class<T> clazz,
                                                                          java.lang.Class... argTypes)
      • instantiate

        public static <T> T instantiate​(java.lang.reflect.Constructor<T> ctor,
                                        java.lang.Object... args)
      • loadFromService

        public static <T> T loadFromService​(java.lang.Class<T> clazz)
      • loadFromService

        public static <T> T loadFromService​(java.lang.Class<T> clazz,
                                            java.lang.String errorMessage)