ClassUtils

object ClassUtils

Functions

Link copied to clipboard
fun getStaticObjectOrNull(clazz: Class<*>, fieldName: String): Any?

Get the static object

Link copied to clipboard
fun <T> getStaticObjectOrNullAs(clazz: Class<*>, fieldName: String): T?

Get the static object, and trying to cast to the T type

Link copied to clipboard
fun getStaticObjectOrNullUntilSuperclass(clazz: Class<*>, fieldName: String, untilSuperClass: Class<*>.() -> Boolean? = null): Any?

Get the static object

Link copied to clipboard
fun <T> getStaticObjectOrNullUntilSuperclassAs(clazz: Class<*>, fieldName: String, untilSuperClass: Class<*>.() -> Boolean? = null): T?

Get the static object, and trying to cast to the T type

Link copied to clipboard
fun invokeStaticMethod(clz: Class<*>, methodName: String, returnType: Class<*>? = null, paramTypes: ParamTypes, params: Params): Any?

Invoke the static method in the class

Link copied to clipboard
fun invokeStaticMethodBestMatch(clz: Class<*>, methodName: String, returnType: Class<*>? = null, vararg params: Any?): Any?

Invoke the static method(best match params) in the class

Link copied to clipboard

Check if two classes are equal or match the same primitive type

Link copied to clipboard
fun loadClass(className: String, cl: ClassLoader? = null): Class<*>

Load the class or throw exception if not found

Link copied to clipboard
fun loadClassOrNull(className: String, cl: ClassLoader? = null): Class<*>?

Load the class or null if not found

Link copied to clipboard
fun loadFirstClass(vararg className: String): Class<*>
fun loadFirstClass(cl: ClassLoader, vararg className: String): Class<*>

Load the first exists class or throw exception all not found

Link copied to clipboard
fun loadFirstClassOrNull(vararg className: String): Class<*>?
fun loadFirstClassOrNull(cl: ClassLoader, vararg className: String): Class<*>?

Load the first exists class or null

Link copied to clipboard
fun newInstance(clz: Class<*>, paramTypes: ParamTypes = paramTypes(), params: Params = params()): Any

Create a new instance of the class

Link copied to clipboard
fun newInstanceBestMatch(clz: Class<*>, vararg params: Any?): Any

Create a new instance of the class

Link copied to clipboard
fun setStaticObject(clazz: Class<*>, fieldName: String, value: Any?)

Set the static object

Link copied to clipboard
fun setStaticObjectUntilSuperclass(clazz: Class<*>, fieldName: String, value: Any?, untilSuperClass: Class<*>.() -> Boolean? = null)

Set the static object

Link copied to clipboard

Cast class to primitive type if possible