Package com.okta.commons.lang
Class Classes
- java.lang.Object
-
- com.okta.commons.lang.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'scontext 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.InputStreamgetResourceAsStream(java.lang.String name)Returns the specified resource by checking the current thread'scontext class loader, then the current ClassLoader (Classes.class.getClassLoader()), then the system/application ClassLoader (ClassLoader.getSystemClassLoader(), in that order, usinggetResourceAsStream(name).static <T> Tinstantiate(java.lang.reflect.Constructor<T> ctor, java.lang.Object... args)static booleanisAvailable(java.lang.String fullyQualifiedClassName)static <T> TloadFromService(java.lang.Class<T> clazz)static <T> TloadFromService(java.lang.Class<T> clazz, java.lang.String errorMessage)static <T> TnewInstance(java.lang.Class<T> clazz)static <T> TnewInstance(java.lang.Class<T> clazz, java.lang.Object... args)static <T> TnewInstance(java.lang.String fqcn)static <T> TnewInstance(java.lang.String fqcn, java.lang.Object... args)
-
-
-
Method Detail
-
forName
public static <T> java.lang.Class<T> forName(java.lang.String fqcn) throws UnknownClassExceptionAttempts to load the specified class name from the current thread'scontext 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, anUnknownClassExceptionis thrown (our RuntimeException equivalent of the JRE'sClassNotFoundException.- 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'scontext class loader, then the current ClassLoader (Classes.class.getClassLoader()), then the system/application ClassLoader (ClassLoader.getSystemClassLoader(), in that order, usinggetResourceAsStream(name).- Parameters:
name- the name of the resource to acquire from the classloader(s).- Returns:
- the InputStream of the resource found, or
nullif 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)
-
-