Class TimedTransitionProperty<V extends Serializable>

java.lang.Object
com.google.common.collect.ForwardingObject
com.google.common.collect.ForwardingMap<org.joda.time.DateTime,V>
google.registry.model.common.TimedTransitionProperty<V>
All Implemented Interfaces:
UnsafeSerializable, Serializable, Map<org.joda.time.DateTime,V>

public class TimedTransitionProperty<V extends Serializable> extends com.google.common.collect.ForwardingMap<org.joda.time.DateTime,V> implements UnsafeSerializable
An entity property whose value transitions over time. Each value it takes on becomes active at a corresponding instant, and remains active until the next transition occurs. At least one "start of time" value (corresponding to START_OF_TIME, i.e. the Unix epoch) must be provided so that the property will have a value for all possible times.

This concept is naturally represented by a sorted map of DateTime to TimedTransitionProperty. This class implements ForwardingMap and stores the data in a backing map and exposes several convenient methods to extrapolate the value at arbitrary point in time.

See Also:
  • Nested Class Summary

    Nested classes/interfaces inherited from class com.google.common.collect.ForwardingMap

    com.google.common.collect.ForwardingMap.StandardEntrySet, com.google.common.collect.ForwardingMap.StandardKeySet, com.google.common.collect.ForwardingMap.StandardValues

    Nested classes/interfaces inherited from interface java.util.Map

    Map.Entry<K extends Object,V extends Object>
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Checks whether this TimedTransitionProperty is in a valid state, i.e.
    protected com.google.common.collect.ImmutableSortedMap<org.joda.time.DateTime,V>
     
    fromValueMap(com.google.common.collect.ImmutableSortedMap<org.joda.time.DateTime,V> valueMap)
    Returns a new immutable TimedTransitionProperty representing the given map of DateTime to value TimedTransitionProperty.
    org.joda.time.DateTime
    getNextTransitionAfter(org.joda.time.DateTime time)
    Returns the time of the next transition.
    getValueAtTime(org.joda.time.DateTime time)
    Returns the value of the property that is active at the specified time.
    make(com.google.common.collect.ImmutableSortedMap<org.joda.time.DateTime,V> newTransitions, com.google.common.collect.ImmutableMultimap<V,V> allowedTransitions, String allowedTransitionMapName, V initialValue, String badInitialValueErrorMessage)
    Validates a new set of transitions and returns the resulting TimedTransitionProperty.
    com.google.common.collect.ImmutableSortedMap<org.joda.time.DateTime,V>
    Exposes the underlying ImmutableSortedMap.
    static <V extends Serializable>
    void
    validateTimedTransitionMap(NavigableMap<org.joda.time.DateTime,V> transitionMap, com.google.common.collect.ImmutableMultimap<V,V> allowedTransitions, String mapName)
    Validates that a transition map is not null or empty, starts at START_OF_TIME, and has transitions which move from one value to another in allowed ways.
    withInitialValue(V initialValue)
    Returns a new immutable TimedTransitionProperty with an initial value at START_OF_TIME.

    Methods inherited from class com.google.common.collect.ForwardingMap

    clear, containsKey, containsValue, entrySet, equals, get, hashCode, isEmpty, keySet, put, putAll, remove, size, standardClear, standardContainsKey, standardContainsValue, standardEquals, standardHashCode, standardIsEmpty, standardPutAll, standardRemove, standardToString, values

    Methods inherited from class com.google.common.collect.ForwardingObject

    toString

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Method Details

    • fromValueMap

      public static <V extends Serializable> TimedTransitionProperty<V> fromValueMap(com.google.common.collect.ImmutableSortedMap<org.joda.time.DateTime,V> valueMap)
      Returns a new immutable TimedTransitionProperty representing the given map of DateTime to value TimedTransitionProperty.
    • withInitialValue

      public static <V extends Serializable> TimedTransitionProperty<V> withInitialValue(V initialValue)
      Returns a new immutable TimedTransitionProperty with an initial value at START_OF_TIME.
    • make

      public static <V extends Serializable> TimedTransitionProperty<V> make(com.google.common.collect.ImmutableSortedMap<org.joda.time.DateTime,V> newTransitions, com.google.common.collect.ImmutableMultimap<V,V> allowedTransitions, String allowedTransitionMapName, V initialValue, String badInitialValueErrorMessage)
      Validates a new set of transitions and returns the resulting TimedTransitionProperty.
      Parameters:
      newTransitions - map from DateTime to transition value TimedTransitionProperty
      allowedTransitions - optional map of all possible state-to-state transitions
      allowedTransitionMapName - optional transition map description string for error messages
      initialValue - optional initial value; if present, the first transition must have this value
      badInitialValueErrorMessage - option error message string if the initial value is wrong
    • validateTimedTransitionMap

      public static <V extends Serializable> void validateTimedTransitionMap(@Nullable NavigableMap<org.joda.time.DateTime,V> transitionMap, com.google.common.collect.ImmutableMultimap<V,V> allowedTransitions, String mapName)
      Validates that a transition map is not null or empty, starts at START_OF_TIME, and has transitions which move from one value to another in allowed ways.
    • checkValidity

      public void checkValidity()
      Checks whether this TimedTransitionProperty is in a valid state, i.e. whether it has a transition entry for START_OF_TIME, and throws IllegalStateException if not.
    • delegate

      protected com.google.common.collect.ImmutableSortedMap<org.joda.time.DateTime,V> delegate()
      Specified by:
      delegate in class com.google.common.collect.ForwardingMap<org.joda.time.DateTime,V extends Serializable>
    • toValueMap

      public com.google.common.collect.ImmutableSortedMap<org.joda.time.DateTime,V> toValueMap()
      Exposes the underlying ImmutableSortedMap.
    • getValueAtTime

      public V getValueAtTime(org.joda.time.DateTime time)
      Returns the value of the property that is active at the specified time. The active value for a time before START_OF_TIME is extrapolated to be the value that is active at START_OF_TIME.
    • getNextTransitionAfter

      @Nullable public org.joda.time.DateTime getNextTransitionAfter(org.joda.time.DateTime time)
      Returns the time of the next transition. Returns null if there is no subsequent transition.