Skip to content

Package io.github.qishr.cascara.common.util

Class ReflectionUtils

java.lang.Object
        io.github.qishr.cascara.common.util.ReflectionUtils


public class ReflectionUtils

Constructor Summary

Constructor Description
ReflectionUtils()

Method Summary

Modifier and Type Method Description
public static T createInstanceUnsafe(Class clazz)
public static C createInstance(Class targetClass)
public static boolean isAbstract(Type jvmType)
public static boolean isInterface(Type jvmType)
public static boolean isWildcard(Type jvmType)
public static boolean isConcreteType(Type jvmType)
public static boolean isInstance(Object thisInstance, Type thatType)
public static boolean canAssign(Type fromThis, Class<?> toThat)
public static C getRawClass(Type jvmType)
public static Type getKeyTypeOfMapType(Type mapType)
public static Type getValueTypeOfMapType(Type mapType)
public static Type getElementTypeOfCollectionType(Type collectionType)
public static Type getEnumType(Type jvmType) Unboxes a single-type parameter wrapper (such as Enum) to expose the underlying type argument, or passes the type through as-is if unparameterized.
public static Type getTypeArgumentTypeOfGenericType(Type jvmType, int paramIndex)
public static Class<?> getArrayComponentType(Type targetType)
public static String getEffectiveName(Field field)
public static List<Field> getAllFields(Class<?> clazz)
public static List<Field> getAllFields(Class<?> clazz, Function<Field, Boolean> excludeFunction)
public static List<Method> getAllMethods(Class<?> jvmType)
public static Set<Class<?>> getReferencedClasses(Class<?> clazz)
public static Set<Class<?>> getReferencedClasses(Class<?> clazz, Set<String> excludeFunction)
public static Set<Class<?>> getReferencedClasses(Class<?> clazz, Function<Class<?>, Boolean> excludeFunction)
public static String getTypeName(Type jvmType)
public static Pair<Class<?>, String> getCaller()
public static Pair<Class<?>, String> getCaller(boolean ignoreQueryingClass)
public static Pair<Class<?>, String> getCaller(boolean ignoreQueryingClass, boolean ignoreQueryingModule)
public static java.lang.@io.github.qishr.cascara.common.annotation.Experimental String getTestName()
public static java.lang.reflect.@io.github.qishr.cascara.common.annotation.Experimental Method getTestMethod()
public static List<Method> getMethodsByName(Class<?> clazz, String name)

Method Details

createInstanceUnsafe

public static T createInstanceUnsafe(Class clazz)

Throws:

InstantiationException


createInstance

public static C createInstance(Class targetClass)

Throws:

InstantiationException , IllegalAccessException , IllegalArgumentException , InvocationTargetException , SecurityException


isAbstract

public static boolean isAbstract(Type jvmType)


isInterface

public static boolean isInterface(Type jvmType)


isWildcard

public static boolean isWildcard(Type jvmType)


isConcreteType

public static boolean isConcreteType(Type jvmType)


isInstance

public static boolean isInstance(Object thisInstance, Type thatType)


canAssign

public static boolean canAssign(Type fromThis, Class<?> toThat)


getRawClass

@io.github.qishr.cascara.common.annotation.NonNull
public static C getRawClass(Type jvmType)


getKeyTypeOfMapType

@io.github.qishr.cascara.common.annotation.NonNull
public static Type getKeyTypeOfMapType(Type mapType)


getValueTypeOfMapType

@io.github.qishr.cascara.common.annotation.NonNull
public static Type getValueTypeOfMapType(Type mapType)


getElementTypeOfCollectionType

@io.github.qishr.cascara.common.annotation.NonNull
public static Type getElementTypeOfCollectionType(Type collectionType)


getEnumType

public static Type getEnumType(Type jvmType)

Unboxes a single-type parameter wrapper (such as Enum) to expose the underlying type argument, or passes the type through as-is if unparameterized.


getTypeArgumentTypeOfGenericType

public static Type getTypeArgumentTypeOfGenericType(Type jvmType, int paramIndex)


getArrayComponentType

@io.github.qishr.cascara.common.annotation.Nullable
public static Class<?> getArrayComponentType(Type targetType)


getEffectiveName

public static String getEffectiveName(Field field)


getAllFields

public static List<Field> getAllFields(Class<?> clazz)


getAllFields

public static List<Field> getAllFields(Class<?> clazz, Function<Field, Boolean> excludeFunction)


getAllMethods

public static List<Method> getAllMethods(Class<?> jvmType)


getReferencedClasses

public static Set<Class<?>> getReferencedClasses(Class<?> clazz)


getReferencedClasses

public static Set<Class<?>> getReferencedClasses(Class<?> clazz, Set<String> excludeFunction)


getReferencedClasses

public static Set<Class<?>> getReferencedClasses(Class<?> clazz, Function<Class<?>, Boolean> excludeFunction)


getTypeName

public static String getTypeName(Type jvmType)


getCaller

@io.github.qishr.cascara.common.annotation.Nullable
public static Pair<Class<?>, String> getCaller()


getCaller

@io.github.qishr.cascara.common.annotation.Nullable
public static Pair<Class<?>, String> getCaller(boolean ignoreQueryingClass)


getCaller

@io.github.qishr.cascara.common.annotation.Nullable
public static Pair<Class<?>, String> getCaller(boolean ignoreQueryingClass, boolean ignoreQueryingModule)


getTestName

@io.github.qishr.cascara.common.annotation.Experimental
@io.github.qishr.cascara.common.annotation.Nullable
public static java.lang.@io.github.qishr.cascara.common.annotation.Experimental String getTestName()


getTestMethod

@io.github.qishr.cascara.common.annotation.Experimental
@io.github.qishr.cascara.common.annotation.Nullable
public static java.lang.reflect.@io.github.qishr.cascara.common.annotation.Experimental Method getTestMethod()


getMethodsByName

public static List<Method> getMethodsByName(Class<?> clazz, String name)