Add data model entities for .app discounting

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=121580499
This commit is contained in:
mcilwain 2016-05-05 08:19:28 -07:00 committed by Justine Tunney
parent b435e20cbe
commit 3ec6aebe44
8 changed files with 43 additions and 904 deletions

View file

@ -139,8 +139,23 @@ public class TimedTransitionProperty<V, T extends TimedTransitionProperty.TimedT
public static <V, T extends TimedTransition<V>> TimedTransitionProperty<V, T> forMapify(
ImmutableSortedMap<DateTime, V> valueMap,
Class<T> timedTransitionSubclass) {
return new TimedTransitionProperty<>(new TreeMap<>(
makeTransitionMap(valueMap, timedTransitionSubclass)));
return new TimedTransitionProperty<>(
new TreeMap<>(makeTransitionMap(valueMap, timedTransitionSubclass)));
}
/**
* Returns a new mutable {@code TimedTransitionProperty} representing the given value being set at
* start of time, constructed using the given {@code TimedTransition} subclass.
*
* <p>
* This method should only be used for initializing fields that are declared with the @Mapify
* annotation. The map for those fields must be mutable so that Objectify can load values from the
* datastore into the map, but clients should still never mutate the field's map directly.
*/
public static <V, T extends TimedTransition<V>> TimedTransitionProperty<V, T> forMapify(
V valueAtStartOfTime, Class<T> timedTransitionSubclass) {
return forMapify(
ImmutableSortedMap.of(START_OF_TIME, valueAtStartOfTime), timedTransitionSubclass);
}
/** The backing map of DateTime to TimedTransition subclass used to store the transitions. */

View file

@ -24,7 +24,6 @@ import static google.registry.model.ofy.Ofy.RECOMMENDED_MEMCACHE_EXPIRATION;
import static google.registry.model.registry.label.PremiumList.getPremiumPrice;
import static google.registry.util.CollectionUtils.nullToEmptyImmutableCopy;
import static google.registry.util.DateTimeUtils.END_OF_TIME;
import static google.registry.util.DateTimeUtils.START_OF_TIME;
import static google.registry.util.PreconditionsUtils.checkArgumentNotNull;
import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static org.joda.money.CurrencyUnit.USD;
@ -254,14 +253,12 @@ public class Registry extends ImmutableObject implements Buildable {
TldType tldType = TldType.REAL;
/**
* A property that transitions to different TldStates at different times. Stored as a list
* of TldStateTransition embedded objects using the @Mapify annotation.
* A property that transitions to different TldStates at different times. Stored as a list of
* TldStateTransition embedded objects using the @Mapify annotation.
*/
@Mapify(TimedTransitionProperty.TimeMapper.class)
TimedTransitionProperty<TldState, TldStateTransition> tldStateTransitions =
TimedTransitionProperty.forMapify(
ImmutableSortedMap.of(START_OF_TIME, DEFAULT_TLD_STATE),
TldStateTransition.class);
TimedTransitionProperty.forMapify(DEFAULT_TLD_STATE, TldStateTransition.class);
/** An automatically managed creation timestamp. */
CreateAutoTimestamp creationTime = CreateAutoTimestamp.create(null);
@ -326,7 +323,7 @@ public class Registry extends ImmutableObject implements Buildable {
Money serverStatusChangeBillingCost = DEFAULT_SERVER_STATUS_CHANGE_BILLING_COST;
/**
* A property that transitions to different renew billing costs at different times. Stored as a
* A property that transitions to different renew billing costs at different times. Stored as a
* list of BillingCostTransition embedded objects using the @Mapify annotation.
* <p>
* A given value of this property represents the per-year billing cost for renewing a domain name.
@ -335,9 +332,7 @@ public class Registry extends ImmutableObject implements Buildable {
*/
@Mapify(TimedTransitionProperty.TimeMapper.class)
TimedTransitionProperty<Money, BillingCostTransition> renewBillingCostTransitions =
TimedTransitionProperty.forMapify(
ImmutableSortedMap.of(START_OF_TIME, DEFAULT_RENEW_BILLING_COST),
BillingCostTransition.class);
TimedTransitionProperty.forMapify(DEFAULT_RENEW_BILLING_COST, BillingCostTransition.class);
String lordnUsername;