Class PremiumListDao


  • public class PremiumListDao
    extends java.lang.Object
    Data access object class for accessing PremiumList objects from Cloud SQL.

    This class handles both the mapping from string to SQL-level PremiumList objects as well as the mapping and retrieval of PremiumList.PremiumEntry objects that correspond to the particular PremiumList object in SQL, and caching these entries so that future lookups can be quicker.

    • Method Detail

      • setPremiumListCacheForTest

        public static void setPremiumListCacheForTest​(java.util.Optional<java.time.Duration> expiry)
      • createPremiumListCache

        public static com.github.benmanes.caffeine.cache.LoadingCache<java.lang.String,​java.util.Optional<PremiumList>> createPremiumListCache​(java.time.Duration cachePersistDuration)
      • getLatestRevision

        public static java.util.Optional<PremiumList> getLatestRevision​(java.lang.String premiumListName)
        Returns the most recent revision of the PremiumList with the specified name, if it exists.

        Note that this does not load PremiumList.labelsToPrices! If you need to check prices, use getPremiumPrice(java.lang.String, java.lang.String).

      • getPremiumPrice

        public static java.util.Optional<org.joda.money.Money> getPremiumPrice​(java.lang.String premiumListName,
                                                                               java.lang.String label)
        Returns the premium price for the specified label and registry, or absent if the label is not premium.
      • save

        public static PremiumList save​(java.lang.String name,
                                       org.joda.money.CurrencyUnit currencyUnit,
                                       java.util.List<java.lang.String> inputData)
      • save

        public static PremiumList save​(PremiumList premiumList)
        Saves the given premium list (and its premium list entries) to Cloud SQL.
      • delete

        public static void delete​(PremiumList premiumList)
      • loadPremiumEntries

        public static java.util.List<PremiumList.PremiumEntry> loadPremiumEntries​(PremiumList premiumList)
        Returns all PremiumEntries in the given premiumList.

        This is an expensive operation and should only be used when the entire list is required.

      • loadAllPremiumEntries

        public static com.google.common.collect.ImmutableList<PremiumList.PremiumEntry> loadAllPremiumEntries​(java.lang.String premiumListName)
        Returns all PremiumEntries in the list with the given name.

        This is an expensive operation and should only be used when the entire list is required.