Package com.alibaba.fastjson2.util
Class TypeUtils
- java.lang.Object
-
- com.alibaba.fastjson2.util.TypeUtils
-
public class TypeUtils extends Object
-
-
Field Summary
-
Constructor Summary
Constructors Constructor Description TypeUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> Tcast(Object obj, Class<T> targetClass)static <T> Tcast(Object obj, Class<T> targetClass, ObjectReaderProvider provider)static <T> Tcast(Object obj, Type type)static Object[]cast(Object obj, Type[] types)static <T> Tcast(Object obj, Type type, ObjectReaderProvider provider)static intcompare(Object a, Object b)static doubledoubleValue(boolean isNegative, int decExp, char[] digits, int nDigits)static doubledoubleValue(int signNum, long intCompact, int scale)static floatfloatValue(boolean isNegative, int decExponent, char[] digits, int nDigits)static floatfloatValue(int signNum, long intCompact, int scale)static Class<?>getArrayClass(Class componentClass)static Class<?>getClass(Type type)static ObjectgetDefaultValue(Type paramType)static MapgetInnerMap(Map object)static Class<?>getMapping(Type type)static ClassgetMapping(String typeName)static TypegetMapValueType(Type fieldType)static StringgetTypeName(Class type)static Typeintern(Type type)static booleanisFunction(Class type)static booleanisInt32(BigInteger value)static booleanisInt64(BigInteger value)static booleanisInteger(byte[] str, int off, int len)static booleanisInteger(char[] str, int off, int len)static booleanisInteger(String str)static booleanisInteger(BigDecimal decimal)decimal is integer, check has non-zero smallstatic booleanisJavaScriptSupport(long i)static booleanisJavaScriptSupport(BigDecimal i)static booleanisJavaScriptSupport(BigInteger i)static booleanisNumber(byte[] str, int off, int len)static booleanisNumber(char[] str, int off, int len)static booleanisNumber(String str)static booleanisProxy(Class<?> clazz)static booleanisUUID(String str)static ClassloadClass(String className)static <T> TnewProxyInstance(Class<T> objectClass, JSONObject object)static ClassnonePrimitive(Class type)static BigDecimalparseBigDecimal(byte[] bytes, int off, int len)static BigDecimalparseBigDecimal(char[] bytes, int off, int len)static BooleanparseBoolean(byte[] bytes, int off, int len)static BooleanparseBoolean(char[] bytes, int off, int len)static doubleparseDouble(byte[] in, int off, int len)static doubleparseDouble(char[] in, int off, int len)static floatparseFloat(byte[] in, int off, int len)static floatparseFloat(char[] in, int off, int len)static intparseInt(byte[] bytes, int off, int len)static intparseInt(char[] bytes, int off, int len)static longparseLong(byte[] bytes, int off, int len)static longparseLong(char[] bytes, int off, int len)static BigDecimaltoBigDecimal(byte[] strBytes)static BigDecimaltoBigDecimal(char[] chars)static BigDecimaltoBigDecimal(double d)static BigDecimaltoBigDecimal(float f)static BigDecimaltoBigDecimal(long i)static BigDecimaltoBigDecimal(Object value)static BigDecimaltoBigDecimal(String str)static BigIntegertoBigInteger(Object value)static BooleantoBoolean(Object value)static booleantoBooleanValue(Object value)static BytetoByte(Object value)static bytetoByteValue(Object value)static DatetoDate(Object obj)static DoubletoDouble(Object value)static doubletoDoubleValue(Object value)static FloattoFloat(Object value)static floattoFloatValue(Object value)static InstanttoInstant(Object obj)static IntegertoInteger(Object value)static inttoIntValue(Object value)static LongtoLong(Object value)static longtoLongValue(Object value)static ShorttoShort(Object value)static shorttoShortValue(Object value)static StringtoString(byte ch)static StringtoString(byte c0, byte c1)static StringtoString(char ch)static StringtoString(char c0, char c1)static String[]toStringArray(Object object)static booleanvalidateIPv4(String str)static booleanvalidateIPv6(String str)
-
-
-
Field Detail
-
CLASS_JSON_OBJECT_1x
public static final Class CLASS_JSON_OBJECT_1x
-
FIELD_JSON_OBJECT_1x_map
public static final Field FIELD_JSON_OBJECT_1x_map
-
CLASS_JSON_ARRAY_1x
public static final Class CLASS_JSON_ARRAY_1x
-
CLASS_SINGLE_SET
public static final Class CLASS_SINGLE_SET
-
CLASS_SINGLE_LIST
public static final Class CLASS_SINGLE_LIST
-
CLASS_UNMODIFIABLE_COLLECTION
public static final Class CLASS_UNMODIFIABLE_COLLECTION
-
CLASS_UNMODIFIABLE_LIST
public static final Class CLASS_UNMODIFIABLE_LIST
-
CLASS_UNMODIFIABLE_SET
public static final Class CLASS_UNMODIFIABLE_SET
-
CLASS_UNMODIFIABLE_SORTED_SET
public static final Class CLASS_UNMODIFIABLE_SORTED_SET
-
CLASS_UNMODIFIABLE_NAVIGABLE_SET
public static final Class CLASS_UNMODIFIABLE_NAVIGABLE_SET
-
PARAM_TYPE_LIST_STR
public static final ParameterizedType PARAM_TYPE_LIST_STR
-
METHOD_TYPE_SUPPLIER
public static final MethodType METHOD_TYPE_SUPPLIER
-
METHOD_TYPE_FUNCTION
public static final MethodType METHOD_TYPE_FUNCTION
-
METHOD_TYPE_TO_INT_FUNCTION
public static final MethodType METHOD_TYPE_TO_INT_FUNCTION
-
METHOD_TYPE_TO_LONG_FUNCTION
public static final MethodType METHOD_TYPE_TO_LONG_FUNCTION
-
METHOD_TYPE_OBJECT_INT_CONSUMER
public static final MethodType METHOD_TYPE_OBJECT_INT_CONSUMER
-
METHOD_TYPE_INT_FUNCTION
public static final MethodType METHOD_TYPE_INT_FUNCTION
-
METHOD_TYPE_LONG_FUNCTION
public static final MethodType METHOD_TYPE_LONG_FUNCTION
-
METHOD_TYPE_BI_FUNCTION
public static final MethodType METHOD_TYPE_BI_FUNCTION
-
METHOD_TYPE_BI_CONSUMER
public static final MethodType METHOD_TYPE_BI_CONSUMER
-
METHOD_TYPE_VOO
public static final MethodType METHOD_TYPE_VOO
-
METHOD_TYPE_OBJECT
public static final MethodType METHOD_TYPE_OBJECT
-
METHOD_TYPE_OBJECT_OBJECT
public static final MethodType METHOD_TYPE_OBJECT_OBJECT
-
METHOD_TYPE_INT_OBJECT
public static final MethodType METHOD_TYPE_INT_OBJECT
-
METHOD_TYPE_LONG_OBJECT
public static final MethodType METHOD_TYPE_LONG_OBJECT
-
METHOD_TYPE_VOID_OBJECT_INT
public static final MethodType METHOD_TYPE_VOID_OBJECT_INT
-
METHOD_TYPE_OBJECT_LONG
public static final MethodType METHOD_TYPE_OBJECT_LONG
-
METHOD_TYPE_VOID_LONG
public static final MethodType METHOD_TYPE_VOID_LONG
-
METHOD_TYPE_OBJECT_OBJECT_OBJECT
public static final MethodType METHOD_TYPE_OBJECT_OBJECT_OBJECT
-
METHOD_TYPE_VOID
public static final MethodType METHOD_TYPE_VOID
-
METHOD_TYPE_VOID_INT
public static final MethodType METHOD_TYPE_VOID_INT
-
METHOD_TYPE_VOID_STRING
public static final MethodType METHOD_TYPE_VOID_STRING
-
METHOD_TYPE_OBJECT_INT
public static final MethodType METHOD_TYPE_OBJECT_INT
-
BIGINT_INT32_MIN
public static final BigInteger BIGINT_INT32_MIN
-
BIGINT_INT32_MAX
public static final BigInteger BIGINT_INT32_MAX
-
BIGINT_INT64_MIN
public static final BigInteger BIGINT_INT64_MIN
-
BIGINT_INT64_MAX
public static final BigInteger BIGINT_INT64_MAX
-
SMALL_10_POW
public static final double[] SMALL_10_POW
All the positive powers of 10 that can be represented exactly in double/float.
-
-
Method Detail
-
newProxyInstance
public static <T> T newProxyInstance(Class<T> objectClass, JSONObject object)
-
toString
public static String toString(char ch)
-
toString
public static String toString(byte ch)
-
toString
public static String toString(char c0, char c1)
-
toString
public static String toString(byte c0, byte c1)
-
parseDouble
public static double parseDouble(byte[] in, int off, int len) throws NumberFormatException- Throws:
NumberFormatException
-
parseDouble
public static double parseDouble(char[] in, int off, int len) throws NumberFormatException- Throws:
NumberFormatException
-
parseFloat
public static float parseFloat(byte[] in, int off, int len) throws NumberFormatException- Throws:
NumberFormatException
-
parseFloat
public static float parseFloat(char[] in, int off, int len) throws NumberFormatException- Throws:
NumberFormatException
-
doubleValue
public static double doubleValue(boolean isNegative, int decExp, char[] digits, int nDigits)
-
floatValue
public static float floatValue(boolean isNegative, int decExponent, char[] digits, int nDigits)
-
cast
public static <T> T cast(Object obj, Type type, ObjectReaderProvider provider)
-
cast
public static <T> T cast(Object obj, Class<T> targetClass, ObjectReaderProvider provider)
-
toBigDecimal
public static BigDecimal toBigDecimal(Object value)
-
toBigDecimal
public static BigDecimal toBigDecimal(long i)
-
toBigDecimal
public static BigDecimal toBigDecimal(float f)
-
toBigDecimal
public static BigDecimal toBigDecimal(double d)
-
toBigDecimal
public static BigDecimal toBigDecimal(String str)
-
toBigDecimal
public static BigDecimal toBigDecimal(char[] chars)
-
toBigDecimal
public static BigDecimal toBigDecimal(byte[] strBytes)
-
isInt32
public static boolean isInt32(BigInteger value)
-
isInt64
public static boolean isInt64(BigInteger value)
-
isInteger
public static boolean isInteger(BigDecimal decimal)
decimal is integer, check has non-zero small- Parameters:
decimal-- Returns:
-
toBigInteger
public static BigInteger toBigInteger(Object value)
-
toLongValue
public static long toLongValue(Object value)
-
parseBoolean
public static Boolean parseBoolean(byte[] bytes, int off, int len)
-
parseBoolean
public static Boolean parseBoolean(char[] bytes, int off, int len)
-
parseInt
public static int parseInt(byte[] bytes, int off, int len)
-
parseInt
public static int parseInt(char[] bytes, int off, int len)
-
parseLong
public static long parseLong(byte[] bytes, int off, int len)
-
parseLong
public static long parseLong(char[] bytes, int off, int len)
-
parseBigDecimal
public static BigDecimal parseBigDecimal(char[] bytes, int off, int len)
-
parseBigDecimal
public static BigDecimal parseBigDecimal(byte[] bytes, int off, int len)
-
toByteValue
public static byte toByteValue(Object value)
-
toShortValue
public static short toShortValue(Object value)
-
toIntValue
public static int toIntValue(Object value)
-
toBooleanValue
public static boolean toBooleanValue(Object value)
-
toFloatValue
public static float toFloatValue(Object value)
-
toDoubleValue
public static double toDoubleValue(Object value)
-
isProxy
public static boolean isProxy(Class<?> clazz)
-
isFunction
public static boolean isFunction(Class type)
-
isInteger
public static boolean isInteger(String str)
-
isInteger
public static boolean isInteger(byte[] str, int off, int len)
-
isInteger
public static boolean isInteger(char[] str, int off, int len)
-
isNumber
public static boolean isNumber(String str)
-
isNumber
public static boolean isNumber(byte[] str, int off, int len)
-
isNumber
public static boolean isNumber(char[] str, int off, int len)
-
isUUID
public static boolean isUUID(String str)
-
validateIPv4
public static boolean validateIPv4(String str)
-
validateIPv6
public static boolean validateIPv6(String str)
-
doubleValue
public static double doubleValue(int signNum, long intCompact, int scale)
-
floatValue
public static float floatValue(int signNum, long intCompact, int scale)
-
isJavaScriptSupport
public static boolean isJavaScriptSupport(long i)
-
isJavaScriptSupport
public static boolean isJavaScriptSupport(BigDecimal i)
-
isJavaScriptSupport
public static boolean isJavaScriptSupport(BigInteger i)
-
-