Class StrutsTypeConverterHolder
- All Implemented Interfaces:
TypeConverterHolder
TypeConverterHolder-
Field Summary
FieldsModifier and TypeFieldDescriptionDeprecated, for removal: This API element is subject to removal in a future version.since 7.3.0, unused - superseded by internal concurrent storage. -
Constructor Summary
Constructors -
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.since 7.3.0, usecomputeMappingIfAbsent(Class, Function)instead.voidaddNoMapping(Class clazz) Stores theNO_MAPPINGsentinel for the given class, replacing any mapping previously cached for it.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)instead.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)instead.
-
Field Details
-
unknownMappings
Deprecated, for removal: This API element is subject to removal in a future version.since 7.3.0, unused - superseded by internal concurrent storage. Retained only for binary compatibility with subclasses compiled against earlier versions, and will be removed in a future release.Record classes that doesn't have conversion mapping defined.- String -> classname as String
-
-
Constructor Details
-
StrutsTypeConverterHolder
public StrutsTypeConverterHolder()
-
-
Method Details
-
addDefaultMapping
Description copied from interface:TypeConverterHolderAdds mapping for default type converters - application scoped- Specified by:
addDefaultMappingin interfaceTypeConverterHolder- Parameters:
className- name of the class with associated convertertypeConverter-TypeConverterinstance for associated class
-
containsDefaultMapping
Description copied from interface:TypeConverterHolderChecks if converter was already defined for given class- Specified by:
containsDefaultMappingin interfaceTypeConverterHolder- Parameters:
className- name of the class to check for- Returns:
- true if default mapping was already specified
-
getDefaultMapping
Description copied from interface:TypeConverterHolderReturns instance ofTypeConverterassociated with given class- Specified by:
getDefaultMappingin interfaceTypeConverterHolder- 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)instead.Returnsnullifclazzhas been flagged as having no mapping viaaddNoMapping(Class), even if a real mapping was previously stored for it.- Specified by:
getMappingin interfaceTypeConverterHolder- 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) public 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)instead.Description copied from interface:TypeConverterHolderAssign mapping of converters for given class- Specified by:
addMappingin interfaceTypeConverterHolder- 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)instead.Description copied from interface:TypeConverterHolderCheck if there is no mapping for given class to convert- Specified by:
containsNoMappingin interfaceTypeConverterHolder- Parameters:
clazz- class to convert to/from- Returns:
- true if mapping couldn't be found
-
addNoMapping
Stores theNO_MAPPINGsentinel for the given class, replacing any mapping previously cached for it. This matches the pre-7.3.0 effective behaviour, back when a separate no-mapping collection was consulted independently of the mappings map: the only in-tree caller,XWorkConverter.getConverter, checked the no-mapping flag first and short-circuited before the cached mapping was ever read, so flagging a class as no-mapping made it behave as though it had no mapping, real cached mapping or not.Map.putIfAbsent(K, V)is deliberately not used here: it would leave a stale mapping being served for a class whose conversion build subsequently failed, which is a genuine behaviour change rather than a faithful port.- Specified by:
addNoMappingin interfaceTypeConverterHolder- Parameters:
clazz- class to register missing converter
-
computeMappingIfAbsent
public Map<String,Object> computeMappingIfAbsent(Class clazz, Function<Class, Map<String, Object>> builder) Description copied from interface:TypeConverterHolderReturns 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.
- Specified by:
computeMappingIfAbsentin interfaceTypeConverterHolder- 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
-
containsUnknownMapping
Description copied from interface:TypeConverterHolderChecks if no mapping was defined for given class name FIXME lukaszlenart: maybe it should be merged with NoMapping- Specified by:
containsUnknownMappingin interfaceTypeConverterHolder- Parameters:
className- name of the class to check for- Returns:
- true if converter was defined for given class name
-
addUnknownMapping
Description copied from interface:TypeConverterHolderAdds no converter flag for given class name FIXME lukaszlenart: maybe it should be merged with NoMapping- Specified by:
addUnknownMappingin interfaceTypeConverterHolder- Parameters:
className- name of the class to mark there is no converter for it
-