Class TypeUtil
- java.lang.Object
-
- org.apache.logging.log4j.core.util.TypeUtil
-
public final class TypeUtil extends java.lang.ObjectUtility class for working with JavaTypes and derivatives. This class is adapted heavily from the Spring Framework, specifically the TypeUtils class.- Since:
- 2.1
- See Also:
Type,GenericArrayType,ParameterizedType,WildcardType,Class
-
-
Constructor Summary
Constructors Modifier Constructor Description privateTypeUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.util.List<java.lang.reflect.Field>getAllDeclaredFields(java.lang.Class<?> cls)Gets all declared fields for the given class (including superclasses).private static java.lang.reflect.Type[]getEffectiveLowerBounds(java.lang.reflect.WildcardType type)private static java.lang.reflect.Type[]getEffectiveUpperBounds(java.lang.reflect.WildcardType type)static booleanisAssignable(java.lang.reflect.Type lhs, java.lang.reflect.Type rhs)Indicates if twoTypes are assignment compatible.private static booleanisBoundAssignable(java.lang.reflect.Type lhs, java.lang.reflect.Type rhs)private static booleanisParameterizedAssignable(java.lang.reflect.ParameterizedType lhs, java.lang.reflect.ParameterizedType rhs)private static booleanisWildcardAssignable(java.lang.reflect.WildcardType lhs, java.lang.reflect.Type rhs)
-
-
-
Method Detail
-
getAllDeclaredFields
public static java.util.List<java.lang.reflect.Field> getAllDeclaredFields(java.lang.Class<?> cls)
Gets all declared fields for the given class (including superclasses).- Parameters:
cls- the class to examine- Returns:
- all declared fields for the given class (including superclasses).
- See Also:
Class.getDeclaredFields()
-
isAssignable
public static boolean isAssignable(java.lang.reflect.Type lhs, java.lang.reflect.Type rhs)Indicates if twoTypes are assignment compatible.- Parameters:
lhs- the left hand side to check assignability torhs- the right hand side to check assignability from- Returns:
trueif it is legal to assign a variable of typerhsto a variable of typelhs- See Also:
Class.isAssignableFrom(Class)
-
isParameterizedAssignable
private static boolean isParameterizedAssignable(java.lang.reflect.ParameterizedType lhs, java.lang.reflect.ParameterizedType rhs)
-
isWildcardAssignable
private static boolean isWildcardAssignable(java.lang.reflect.WildcardType lhs, java.lang.reflect.Type rhs)
-
getEffectiveUpperBounds
private static java.lang.reflect.Type[] getEffectiveUpperBounds(java.lang.reflect.WildcardType type)
-
getEffectiveLowerBounds
private static java.lang.reflect.Type[] getEffectiveLowerBounds(java.lang.reflect.WildcardType type)
-
isBoundAssignable
private static boolean isBoundAssignable(java.lang.reflect.Type lhs, java.lang.reflect.Type rhs)
-
-