Package xyz.cp74.utils
Class CastUtils
- java.lang.Object
-
- xyz.cp74.utils.CastUtils
-
public class CastUtils extends Object
CastUtils Cast different things to different things- Author:
- Christian Paul
-
-
Constructor Summary
Constructors Constructor Description CastUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static doubletoDouble(Object o)Cast object to doublestatic doubletoDouble(Object o, double defaultValue)Cast object to doublestatic IntegertoInteger(Object o)Cast object to integerstatic IntegertoInteger(Object o, int defaultValue)Cast object to integerstatic List<String>toListOfStrings(Object o)Cast object to a list of stringsstatic LongtoLong(Object o)Cast object to longstatic LongtoLong(Object o, long defaultValue)Cast object to longstatic Set<String>toSetOfStrings(Object o)Cast object to a set of stringsstatic StringtoString(Object o)Cast object to stringstatic StringtoString(Object o, String defaultValue)Cast object to string
-
-
-
Method Detail
-
toInteger
public static Integer toInteger(Object o)
Cast object to integer- Parameters:
o- object to cast- Returns:
- integer
-
toInteger
public static Integer toInteger(Object o, int defaultValue)
Cast object to integer- Parameters:
o- object to castdefaultValue- default return value, if object is not castable- Returns:
- integer
-
toLong
public static Long toLong(Object o)
Cast object to long- Parameters:
o- object to cast- Returns:
- long
-
toLong
public static Long toLong(Object o, long defaultValue)
Cast object to long- Parameters:
o- object to castdefaultValue- default return value, if object is not castable- Returns:
- long
-
toDouble
public static double toDouble(Object o)
Cast object to double- Parameters:
o- object to cast- Returns:
- double
-
toDouble
public static double toDouble(Object o, double defaultValue)
Cast object to double- Parameters:
o- object to castdefaultValue- default reurn value, if object is not castable- Returns:
- double
-
toString
public static String toString(Object o)
Cast object to string- Parameters:
o- object to cast- Returns:
- string
-
toString
public static String toString(Object o, String defaultValue)
Cast object to string- Parameters:
o- object to castdefaultValue- default return value, if object is null- Returns:
- string
-
toListOfStrings
public static List<String> toListOfStrings(Object o)
Cast object to a list of strings- Parameters:
o- object to cast- Returns:
- list of strings
-
-