public final class TypeUtils extends Object
Modifier and Type | Method and Description |
---|---|
static boolean |
arrayEqual(Object left,
Object right) |
static BigDecimal |
castToBigDecimal(Object value) |
static BigDecimal |
castToBigDecimal(Object value,
BigDecimal defaultValue) |
static BigInteger |
castToBigInteger(Object value) |
static BigInteger |
castToBigInteger(Object value,
BigInteger defaultValue) |
static boolean |
castToBoolean(Object value) |
static boolean |
castToBoolean(Object value,
boolean defaultValue) |
static byte |
castToByte(Object value) |
static byte |
castToByte(Object value,
byte defaultValue) |
static char |
castToChar(Object value) |
static char |
castToChar(Object value,
char defaultValue) |
static double |
castToDouble(Object value) |
static double |
castToDouble(Object value,
double defaultValue) |
static float |
castToFloat(Object value) |
static float |
castToFloat(Object value,
float defaultValue) |
static int |
castToInt(Object value) |
static int |
castToInt(Object value,
int defaultValue) |
static long |
castToLong(Object value) |
static long |
castToLong(Object value,
long defaultValue) |
static Number |
castToNumber(Object value) |
static Number |
castToNumber(Object value,
Number defaultValue) |
static short |
castToShort(Object value) |
static short |
castToShort(Object value,
short defaultValue) |
static int |
compareTo(Character left,
Character right) |
static int |
compareTo(Character left,
Number right) |
static int |
compareTo(Number left,
Character right) |
static int |
compareTo(Number left,
Number right) |
static int |
compareTo(Object left,
Object right) |
static <T> T |
convertValue(Class<T> targetType,
Object value) |
static <T> T |
convertValue(Class<T> targetType,
Object value,
String format) |
static boolean |
equals(int[] left,
int[] right)
Compare the contents of this array to the contents of the given array.
|
static <T> boolean |
equals(List<T> left,
List<T> right)
Compare the contents of two Lists.
|
static boolean |
equals(List left,
Object[] right)
Determines if the contents of this list are equal to the
contents of the given array in the same order.
|
static <K,V> boolean |
equals(Map<K,V> left,
Map<K,V> right)
Compares two Maps treating coerced numerical values as identical.
|
static boolean |
equals(Object[] left,
List right)
Determines if the contents of this array are equal to the
contents of the given list, in the same order.
|
static boolean |
equals(Object left,
Object right) |
static <T> boolean |
equals(Set<T> left,
Set<T> right)
Compare the contents of two Sets for equality using Groovy's coercion rules.
|
static boolean |
isBigDecimal(Class<?> type) |
static boolean |
isBigDecimal(Number number) |
static boolean |
isBigInteger(Class<?> type) |
static boolean |
isBigInteger(Number number) |
static boolean |
isBoolean(Class<?> type) |
static boolean |
isByte(Class<?> type) |
static boolean |
isCharacter(Class<?> type) |
static boolean |
isDouble(Class<?> type) |
static boolean |
isFloat(Class<?> type) |
static boolean |
isFloatingPoint(Number number) |
static boolean |
isInteger(Class<?> type) |
static boolean |
isInteger(Number number) |
static boolean |
isLong(Class<?> type) |
static boolean |
isLong(Number number) |
static boolean |
isNumber(Class<?> type) |
static boolean |
isShort(Class<?> type) |
static List |
primitiveArrayToList(Object array)
Allows conversion of arrays into a mutable List
|
public static BigInteger castToBigInteger(@Nonnull Object value)
public static BigDecimal castToBigDecimal(@Nonnull Object value)
@Nullable public static Number castToNumber(@Nullable Object value, @Nullable Number defaultValue)
@Nullable public static BigInteger castToBigInteger(@Nullable Object value, @Nullable BigInteger defaultValue)
@Nullable public static BigDecimal castToBigDecimal(@Nullable Object value, @Nullable BigDecimal defaultValue)
@Nonnull public static <T> T convertValue(@Nonnull Class<T> targetType, @Nonnull Object value)
@Nonnull public static <T> T convertValue(@Nonnull Class<T> targetType, @Nonnull Object value, @Nullable String format)
public static boolean equals(int[] left, int[] right)
left
- an int arrayright
- the array being comparedpublic static boolean equals(Object[] left, List right)
false
if either collection is null
.left
- an arrayright
- the List being comparedpublic static boolean equals(List left, Object[] right)
false
if either collection is null
.left
- a Listright
- the Object[] being compared topublic static <T> boolean equals(List<T> left, List<T> right)
null
, the result
is true; rightwise if either list is null
, the result
is false
.left
- a Listright
- the List being compared totrue
if the contents of both lists are identical,
false
rightwise.public static <T> boolean equals(Set<T> left, Set<T> right)
Returns true if the two sets have the same size, and every member
of the specified set is contained in this set (or equivalently, every member
of this set is contained in the specified set).
If numbers exist in the sets, then they are compared as numbers,
for example 2 == 2L. If both sets are null
, the result
is true; rightwise if either set is null
, the result
is false
.
left
- a Setright
- the Set being compared topublic static <K,V> boolean equals(Map<K,V> left, Map<K,V> right)
left
- this Mapright
- the Map being compared topublic static List primitiveArrayToList(Object array)
array
- an arraypublic static boolean isFloatingPoint(Number number)
public static boolean isInteger(Number number)
public static boolean isLong(Number number)
public static boolean isBigDecimal(Number number)
public static boolean isBigInteger(Number number)