Class ClassUtil


  • public final class ClassUtil
    extends Object
    Utility classes with respect to the class operations.
    Since:
    1.0
    Author:
    Gurkan Erdogdu
    • Field Detail

      • PRIMITIVE_TO_WRAPPERS_MAP

        public static final Map<Class<?>,​Class<?>> PRIMITIVE_TO_WRAPPERS_MAP
      • NO_TYPES

        public static final Type[] NO_TYPES
    • Method Detail

      • isSame

        public static boolean isSame​(Type type1,
                                     Type type2)
      • getPrimitiveWrapper

        public static Class<?> getPrimitiveWrapper​(Class<?> clazz)
      • getClass

        public static Class<?> getClass​(Type type)
        Gets the class of the given type arguments.

        If the given type Type parameters is an instance of the ParameterizedType, it returns the raw type otherwise it return the casted Class of the type argument.

        Parameters:
        type - class or parametrized type
        Returns:
      • isParameterizedType

        public static boolean isParameterizedType​(Type type)
        Returns true if type is an instance of ParameterizedType else otherwise.
        Parameters:
        type - type of the artifact
        Returns:
        true if type is an instance of ParameterizedType
      • isWildCardType

        public static boolean isWildCardType​(Type type)
        Returns true if type is an instance of WildcardType else otherwise.
        Parameters:
        type - type of the artifact
        Returns:
        true if type is an instance of WildcardType
      • isClassAssignableFrom

        public static boolean isClassAssignableFrom​(Class<?> lhs,
                                                    Class<?> rhs)
        Returns true if rhs is assignable type to the lhs, false otherwise.
        Parameters:
        lhs - left hand side class
        rhs - right hand side class
        Returns:
        true if rhs is assignable to lhs
      • getClazz

        public static Class<?> getClazz​(Type type)
        Return raw class type for given type.
        Parameters:
        type - base type instance
        Returns:
        class type for given type
      • isRawClassEquals

        public static boolean isRawClassEquals​(Type ipType,
                                               Type apiType)
      • hasAnnotation

        public static boolean hasAnnotation​(String fqAnnotationName,
                                            Class<?> cl)
        Parameters:
        fqAnnotationName - a fully qualified runtime annotation name whose presence on the given class is to be checked
        cl - the class to check
        Returns:
        true if the given Class is annotated with the given runtime annotation; false otherwise