Package science.aist.jack.general.util
Class CastUtils
- java.lang.Object
-
- science.aist.jack.general.util.CastUtils
-
public class CastUtils extends Object
Helper class for casting
- Since:
- 2.0
- Author:
- Andreas Pointner
-
-
Constructor Summary
Constructors Constructor Description CastUtils()
-
-
-
Method Detail
-
cast
public <S,T> T cast(S source)
Cast any given source to any type
Supports to cast elements:Object o = "abc"; String s = cast(o);
Supports to cast generic types:
List<Object> oList = ... List<String> sList = cast(oList);
- Type Parameters:
S
- the source typeT
- the target type- Parameters:
source
- the element to be casted- Returns:
- the casted result
- Throws:
ClassCastException
- if the cast fails
-
-