Add TimedTransitionProperty.getTransitionTime()

Add a method to get the next transition time so that we can return the expiry
date along with the EAP fee for a given time.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=125076484
This commit is contained in:
mmuller 2016-06-16 10:45:07 -07:00 committed by Ben McIlwain
parent 4f91d03704
commit 61f37b756a
2 changed files with 21 additions and 0 deletions

View file

@ -35,6 +35,8 @@ import org.joda.time.DateTime;
import java.util.NavigableMap;
import java.util.TreeMap;
import javax.annotation.Nullable;
/**
* 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
@ -203,4 +205,12 @@ public class TimedTransitionProperty<V, T extends TimedTransitionProperty.TimedT
// where any given time earlier than START_OF_TIME is replaced by START_OF_TIME.
return backingMap.floorEntry(latestOf(START_OF_TIME, time)).getValue().getValue();
}
/**
* Returns the time of the next transition. Returns null if there is no subsequent transition.
*/
@Nullable
public DateTime getNextTransitionAfter(DateTime time) {
return backingMap.higherKey(latestOf(START_OF_TIME, time));
}
}