Class TypeUtils


  • public class TypeUtils
    extends Object
    Author:
    wenshao[szujobs@hotmail.com]
    • Field Detail

      • compatibleWithJavaBean

        public static boolean compatibleWithJavaBean
      • compatibleWithFieldName

        public static boolean compatibleWithFieldName
        根据field name的大小写输出输入数据
      • fnv1a_64_magic_hashcode

        public static final long fnv1a_64_magic_hashcode
        See Also:
        Constant Field Values
    • Constructor Detail

      • TypeUtils

        public TypeUtils()
    • Method Detail

      • isXmlField

        public static boolean isXmlField​(Class clazz)
      • getXmlAccessorType

        public static Annotation getXmlAccessorType​(Class clazz)
      • isClob

        public static boolean isClob​(Class clazz)
      • castToString

        public static String castToString​(Object value)
      • castToByte

        public static Byte castToByte​(Object value)
      • castToShort

        public static Short castToShort​(Object value)
      • castToBigDecimal

        public static BigDecimal castToBigDecimal​(Object value)
      • castToBigInteger

        public static BigInteger castToBigInteger​(Object value)
      • castToFloat

        public static Float castToFloat​(Object value)
      • castToDouble

        public static Double castToDouble​(Object value)
      • castToDate

        public static Date castToDate​(Object value)
      • castToSqlDate

        public static Object castToSqlDate​(Object value)
      • longExtractValue

        public static long longExtractValue​(Number number)
      • castToSqlTime

        public static Object castToSqlTime​(Object value)
      • castToTimestamp

        public static Object castToTimestamp​(Object value)
      • isNumber

        public static boolean isNumber​(String str)
      • castToLong

        public static Long castToLong​(Object value)
      • byteValue

        public static byte byteValue​(BigDecimal decimal)
      • shortValue

        public static short shortValue​(BigDecimal decimal)
      • intValue

        public static int intValue​(BigDecimal decimal)
      • longValue

        public static long longValue​(BigDecimal decimal)
      • castToBytes

        public static byte[] castToBytes​(Object value)
      • castToBoolean

        public static Boolean castToBoolean​(Object value)
      • castToJavaBean

        public static <T> T castToJavaBean​(Object obj,
                                           Class<T> clazz)
      • toLocale

        public static Locale toLocale​(String strVal)
      • clearClassMapping

        public static void clearClassMapping()
      • addMapping

        public static void addMapping​(String className,
                                      Class<?> clazz)
      • loadClass

        public static Class<?> loadClass​(String className)
      • isPath

        public static boolean isPath​(Class<?> clazz)
      • getClassFromMapping

        public static Class<?> getClassFromMapping​(String className)
      • hasIllegalTypeNameChars

        public static boolean hasIllegalTypeNameChars​(String typeName)
        Tests whether a type name carries a character that cannot appear in a Java binary class name but is meaningful in a URL. A nested jar URL such as jar:http://host/x.jar!/ is resolvable by some class loaders, so a type name carrying one must never reach one.
        Parameters:
        typeName - the type name to test
        Returns:
        true if the type name must be rejected without being resolved
      • normalizeAcceptName

        public static String normalizeAcceptName​(String typeName)
        Normalizes a type name the way the autoType accept-list rolling hash normalizes it, so that a nested class matches whether it is written with its binary name (a.b.Outer$Inner) or its canonical name (a.b.Outer.Inner).
        Parameters:
        typeName - the type name to normalize
        Returns:
        the normalized type name
      • isAutoTypeDenyClass

        public static boolean isAutoTypeDenyClass​(Class<?> type)
        Tests whether a class is a well known deserialization gadget entry point, namely a ClassLoader subclass or a JDK SQL DataSource/RowSet implementation. Such types must not be resolved by matching an autoType whitelist prefix; only an accept entry naming the type in full is treated as an explicit opt-in.
        Parameters:
        type - the class to test
        Returns:
        true if the class must not be resolved through a whitelist prefix match
      • loadClass

        public static Class<?> loadClass​(String className,
                                         ClassLoader classLoader,
                                         boolean cache)
      • getSuperMethodAnnotation

        public static JSONField getSuperMethodAnnotation​(Class<?> clazz,
                                                         Method method)
      • isGenericParamType

        public static boolean isGenericParamType​(Type type)
      • getGenericParamType

        public static Type getGenericParamType​(Type type)
      • unwrapOptional

        public static Type unwrapOptional​(Type type)
      • getClass

        public static Class<?> getClass​(Type type)
      • getField

        public static Field getField​(Class<?> clazz,
                                     String fieldName,
                                     Field[] declaredFields)
      • getSerializeFeatures

        public static int getSerializeFeatures​(Class<?> clazz)
        Deprecated.
      • getParserFeatures

        public static int getParserFeatures​(Class<?> clazz)
      • decapitalize

        public static String decapitalize​(String name)
      • getPropertyNameByMethodName

        public static String getPropertyNameByMethodName​(String methodName)
        resolve property name from get/set method name
        Parameters:
        methodName - get/set method name
        Returns:
        property name
      • getCollectionItemType

        public static Type getCollectionItemType​(Type fieldType)
      • getCollectionItemClass

        public static Class<?> getCollectionItemClass​(Type fieldType)
      • checkPrimitiveArray

        public static Type checkPrimitiveArray​(GenericArrayType genericArrayType)
      • createSet

        public static Set createSet​(Type type)
      • createCollection

        public static Collection createCollection​(Type type)
      • getRawClass

        public static Class<?> getRawClass​(Type type)
      • isProxy

        public static boolean isProxy​(Class<?> clazz)
      • isTransient

        public static boolean isTransient​(Method method)
      • isAnnotationPresentOneToMany

        public static boolean isAnnotationPresentOneToMany​(Method method)
      • isAnnotationPresentManyToMany

        public static boolean isAnnotationPresentManyToMany​(Method method)
      • isHibernateInitialized

        public static boolean isHibernateInitialized​(Object object)
      • parseDouble

        public static double parseDouble​(String str)
      • parseFloat

        public static float parseFloat​(String str)
      • fnv1a_64_extract

        public static long fnv1a_64_extract​(String key)
      • fnv1a_64_lower

        public static long fnv1a_64_lower​(String key)
      • fnv1a_64

        public static long fnv1a_64​(String key)
      • isKotlin

        public static boolean isKotlin​(Class clazz)
      • getKoltinConstructorParameters

        public static String[] getKoltinConstructorParameters​(Class clazz)
      • getAnnotation

        public static <A extends Annotation> A getAnnotation​(Class<?> targetClass,
                                                             Class<A> annotationClass)
      • getAnnotation

        public static <A extends Annotation> A getAnnotation​(Field field,
                                                             Class<A> annotationClass)
      • getAnnotation

        public static <A extends Annotation> A getAnnotation​(Method method,
                                                             Class<A> annotationClass)
      • getParameterAnnotations

        public static Annotation[][] getParameterAnnotations​(Method method)
      • getParameterAnnotations

        public static Annotation[][] getParameterAnnotations​(Constructor constructor)
      • isJacksonCreator

        public static boolean isJacksonCreator​(Method method)
      • optionalEmpty

        public static Object optionalEmpty​(Type type)