Package org.apache.juneau.internal
Class ConverterUtils
java.lang.Object
org.apache.juneau.internal.ConverterUtils
Utility class for efficiently converting objects between types.
 
   
 
If the value isn't an instance of the specified type, then converts the value if possible.
The following conversions are valid:
| Convert to type | Valid input value types | Notes | 
|---|---|---|
| A class that is the normal type of a registered ObjectSwap. | A value whose class matches the transformed type of that registered ObjectSwap. | |
| A class that is the transformed type of a registered ObjectSwap. | A value whose class matches the normal type of that registered ObjectSwap. | |
| Number(e.g.Integer,Short,Float,...)Number.(e.g.Integer.,Short.,Float.,...) | Number,String, | For primitive TYPES, | 
| Map(e.g.Map,HashMap,TreeMap,JsonMap) | Map | If Mapis not constructible, anJsonMapis created. | 
|  |  | If | 
|  |  | |
|  |  | |
|  |  | |
| Bean |  | |
|  | Anything | Arrays are converted to JSON arrays | 
| Anything with one of the following methods:  |  |  | 
See Also:
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionstatic BooleanConverts an object to a Boolean.static IntegerConverts an object to an Integer.static NumberConverts an object to a Number.static <T> TConverts the specified object to the specified type.static <T> TConverts the specified object to the specified type.
- 
Constructor Details- 
ConverterUtilspublic ConverterUtils()
 
- 
- 
Method Details- 
toTypeConverts the specified object to the specified type.- Type Parameters:
- T- The class type to convert the value to.
- Parameters:
- value- The value to convert.
- type- The class type to convert the value to.
- Returns:
- The converted value.
- Throws:
- InvalidDataConversionException- If the specified value cannot be converted to the specified type.
 
- 
toTypeConverts the specified object to the specified type.- Type Parameters:
- T- The class type to convert the value to.
- Parameters:
- value- The value to convert.
- type- The class type to convert the value to.
- args- The type arguments.
- Returns:
- The converted value.
- Throws:
- InvalidDataConversionException- If the specified value cannot be converted to the specified type.
 
- 
toBooleanConverts an object to a Boolean.- Parameters:
- o- The object to convert.
- Returns:
- The converted object.
 
- 
toIntegerConverts an object to an Integer.- Parameters:
- o- The object to convert.
- Returns:
- The converted object.
 
- 
toNumberConverts an object to a Number.- Parameters:
- o- The object to convert.
- Returns:
- The converted object.
 
 
-