Class ClassUtils
java.lang.Object
org.springframework.util.ClassUtils
Miscellaneous
java.lang.Class utility methods.
Mainly for internal use within the framework.
- Since:
- 1.1
- Author:
- Juergen Hoeller, Keith Donald, Rob Harrop, Sam Brannen, Sebastien Deleuze, Sungbin Yang
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringaddResourcePathToPackagePath(Class<?> clazz, String resourceName) Return a path suitable for use withClassLoader.getResource(also suitable for use withClass.getResourceby prepending a slash ('/') to the return value).static StringclassNamesToString(Class<?>... classes) Build a String that consists of the names of the classes/interfaces in the given array.static StringclassNamesToString(@Nullable Collection<Class<?>> classes) Build a String that consists of the names of the classes/interfaces in the given collection.static StringclassPackageAsResourcePath(@Nullable Class<?> clazz) Given an input class object, return a string which consists of the class's package name as a pathname, i.e., all dots ('.') are replaced by slashes ('/').static StringconvertClassNameToResourcePath(String className) Convert a "."-based fully qualified class name to a "/"-based resource path.static StringconvertResourcePathToClassName(String resourcePath) Convert a "/"-based resource path to a "."-based fully qualified class name.static Class<?> createCompositeInterface(Class<?>[] interfaces, @Nullable ClassLoader classLoader) Create a composite interface Class for the given interfaces, implementing the given interfaces in one single Class.determineCommonAncestor(@Nullable Class<?> clazz1, @Nullable Class<?> clazz2) Determine the common ancestor of the given classes, if any.static Class<?> forName(String name, @Nullable ClassLoader classLoader) Replacement forClass.forName()that also returns Class instances for primitives (for example, "int") and array class names (for example, "String[]").static Class<?>[]getAllInterfaces(Object instance) Return all interfaces that the given instance implements as an array, including ones implemented by superclasses.getAllInterfacesAsSet(Object instance) Return all interfaces that the given instance implements as a Set, including ones implemented by superclasses.static Class<?>[]getAllInterfacesForClass(Class<?> clazz) Return all interfaces that the given class implements as an array, including ones implemented by superclasses.static Class<?>[]getAllInterfacesForClass(Class<?> clazz, @Nullable ClassLoader classLoader) Return all interfaces that the given class implements as an array, including ones implemented by superclasses.getAllInterfacesForClassAsSet(Class<?> clazz) Return all interfaces that the given class implements as a Set, including ones implemented by superclasses.getAllInterfacesForClassAsSet(Class<?> clazz, @Nullable ClassLoader classLoader) Return all interfaces that the given class implements as a Set, including ones implemented by superclasses.static StringgetClassFileName(Class<?> clazz) Determine the name of the class file, relative to the containing package: for example, "String.class".static <T> @Nullable Constructor<T> getConstructorIfAvailable(Class<T> clazz, Class<?>... paramTypes) Determine whether the given class has a public constructor with the given signature, and return it if available (else returnnull).static @Nullable ClassLoaderReturn the default ClassLoader to use: typically the thread context ClassLoader, if available; the ClassLoader that loaded the ClassUtils class will be used as fallback.getDescriptiveType(@Nullable Object value) Return a descriptive name for the given object's type: usually simply the class name, but component type class name + "[]" for arrays, and an appended list of implemented interfaces for JDK proxies.static Method