class DefaultAnimationPlan implements AnimationPlan {

    @Override
    @Nullable
    public DefaultAnimationState findState(Date time, Direction direction)
    {
        Utilities.checkNull(time, "time");
        Utilities.checkNull(direction, "direction");
        int resultIndex = 0;
        long minDistance = Long.MAX_VALUE;
        for (int index = 0; index < myAnimationSequence.size(); ++index)
        {
            TimeSpan span = myAnimationSequence.get(index);
            if (span.overlaps(time))
            {
                resultIndex = index;
                break;
            }
            long dist = Math.abs(span.getStart() + span.getEnd() - time.getTime() * 2);
            if (dist < minDistance)
            {
                minDistance = dist;
                resultIndex = index;
            }
        }

        return new DefaultAnimationState(resultIndex, direction);
    }

    public  DefaultAnimationPlan(List<? extends TimeSpan> sequence, EndBehavior endBehavior);

}