@Immutable public final class TypeConverter extends Object
TypeConverterRegistry.getFuzzyConverter(Class, Class) for
retrieving a registered converter. If no converter is found, it is checked
whether a mapping from a primitive type to an object type exists.| Modifier and Type | Method and Description |
|---|---|
static <DSTTYPE> DSTTYPE |
convert(boolean aSrcValue,
Class<DSTTYPE> aDstClass) |
static <DSTTYPE> DSTTYPE |
convert(byte aSrcValue,
Class<DSTTYPE> aDstClass) |
static <DSTTYPE> DSTTYPE |
convert(char aSrcValue,
Class<DSTTYPE> aDstClass) |
static <DSTTYPE> DSTTYPE |
convert(double aSrcValue,
Class<DSTTYPE> aDstClass) |
static <DSTTYPE> DSTTYPE |
convert(float aSrcValue,
Class<DSTTYPE> aDstClass) |
static <DSTTYPE> DSTTYPE |
convert(int aSrcValue,
Class<DSTTYPE> aDstClass) |
static <DSTTYPE> DSTTYPE |
convert(long aSrcValue,
Class<DSTTYPE> aDstClass) |
static <DSTTYPE> DSTTYPE |
convert(short aSrcValue,
Class<DSTTYPE> aDstClass) |
static <DSTTYPE> DSTTYPE |
convertIfNecessary(ITypeConverterProvider aTypeConverterProvider,
Object aSrcValue,
Class<DSTTYPE> aDstClass)
Convert the passed source value to the destination class, if a conversion
is necessary.
|
static <DSTTYPE> DSTTYPE |
convertIfNecessary(Object aSrcValue,
Class<DSTTYPE> aDstClass)
Convert the passed source value to the destination class, if a conversion
is necessary.
|
static boolean |
convertToBoolean(Object aSrcValue)
Convert the passed source value to boolean
|
static byte |
convertToByte(Object aSrcValue)
Convert the passed source value to byte
|
static char |
convertToChar(Object aSrcValue)
Convert the passed source value to char
|
static double |
convertToDouble(Object aSrcValue)
Convert the passed source value to double
|
static float |
convertToFloat(Object aSrcValue)
Convert the passed source value to float
|
static int |
convertToInt(Object aSrcValue)
Convert the passed source value to int
|
static long |
convertToLong(Object aSrcValue)
Convert the passed source value to long
|
static short |
convertToShort(Object aSrcValue)
Convert the passed source value to short
|
@Nullable public static <DSTTYPE> DSTTYPE convert(boolean aSrcValue, @Nonnull Class<DSTTYPE> aDstClass)
@Nullable public static <DSTTYPE> DSTTYPE convert(byte aSrcValue, @Nonnull Class<DSTTYPE> aDstClass)
@Nullable public static <DSTTYPE> DSTTYPE convert(char aSrcValue, @Nonnull Class<DSTTYPE> aDstClass)
@Nullable public static <DSTTYPE> DSTTYPE convert(double aSrcValue, @Nonnull Class<DSTTYPE> aDstClass)
@Nullable public static <DSTTYPE> DSTTYPE convert(float aSrcValue, @Nonnull Class<DSTTYPE> aDstClass)
@Nullable public static <DSTTYPE> DSTTYPE convert(int aSrcValue, @Nonnull Class<DSTTYPE> aDstClass)
@Nullable public static <DSTTYPE> DSTTYPE convert(long aSrcValue, @Nonnull Class<DSTTYPE> aDstClass)
@Nullable public static <DSTTYPE> DSTTYPE convert(short aSrcValue, @Nonnull Class<DSTTYPE> aDstClass)
public static boolean convertToBoolean(@Nonnull Object aSrcValue)
aSrcValue - The source value. May not be null.null if the source value was null.IllegalArgumentException - if the conversion process fails because either the conversion
failed, or no converter was found.TypeConverterException - if the source value is nullTypeConverterProviderBestMatchpublic static byte convertToByte(@Nonnull Object aSrcValue)
aSrcValue - The source value. May not be null.null if the source value was null.IllegalArgumentException - if the conversion process fails because either the conversion
failed, or no converter was found.TypeConverterException - if the source value is nullTypeConverterProviderBestMatchpublic static char convertToChar(@Nonnull Object aSrcValue)
aSrcValue - The source value. May not be null.null if the source value was null.IllegalArgumentException - if the conversion process fails because either the conversion
failed, or no converter was found.TypeConverterException - if the source value is nullTypeConverterProviderBestMatchpublic static double convertToDouble(@Nonnull Object aSrcValue)
aSrcValue - The source value. May not be null.null if the source value was null.IllegalArgumentException - if the conversion process fails because either the conversion
failed, or no converter was found.TypeConverterException - if the source value is nullTypeConverterProviderBestMatchpublic static float convertToFloat(@Nonnull Object aSrcValue)
aSrcValue - The source value. May not be null.null if the source value was null.IllegalArgumentException - if the conversion process fails because either the conversion
failed, or no converter was found.TypeConverterException - if the source value is nullTypeConverterProviderBestMatchpublic static int convertToInt(@Nonnull Object aSrcValue)
aSrcValue - The source value. May not be null.null if the source value was null.IllegalArgumentException - if the conversion process fails because either the conversion
failed, or no converter was found.TypeConverterException - if the source value is nullTypeConverterProviderBestMatchpublic static long convertToLong(@Nonnull Object aSrcValue)
aSrcValue - The source value. May not be null.null if the source value was null.IllegalArgumentException - if the conversion process fails because either the conversion
failed, or no converter was found.TypeConverterException - if the source value is nullTypeConverterProviderBestMatchpublic static short convertToShort(@Nonnull Object aSrcValue)
aSrcValue - The source value. May not be null.null if the source value was null.IllegalArgumentException - if the conversion process fails because either the conversion
failed, or no converter was found.TypeConverterException - if the source value is nullTypeConverterProviderBestMatch@Nullable public static <DSTTYPE> DSTTYPE convertIfNecessary(@Nullable Object aSrcValue, @Nonnull Class<DSTTYPE> aDstClass)
DSTTYPE - The destination type.aSrcValue - The source value. May be null.aDstClass - The destination class to use.null if the source value was null.IllegalArgumentException - if the conversion process fails because either the conversion
failed, or no converter was found.TypeConverterException - If either no converter could be found, or if the conversion failed!TypeConverterProviderBestMatch@Nullable public static <DSTTYPE> DSTTYPE convertIfNecessary(@Nonnull ITypeConverterProvider aTypeConverterProvider, @Nullable Object aSrcValue, @Nonnull Class<DSTTYPE> aDstClass) throws TypeConverterException
DSTTYPE - The destination type.aTypeConverterProvider - The type converter provider. May not be null. .aSrcValue - The source value. May be null.aDstClass - The destination class to use.null if the source value was null.IllegalArgumentException - if the conversion process fails because either the conversion
failed, or no converter was found.TypeConverterException - If either no converter could be found, or if the conversion failed!Copyright © 2006–2014 phloc systems. All rights reserved.