public class ClassUtils extends Object
Modifier and Type | Field and Description |
---|---|
static Map<String,Class> |
BASIC_TYPE_MAP |
static String |
CLASS_EXTENSION
Default extension for class files.
|
static Map<String,Class> |
COMMON_CLASS_MAP |
static int |
EMPTY_OBJECT_ARRAY_HASH_CODE |
static String |
PROPERTY_MICRONAUT_CLASSLOADER_LOGGING
System property to indicate whether classloader logging should be activated.
|
static org.slf4j.Logger |
REFLECTION_LOGGER
A logger that should be used for any reflection access.
|
Constructor and Description |
---|
ClassUtils() |
Modifier and Type | Method and Description |
---|---|
static Optional<Class> |
arrayTypeForPrimitive(String primitiveType)
Returns the array type for the given primitive type name.
|
static Optional<Class> |
forName(String name,
ClassLoader classLoader)
Attempt to load a class for the given name from the given class loader.
|
static org.slf4j.Logger |
getLogger(Class type)
Special case
getLogger method that should be used by classes that are used in the annotation processor. |
static Optional<Class> |
getPrimitiveType(String primitiveType)
The primitive type for the given type name.
|
static boolean |
isJavaBasicType(Class<?> type)
Expanded version of
isJavaLangType(Class) that includes common Java types like URI . |
static boolean |
isJavaBasicType(String name)
Expanded version of
isJavaLangType(Class) that includes common Java types like URI . |
static boolean |
isJavaLangType(Class type)
Return whether the given class is a common type found in java.lang such as String or a primitive type.
|
static boolean |
isJavaLangType(String typeName)
Return whether the given class is a common type found in java.lang such as String or a primitive type.
|
static boolean |
isPresent(String name,
ClassLoader classLoader)
Check whether the given class is present in the given classloader.
|
static String |
pathToClassName(String path)
Converts a URI to a class file reference to the class name
|
static List<Class> |
resolveHierarchy(Class<?> type)
Builds a class hierarchy that includes all super classes
and interfaces that the given class implements or extends from.
|
public static final String PROPERTY_MICRONAUT_CLASSLOADER_LOGGING
public static final int EMPTY_OBJECT_ARRAY_HASH_CODE
public static final String CLASS_EXTENSION
public static final org.slf4j.Logger REFLECTION_LOGGER
@Nonnull public static org.slf4j.Logger getLogger(@Nonnull Class type)
getLogger
method that should be used by classes that are used in the annotation processor.type
- The type@Nonnull public static Optional<Class> arrayTypeForPrimitive(String primitiveType)
primitiveType
- The primitive type namepublic static String pathToClassName(String path)
Converts a URI to a class file reference to the class name
.
ie. ClassUtils.pathToClassName("foo/bar/MyClass.class") == "foo.bar.MyClass"
path
- The path namepublic static boolean isPresent(String name, @Nullable ClassLoader classLoader)
name
- The name of the classclassLoader
- The classloader. If null will fallback to attempt the thread context loader, otherwise the system loaderpublic static boolean isJavaLangType(Class type)
type
- The typepublic static boolean isJavaLangType(String typeName)
typeName
- The type namepublic static boolean isJavaBasicType(@Nullable Class<?> type)
isJavaLangType(Class)
that includes common Java types like URI
.type
- The URIpublic static boolean isJavaBasicType(@Nullable String name)
isJavaLangType(Class)
that includes common Java types like URI
.name
- The name of the typepublic static Optional<Class> getPrimitiveType(String primitiveType)
Byte.TYPE
.primitiveType
- The type namepublic static Optional<Class> forName(String name, @Nullable ClassLoader classLoader)
name
- The name of the classclassLoader
- The classloader. If null will fallback to attempt the thread context loader, otherwise the system loader