public class Conversions extends Object
Constructor and Description |
---|
Conversions() |
Modifier and Type | Method and Description |
---|---|
static <V> V[] |
array(Class<V> type,
Collection<V> array) |
static byte[] |
barray(Object value) |
static char[] |
carray(Object value) |
static <T> T |
coerce(Class<T> clz,
Object value) |
static <T> T |
coerce(Type coerceTo,
Class<T> clz,
Object value) |
static <T> T |
coerceClassic(Class<T> clz,
Object value) |
Number |
coerceNumber(Object inputArgument,
Class<?> paraType) |
static <T> T |
coerceWithFlag(Class<T> clz,
boolean[] flag,
Object value) |
static <T> T |
coerceWithFlag(Type coerceTo,
Class<T> clz,
boolean[] flag,
Object value) |
static Comparable |
comparable(Object comparable)
Cast an object to a comparable object.
|
static Collection<Object> |
createCollection(Class<?> type,
int size) |
static <T> T |
createFromArg(Class<T> clz,
Object value) |
static Map<?,?> |
createMap(Class<?> type,
int size) |
static double[] |
darray(Object value) |
static float[] |
farray(Object value) |
static int[] |
iarray(Object value) |
static <T> Iterator<T> |
iterator(Class<T> class1,
Object value) |
static Iterator |
iterator(Object value) |
static long[] |
larray(Object value) |
static int |
len(Object obj) |
static int |
lengthOf(Object obj) |
static <TO,FROM> List<TO> |
mapFilterNulls(Function<FROM,TO> converter,
Collection<FROM> fromCollection) |
static short[] |
sarray(Object value) |
static <T> T[] |
toArray(Class<T> componentType,
Collection<T> collection) |
static Object |
toArrayGuessType(Collection<?> value) |
static BigDecimal |
toBigDecimal(Object obj) |
static BigInteger |
toBigInteger(Object obj) |
static boolean |
toBoolean(Object value)
Converts the value to boolean.
|
static boolean |
toBoolean(Object obj,
boolean defaultValue)
Converts the value to boolean, and if it is null, it uses the default value passed.
|
static boolean |
toBooleanOrDie(Object obj) |
static byte |
toByte(Object obj) |
static byte |
toByte(Object obj,
byte defaultByte) |
static Calendar |
toCalendar(Date date) |
static char |
toChar(Object obj) |
static char |
toChar(Object obj,
char defaultChar) |
static Class<?> |
toClass(Object value) |
static Class<?> |
toClass(String str) |
static <T> T |
toCollection(Class<T> clz,
Object value) |
static Currency |
toCurrency(Object obj) |
static Date |
toDate(Calendar c) |
static Date |
toDate(long value) |
static Date |
toDate(Long value) |
static Date |
toDate(Object object) |
static Date |
toDate(String value) |
static Date |
toDateUS(String string) |
static double |
toDouble(Object obj) |
static <T extends Enum> |
toEnum(Class<T> cls,
int value) |
static <T extends Enum> |
toEnum(Class<T> cls,
Object value) |
static <T extends Enum> |
toEnum(Class<T> cls,
String value) |
static <T extends Enum> |
toEnum(Class<T> cls,
String value,
Enum defaultEnum) |
static <T extends Enum> |
toEnumOld(Class<T> cls,
String value) |
static <T extends Enum> |
toEnumOrDie(Class<T> cls,
int value) |
static Date |
toEuroDate(String string) |
static float |
toFloat(Object obj) |
static int |
toInt(Object obj) |
static int |
toInt(Object obj,
int defaultValue) |
static List |
toList(Object value) |
static long |
toLong(Object obj) |
static long |
toLong(Object obj,
long longDefault) |
static long |
toLongOrDie(Object obj) |
static Map<String,Object> |
toMap(Object value) |
static <T> T |
toPrimitiveArrayIfPossible(Class<T> clz,
Object value) |
static Set |
toSet(Object value) |
static short |
toShort(Object obj) |
static short |
toShort(Object obj,
short shortDefault) |
static SortedSet |
toSortedSet(Object value) |
static String |
toString(Object obj) |
static TimeZone |
toTimeZone(boolean[] flag,
Object value) |
static TimeZone |
toTimeZone(Object value) |
static Number |
toWrapper(int i) |
static Number |
toWrapper(long l) |
static Object |
unifyList(List list) |
static Object |
unifyList(Object o,
List list)
This flattens a list.
|
static Object |
unifyListOrArray(Object o) |
static Object |
unifyListOrArray(Object o,
List list)
This flattens a list.
|
static Object |
wrapAsObject(boolean i) |
static Object |
wrapAsObject(byte i) |
static Object |
wrapAsObject(double i) |
static Object |
wrapAsObject(float i) |
static Object |
wrapAsObject(int i) |
static Object |
wrapAsObject(long i) |
static Object |
wrapAsObject(short i) |
public static BigDecimal toBigDecimal(Object obj)
public static BigInteger toBigInteger(Object obj)
public static int toInt(Object obj)
public static int toInt(Object obj, int defaultValue)
public static byte toByte(Object obj)
public static byte toByte(Object obj, byte defaultByte)
public static short toShort(Object obj)
public static short toShort(Object obj, short shortDefault)
public static char toChar(Object obj)
public static char toChar(Object obj, char defaultChar)
public static long toLong(Object obj)
public static long toLongOrDie(Object obj)
public static long toLong(Object obj, long longDefault)
public static boolean toBoolean(Object value)
value
- valuepublic static boolean toBoolean(Object obj, boolean defaultValue)
obj
- value to convert to booleandefaultValue
- default valuepublic static boolean toBooleanOrDie(Object obj)
public static double toDouble(Object obj)
public static float toFloat(Object obj)
public static <T> T coerceWithFlag(Type coerceTo, Class<T> clz, boolean[] flag, Object value)
public static <T> T toPrimitiveArrayIfPossible(Class<T> clz, Object value)
public static double[] darray(Object value)
public static float[] farray(Object value)
public static long[] larray(Object value)
public static short[] sarray(Object value)
public static int[] iarray(Object value)
public static byte[] barray(Object value)
public static char[] carray(Object value)
public static Number toWrapper(long l)
public static Number toWrapper(int i)
public static Object wrapAsObject(boolean i)
public static Object wrapAsObject(byte i)
public static Object wrapAsObject(short i)
public static Object wrapAsObject(int i)
public static Object wrapAsObject(long i)
public static Object wrapAsObject(double i)
public static Object wrapAsObject(float i)
public static Object toArrayGuessType(Collection<?> value)
public static <T> T[] toArray(Class<T> componentType, Collection<T> collection)
public static <V> V[] array(Class<V> type, Collection<V> array)
public static Date toDate(long value)
public static Collection<Object> createCollection(Class<?> type, int size)
public static <TO,FROM> List<TO> mapFilterNulls(Function<FROM,TO> converter, Collection<FROM> fromCollection)
public static Object unifyListOrArray(Object o, List list)
o
- object that might be a listlist
- list to add o to or all of o's items to.public static Object unifyList(Object o, List list)
o
- object that might be a listlist
- list to add o to or all of o's items to.public static Comparable comparable(Object comparable)
comparable
- public static int lengthOf(Object obj)
public static int len(Object obj)
Copyright © 2014. All rights reserved.