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 Iterable<?> |
convertToIterable(Object value)
Converts an arbitrary value to an iterable type.
|
static Set<String> |
convertToSet(String[] values,
boolean ignoreEmpty)
Converts an array of string values to a set.
|
static Object |
invokeMethod(Object instance,
Method method,
Object... args)
Invokes a method with the provided value(s), performing type conversion as necessary.
|
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 Iterable<?> convertToIterable(Object value)
value - Value to convert. This may be any iterable, an array, a map (in which case the
map's entry set is used), a scalar value, or null.public static Set<String> convertToSet(String[] values, boolean ignoreEmpty)
values - Array of string values.ignoreEmpty - If true, empty elements are ignored.public static Object invokeMethod(Object instance, Method method, Object... args)
instance - Instance that is the target of the invocation (may be null for static
methods).method - The method to invoke.args - Arguments to be passed to method (may be null if no arguments). Argument values
will be coerced to the expected type if possible.Copyright © 2018 Fujion Framework. All rights reserved.