Class ClassUtils
- java.lang.Object
-
- com.xebialabs.deployit.booter.local.utils.ClassUtils
-
public class ClassUtils extends java.lang.ObjectUtility methods for dealing withClasses.- Since:
- 9 Feb 2009
-
-
Constructor Summary
Constructors Constructor Description ClassUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <S> java.util.List<java.lang.Class<?>>getActualTypeArguments(java.lang.Class<? extends S> typedClass, java.lang.Class<S> typedSuperclass)Retrieves the type arguments of a class when regarded as an subclass of the given typed superclass or interface.
-
-
-
Method Detail
-
getActualTypeArguments
public static <S> java.util.List<java.lang.Class<?>> getActualTypeArguments(java.lang.Class<? extends S> typedClass, java.lang.Class<S> typedSuperclass)Retrieves the type arguments of a class when regarded as an subclass of the given typed superclass or interface. The order of the runtime type classes matches the order of the type variables in the declaration of the typed superclass or interface. For example, for the classesclass Foo<U, V> {} class Bar<W> extends Foo<String, W> {} class Baz extends Bar<Long>and atypedClassargument ofBaz.class, the method should return[String, Long]for atypedSuperclassargument ofFoo.class, and[Long]iftypedSuperclassisBar.class.
nullis returned. Note: It is not possible to retrieve type information that is not available in the (super)class hierarchy at compile-time. CallinggetActualTypeArguments(new ArrayList<String>().getClass(), List.class)will, for instance, return[null]because the specification of the actual type (String, in this example) did not take place either in the superclassAbstractListor the interfaceList. Ifsuperclassis not a superclass or -interface ofclass, the method returnsnull. This may happen (in spite of the signature) if the method is called with non-generic arguments.- Type Parameters:
S- the type of the object- Parameters:
typedClass- the class for which type information is requiredtypedSuperclass- the typed class or interface of which the object is to be regarded a subclass- Returns:
- the type arguments for the given class when regarded as a subclass of the
given typed superclass, in the order defined in the superclass. If
classis not a subclass ofsuperclass, returnsnull. - Throws:
java.lang.IllegalArgumentException- iftypedSuperclassortypedClassisnull
-
-