Class TypeUtil


  • public final class TypeUtil
    extends java.lang.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:
    Type, GenericArrayType, ParameterizedType, WildcardType, Class
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private TypeUtil()  
    • 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 boolean isAssignable​(java.lang.reflect.Type lhs, java.lang.reflect.Type rhs)
      Indicates if two Types are assignment compatible.
      private static boolean isBoundAssignable​(java.lang.reflect.Type lhs, java.lang.reflect.Type rhs)  
      private static boolean isParameterizedAssignable​(java.lang.reflect.ParameterizedType lhs, java.lang.reflect.ParameterizedType rhs)  
      private static boolean isWildcardAssignable​(java.lang.reflect.WildcardType lhs, java.lang.reflect.Type rhs)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • TypeUtil

        private TypeUtil()
    • 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 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:
        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)