Class TypeCoercerImpl
java.lang.Object
org.apache.tapestry5.commons.internal.util.LockSupport
org.apache.tapestry5.commons.internal.services.TypeCoercerImpl
- All Implemented Interfaces:
TypeCoercer
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Clears cached information stored by the TypeCoercer.Performs a coercion from an input type to a desired output type.<S,
T> String Used primarily inside test suites, this method performs the same steps asTypeCoercer.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.Methods inherited from class org.apache.tapestry5.commons.internal.util.LockSupport
acquireReadLock, downgradeWriteLockToReadLock, releaseReadLock, releaseWriteLock, takeWriteLock, upgradeReadLockToWriteLock
-
Constructor Details
-
TypeCoercerImpl
-
-
Method Details
-
coerce
Description copied from interface:TypeCoercer
Performs a coercion from an input type to a desired output type. When the target type is a primitive, the actual conversion will be to the equivalent wrapper type. In some cases, the TypeCoercer will need to search for an appropriate coercion, and may even combine existing coercions to form new ones; in those cases, the results of the search are cached. The TypeCoercer also caches the results of a coercion search.- Specified by:
coerce
in interfaceTypeCoercer
targetType
- defines the target type- Returns:
- the coerced value
-
getCoercion
Description copied from interface:TypeCoercer
Given a source and target type, computes the coercion that will be used. 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).- Specified by:
getCoercion
in interfaceTypeCoercer
- Type Parameters:
S
- source type (input)T
- target type (output)- Parameters:
sourceType
- type to coerce fromtargetType
- defines the target type- Returns:
- the coercion that will ultimately be used
-
explain
Description copied from interface:TypeCoercer
Used primarily inside test suites, this method performs the same steps asTypeCoercer.coerce(Object, Class)
, but returns a string describing the series of coercions, such as "Object --> String --> Long --> Integer".- Specified by:
explain
in interfaceTypeCoercer
- Type Parameters:
S
- source type (input)T
- target type (output)- Parameters:
sourceType
- the source coercion type (use void.class for coercions from null)targetType
- defines the target type- Returns:
- a string identifying the series of coercions, or the empty string if no coercion is necessary
-
clearCache
Description copied from interface:TypeCoercer
Clears cached information stored by the TypeCoercer.- Specified by:
clearCache
in interfaceTypeCoercer
-