Interface CurrencyContextProvider<T>

Type Parameters:
T - the repository domain type that this currency provider manages
All Known Implementing Classes:
CompositeCurrencyContextProvider

public interface CurrencyContextProvider<T>

While mapping from a repository domain that stores a numeric value to a business domain that utilizes a MonetaryAmount this gives the facilities to resolve a currency for the given source repository object.

This interface can be used as standalone instances to configure the MonetaryMapperMember with. The MonetaryMapperMember will first consult the repository domain itself (via the CurrencyProvider interface) to retrieve a "default" currency. It then consults additionally-configured standalone members to give the ability to override the currency value for the mapping source. If neither the repository domain implements CurrencyProvider or there are no configured currency providers, the default system currency is used.

During Jackson deserialization this is used to initialize CurrencyContextAware objects

Author:
Phillip Verheyden (phillipuniverse)
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    default boolean
    canHandle(Object source, ContextInfo contextInfo)
    Whether or not this can handle the resolution for the given source.
    com.broadleafcommerce.money.CurrencyContext
    getContext(T source, ContextInfo contextInfo)
    Get the currency from a source object
  • Method Details

    • getContext

      @Nullable com.broadleafcommerce.money.CurrencyContext getContext(@NonNull T source, @Nullable ContextInfo contextInfo)
      Get the currency from a source object
      Parameters:
      source - what to use in the consideration of a currency
      Returns:
      a CurrencyUnit or null if not handled.
    • canHandle

      default boolean canHandle(@NonNull Object source, @Nullable ContextInfo contextInfo)
      Whether or not this can handle the resolution for the given source. Default behavior is to match whether or not this implementation declares whether or not it can handle this or child classes
      Parameters:
      source - the repository domain when mapping from a repository or the business domain instance when deserializing from Jackson
      Returns:
      whether or not this can be handled