Class TypeUtil

java.lang.Object
org.apache.logging.log4j.plugins.util.TypeUtil

public final class TypeUtil extends Object
Utility class for working with Java Types and derivatives. This class is adapted heavily from the Spring Framework, specifically the TypeUtils class.
Since:
2.1
See Also:
  • Method Details

    • isAssignable

      public static boolean isAssignable(Type lhs, Type rhs)
      Indicates if two Types are assignment compatible.
      Parameters:
      lhs - the left hand side to check assignability to
      rhs - the right hand side to check assignability from
      Returns:
      true if it is legal to assign a variable of type rhs to a variable of type lhs
      See Also:
    • getRawType

      public static <T> Class<T> getRawType(Type type)
      Extracts the raw type equivalent of a given type.
    • getReferenceType

      public static Class<?> getReferenceType(Class<?> clazz)
      Returns the reference type for a class. For primitives, this is their boxed equivalent. For other types, this is the class unchanged.
    • getSuperclassTypeParameter

      public static Type getSuperclassTypeParameter(Class<?> type)
    • isEqual

      public static boolean isEqual(Type first, Type second)