const classafIoc::TypeCoercer
sys::Obj afIoc::TypeCoercer
A helper class that coerces Objs to a given Type via fromXXX() / toXXX() ctors and methods. This is mainly useful for converting to and from Strs.
As a lot of repetition of types is expected for each TypeCoercer the conversion methods are cached.
@since 1.3.8
- canCoerce
Bool canCoerce(Type fromType, Type toType)Returns
trueiffromTypecan be coerced to the giventoType.- clearCache
Void clearCache()Clears the lookup cache
- coerce
Obj coerce(Obj value, Type toType)Coerces the Obj to the given type. Coercion methods are looked up in the following order:
- toXXX()
- fromXXX()
- makeFromXXX()