public class ConvertUtil extends Object
| Modifier and Type | Method and Description |
|---|---|
static <T> T |
convert(Object value,
Class<T> targetType)
Converts an input value to a target type.
|
static <T> T |
convert(Object value,
Class<T> targetType,
Object instance)
Converts an input value to a target type.
|
static String |
convertToJS(String snippet)
Process a Javascript code snippet.
|
static void |
invokeSetter(Object instance,
Method setter,
Object... args)
Invokes a setter with the provided value(s), performing type conversion as necessary.
|
static List<OptionMap> |
toOptionMaps(Collection<? extends OptionMap.IOptionMapConverter> items)
Converts a collection of IOptionMapConverter items to a list of maps.
|
public static <T> T convert(Object value, Class<T> targetType)
T - The target type.value - The value to convert.targetType - The type to which to convert.public static <T> T convert(Object value, Class<T> targetType, Object instance)
T - The target type.value - The value to convert.targetType - The type to which to convert.instance - The object instance whose property value is to be set (necessary when the
target type is a component and the value is the component name or id).public static String convertToJS(String snippet)
snippet - JS code snippet.public static List<OptionMap> toOptionMaps(Collection<? extends OptionMap.IOptionMapConverter> items)
items - IOptionMapConverter items to convert.public static void invokeSetter(Object instance, Method setter, Object... args)
instance - Instance to receive the value (may be null for static methods).setter - The method to receive the value.args - Arguments to be passed to method. Argument values will be coerced to the expected
type if possible.Copyright © 2017 Regenstrief Center for Biomedical Informatics. All rights reserved.