@UsesConfiguration(value=CoercionTuple.class) public interface TypeCoercer
Coercions to convert between an input value (of some specific
type) and a desired output type. Smart about coercing, even if it requires multiple coercion steps (i.e., via an
intermediate type, such as String).| Modifier and Type | Method and Description |
|---|---|
void |
clearCache()
Clears cached information stored by the TypeCoercer.
|
<S,T> T |
coerce(S input,
Class<T> targetType)
Performs a coercion from an input type to a desired output type.
|
<S,T> String |
explain(Class<S> sourceType,
Class<T> targetType)
Used primarily inside test suites, this method performs the same steps as
coerce(Object, Class), but
returns a string describing the series of coercions, such as "Object --> String --> Long --> Integer". |
<S,T> Coercion<S,T> |
getCoercion(Class<S> sourceType,
Class<T> targetType)
Given a source and target type, computes the coercion that will be used.
|
<S,T> T coerce(S input, Class<T> targetType)
S - source type (input)T - target type (output)input - targetType - defines the target typeRuntimeException - if the input can not be coerced<S,T> Coercion<S,T> getCoercion(Class<S> sourceType, Class<T> targetType)
S - source type (input)T - target type (output)sourceType - type to coerce fromtargetType - defines the target type<S,T> String explain(Class<S> sourceType, Class<T> targetType)
coerce(Object, Class), but
returns a string describing the series of coercions, such as "Object --> String --> Long --> Integer".S - source type (input)T - target type (output)sourceType - the source coercion type (use void.class for coercions from null)targetType - defines the target typevoid clearCache()
5.6.4 - Copyright © 2003-2021 The Apache Software Foundation.