org.ijsberg.iglu.util.types
Class Converter
java.lang.Object
org.ijsberg.iglu.util.types.Converter
public abstract class Converter
- extends Object
Helper class that converts all kinds of primitives, primitive objects and strings.
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Converter
public Converter()
convertToInteger
public static Integer convertToInteger(Object input)
- Parameters:
input -
- Returns:
convertToLong
public static Long convertToLong(Object input)
- Parameters:
input -
- Returns:
convertToShort
public static Short convertToShort(Object input)
- Parameters:
input -
- Returns:
convertToByte
public static Byte convertToByte(Object input)
- Parameters:
input -
- Returns:
convertToFloat
public static Float convertToFloat(Object input)
- Parameters:
input -
- Returns:
convertToDouble
public static Double convertToDouble(Object input)
- Parameters:
input -
- Returns:
convertToBoolean
public static Boolean convertToBoolean(Object input)
- Parameters:
input -
- Returns:
convertToCharacter
public static Character convertToCharacter(Object input)
- Parameters:
input -
- Returns:
convertToPrimitive
protected static Object convertToPrimitive(Object source,
Class<?> type)
convertToObject
public static Object convertToObject(Object source,
Class<?> type)
- Parameters:
source - type - desired type
- Returns:
- converted source object
- Throws:
IllegalArgumentException - in case the object can not be converted to the desired type
convertToMatchingTypes
public static Object[] convertToMatchingTypes(Object[] objects,
Class<?>[] targetTypes)
- Tries to convert the objects in the array into the types specified.
This is typically useful if a method is invoked command-line by reflection.
- Parameters:
objects - targetTypes - needed input types
- Returns:
- the converted objects
- Throws:
IllegalArgumentException - in case conversion is not possible
Copyright © 2011. All Rights Reserved.