|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
@UsesConfiguration(value=CoercionTuple.class) public interface TypeCoercer
Makes use of 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).
| Method Summary | ||
|---|---|---|
void |
clearCache()
Clears cached information stored by the TypeCoercer. |
|
|
coerce(S input,
Class<T> targetType)
Performs a coercion from an input type to a desired output type. |
|
|
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". |
|
|
getCoercion(Class<S> sourceType,
Class<T> targetType)
Given a source and target type, computes the coercion that will be used. |
|
| Method Detail |
|---|
<S,T> T coerce(S input,
Class<T> targetType)
S - source type (input)T - target type (output)input - targetType - defines the target type
RuntimeException - if the input can not be coerced
<S,T> Coercion<S,T> getCoercion(Class<S> sourceType,
Class<T> targetType)
Note: holding the returned coercion past the time when the cache is cleared can cause a memory leak, especially in the context of live reloading (wherein holding a reference to a single class make keep an entire ClassLoader from being reclaimed).
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 type
void clearCache()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||