public class TypeCoercerImpl extends LockSupport implements TypeCoercer
Constructor and Description |
---|
TypeCoercerImpl(Collection<CoercionTuple> tuples) |
Modifier and Type | Method and Description |
---|---|
void |
clearCache()
Clears cached information stored by the TypeCoercer.
|
Object |
coerce(Object input,
Class 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
TypeCoercer.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.
|
acquireReadLock, downgradeWriteLockToReadLock, releaseReadLock, releaseWriteLock, takeWriteLock, upgradeReadLockToWriteLock
public TypeCoercerImpl(Collection<CoercionTuple> tuples)
public Object coerce(Object input, Class targetType)
TypeCoercer
coerce
in interface TypeCoercer
targetType
- defines the target typepublic <S,T> Coercion<S,T> getCoercion(Class<S> sourceType, Class<T> targetType)
TypeCoercer
getCoercion
in interface TypeCoercer
S
- source type (input)T
- target type (output)sourceType
- type to coerce fromtargetType
- defines the target typepublic <S,T> String explain(Class<S> sourceType, Class<T> targetType)
TypeCoercer
TypeCoercer.coerce(Object, Class)
, but
returns a string describing the series of coercions, such as "Object --> String --> Long --> Integer".explain
in interface TypeCoercer
S
- source type (input)T
- target type (output)sourceType
- the source coercion type (use void.class for coercions from null)targetType
- defines the target typepublic void clearCache()
TypeCoercer
clearCache
in interface TypeCoercer
${project.version} - Copyright © 2003-2015 The Apache Software Foundation.