Interface TypeConverterHolder

All Known Implementing Classes:
StrutsTypeConverterHolder

public interface TypeConverterHolder
Holds all mappings related to TypeConverters
  • Method Details

    • addDefaultMapping

      void addDefaultMapping(String className, TypeConverter typeConverter)
      Adds mapping for default type converters - application scoped
      Parameters:
      className - name of the class with associated converter
      typeConverter - TypeConverter instance for associated class
    • containsDefaultMapping

      boolean containsDefaultMapping(String className)
      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

      TypeConverter getDefaultMapping(String className)
      Returns instance of TypeConverter associated with given class
      Parameters:
      className - name of the class to return converter for
      Returns:
      instance of TypeConverter to be used to convert class
    • getMapping

      @Deprecated(since="7.3.0", forRemoval=true) Map<String,Object> getMapping(Class clazz)
      Deprecated, for removal: This API element is subject to removal in a future version.
      since 7.3.0, use computeMappingIfAbsent(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 null if the class has been flagged as having no mapping via addNoMapping(Class), even if a real mapping was previously stored for it with addMapping(Class, Map).

      Parameters:
      clazz - class to convert to/from
      Returns:
      the property-converter mapping for the given class, or null if 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, use computeMappingIfAbsent(Class, Function) which stores the built mapping itself.
      Assign mapping of converters for given class
      Parameters:
      clazz - class to convert to/from
      mapping - property converters
    • containsNoMapping

      @Deprecated(since="7.3.0", forRemoval=true) boolean containsNoMapping(Class clazz)
      Deprecated, for removal: This API element is subject to removal in a future version.
      since 7.3.0, use computeMappingIfAbsent(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

      void addNoMapping(Class clazz)
      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

      boolean containsUnknownMapping(String className)
      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

      void addUnknownMapping(String className)
      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 returns null: a class known to have no mapping yields an empty map.

      If the builder returns null or 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/from
      builder - 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