Interface TypeConverterHolder
- All Known Implementing Classes:
StrutsTypeConverterHolder
TypeConverters-
Method Summary
Modifier and TypeMethodDescriptionvoidaddDefaultMapping(String className, TypeConverter typeConverter) Adds mapping for default type converters - application scopedvoidaddMapping(Class clazz, Map<String, Object> mapping) Deprecated, for removal: This API element is subject to removal in a future version.voidaddNoMapping(Class clazz) Adds no mapping flag for give class.voidaddUnknownMapping(String className) Adds no converter flag for given class name FIXME lukaszlenart: maybe it should be merged with NoMappingReturns the property-converter mapping for the given class, building and caching it on first use.booleancontainsDefaultMapping(String className) Checks if converter was already defined for given classbooleancontainsNoMapping(Class clazz) Deprecated, for removal: This API element is subject to removal in a future version.since 7.3.0, usecomputeMappingIfAbsent(Class, Function)which returns an empty map for classes known to have no mapping.booleancontainsUnknownMapping(String className) Checks if no mapping was defined for given class name FIXME lukaszlenart: maybe it should be merged with NoMappinggetDefaultMapping(String className) Returns instance ofTypeConverterassociated with given classgetMapping(Class clazz) Deprecated, for removal: This API element is subject to removal in a future version.since 7.3.0, usecomputeMappingIfAbsent(Class, Function), which resolves and caches the mapping in one call instead of requiring a check-then-act at the call site.
-
Method Details
-
addDefaultMapping
Adds mapping for default type converters - application scoped- Parameters:
className- name of the class with associated convertertypeConverter-TypeConverterinstance for associated class
-
containsDefaultMapping
Checks if converter was already defined for given class- Parameters:
className- name of the class to check for- Returns:
- true if default mapping was already specified
-
getDefaultMapping
Returns instance ofTypeConverterassociated with given class- Parameters:
className- name of the class to return converter for- Returns:
- instance of
TypeConverterto be used to convert class
-
getMapping
Deprecated, for removal: This API element is subject to removal in a future version.since 7.3.0, usecomputeMappingIfAbsent(Class, Function), which resolves and caches the mapping in one call instead of requiring a check-then-act at the call site.Target class conversion Mappings.Returns
nullif the class has been flagged as having no mapping viaaddNoMapping(Class), even if a real mapping was previously stored for it withaddMapping(Class, Map).- Parameters:
clazz- class to convert to/from- Returns:
- the property-converter mapping for the given class, or
nullif none
-
addMapping
@Deprecated(since="7.3.0", forRemoval=true) void addMapping(Class clazz, Map<String, Object> mapping) Deprecated, for removal: This API element is subject to removal in a future version.since 7.3.0, usecomputeMappingIfAbsent(Class, Function)which stores the built mapping itself.Assign mapping of converters for given class- Parameters:
clazz- class to convert to/frommapping- property converters
-
containsNoMapping
Deprecated, for removal: This API element is subject to removal in a future version.since 7.3.0, usecomputeMappingIfAbsent(Class, Function)which returns an empty map for classes known to have no mapping.Check if there is no mapping for given class to convert- Parameters:
clazz- class to convert to/from- Returns:
- true if mapping couldn't be found
-
addNoMapping
Adds no mapping flag for give class. Flagging a class as having no mapping may replace any mapping previously cached for it; callers should treat this flag as authoritative over a previously cached mapping.- Parameters:
clazz- class to register missing converter
-
containsUnknownMapping
Checks if no mapping was defined for given class name FIXME lukaszlenart: maybe it should be merged with NoMapping- Parameters:
className- name of the class to check for- Returns:
- true if converter was defined for given class name
-
addUnknownMapping
Adds no converter flag for given class name FIXME lukaszlenart: maybe it should be merged with NoMapping- Parameters:
className- name of the class to mark there is no converter for it
-
computeMappingIfAbsent
default Map<String,Object> computeMappingIfAbsent(Class clazz, Function<Class, Map<String, Object>> builder) Returns the property-converter mapping for the given class, building and caching it on first use. Never returnsnull: a class known to have no mapping yields an empty map.If the builder returns
nullor an empty map, the class is recorded in the negative cache so the builder is not invoked for it again.Implementations only guarantee that all callers converge on the same cached mapping instance for a given class - not that the builder runs at most once. Under concurrent first access, the builder may be invoked more than once (each on a different thread, for the same class); only one of the resulting mappings is retained and returned to every caller. The builder must therefore be idempotent and free of side effects on the holder itself. The default implementation is a non-atomic check-then-act using the deprecated primitives, preserving pre-7.3.0 behaviour for third-party holders that do not override it.
- Parameters:
clazz- class to convert to/frombuilder- builds the property-converter mapping for the class when it is not yet cached- Returns:
- the mapping for the class, or an empty map if it has none
- Since:
- 7.3.0
-
computeMappingIfAbsent(Class, Function)which stores the built mapping itself.