public class ConversionUtils extends Object
For extensible type conversion, use ConvertService
.
Modifier and Type | Method and Description |
---|---|
static boolean |
canCast(Class<?> src,
Class<?> dest)
Checks whether objects of the given class can be cast to the specified
type.
|
static boolean |
canCast(Object src,
Class<?> dest)
Checks whether the given object can be cast to the specified type.
|
static boolean |
canConvert(Class<?> src,
Class<?> dest)
Deprecated.
|
static boolean |
canConvert(Class<?> src,
Type dest)
Deprecated.
|
static boolean |
canConvert(Object src,
Class<?> dest)
Deprecated.
|
static boolean |
canConvert(Object src,
Type dest)
Deprecated.
|
static <T> T |
cast(Object src,
Class<T> dest)
Casts the given object to the specified type, or null if the types are
incompatible.
|
static <T> T |
convert(Object src,
Class<T> dest)
Deprecated.
|
static Object |
convert(Object src,
Type dest)
Deprecated.
|
static <T> T |
convertToEnum(String src,
Class<T> dest)
Converts the given string value to an enumeration constant of the specified
type.
|
static Class<?> |
getClass(Type type)
Deprecated.
|
static Class<?> |
getComponentClass(Type type)
Deprecated.
|
static <T> Class<T> |
getNonprimitiveType(Class<T> type)
Returns the non-primitive
Class closest to the given type. |
static <T> T |
getNullValue(Class<T> type)
Gets the "null" value for the given type.
|
static void |
setDelegateService(ConvertService convertService,
double priority)
Sets the
ConvertService to use for handling conversion requests. |
public static <T> T convertToEnum(String src, Class<T> dest)
src
- The value to convert.dest
- The type of the enumeration constant.public static <T> T cast(Object src, Class<T> dest)
public static boolean canCast(Class<?> src, Class<?> dest)
cast(Object, Class)
public static boolean canCast(Object src, Class<?> dest)
cast(Object, Class)
public static <T> Class<T> getNonprimitiveType(Class<T> type)
Class
closest to the given type.
Specifically, the following type conversions are done:
public static <T> T getNullValue(Class<T> type)
public static void setDelegateService(ConvertService convertService, double priority)
ConvertService
to use for handling conversion requests.@Deprecated public static Object convert(Object src, Type dest)
Converter.convert(Object, Type)
@Deprecated public static <T> T convert(Object src, Class<T> dest)
Converter.convert(Object, Class)
@Deprecated public static boolean canConvert(Class<?> src, Type dest)
Converter.canConvert(Class, Type)
@Deprecated public static boolean canConvert(Class<?> src, Class<?> dest)
Converter.canConvert(Class, Class)
@Deprecated public static boolean canConvert(Object src, Type dest)
Converter.canConvert(Object, Type)
@Deprecated public static boolean canConvert(Object src, Class<?> dest)
Converter.canConvert(Object, Class)
@Deprecated public static Class<?> getClass(Type type)
GenericUtils.getClass(Type)
@Deprecated public static Class<?> getComponentClass(Type type)
GenericUtils.getComponentClass(Type)
Copyright © 2009–2015 SciJava. All rights reserved.