Package google.registry.model.tld.label
Class PremiumListDao
- java.lang.Object
-
- google.registry.model.tld.label.PremiumListDao
-
public class PremiumListDao extends java.lang.Object
Data access object class for accessingPremiumList
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 particularPremiumList
object in SQL, and caching these entries so that future lookups can be quicker.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static com.github.benmanes.caffeine.cache.LoadingCache<java.lang.String,java.util.Optional<PremiumList>>
createPremiumListCache(java.time.Duration cachePersistDuration)
static void
delete(PremiumList premiumList)
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.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.static com.google.common.collect.ImmutableList<PremiumList.PremiumEntry>
loadAllPremiumEntries(java.lang.String premiumListName)
Returns allPremiumEntries
in the list with the given name.static java.util.List<PremiumList.PremiumEntry>
loadPremiumEntries(PremiumList premiumList)
Returns allPremiumEntries
in the givenpremiumList
.static PremiumList
save(PremiumList premiumList)
Saves the given premium list (and its premium list entries) to Cloud SQL.static PremiumList
save(java.lang.String name, org.joda.money.CurrencyUnit currencyUnit, java.util.List<java.lang.String> inputData)
static void
setPremiumListCacheForTest(java.util.Optional<java.time.Duration> expiry)
-
-
-
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, usegetPremiumPrice(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 allPremiumEntries
in the givenpremiumList
.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 allPremiumEntries
in the list with the given name.This is an expensive operation and should only be used when the entire list is required.
-
-