Search in sources :

Example 16 with Interval

use of io.spine.time.Interval in project core-java by SpineEventEngine.

the class Rescheduler method reschedule.

private void reschedule(Command command) {
    final Timestamp now = getCurrentTime();
    final Timestamp timeToPost = getTimeToPost(command);
    if (isLaterThan(now, /*than*/
    timeToPost)) {
        onScheduledCommandExpired(command);
    } else {
        final Interval interval = Intervals.between(now, timeToPost);
        final Duration newDelay = Intervals.toDuration(interval);
        final Command updatedCommand = CommandScheduler.setSchedule(command, newDelay, now);
        scheduler().schedule(updatedCommand);
    }
}
Also used : Command(io.spine.core.Command) Duration(com.google.protobuf.Duration) Timestamp(com.google.protobuf.Timestamp) Interval(io.spine.time.Interval)

Aggregations

Timestamp (com.google.protobuf.Timestamp)16 Interval (io.spine.time.Interval)16 Test (org.junit.Test)15 Duration (com.google.protobuf.Duration)3 StringValue (com.google.protobuf.StringValue)2 Command (io.spine.core.Command)1 IntervalChange (io.spine.time.change.IntervalChange)1