mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-04 03:13:49 +00:00
moved beginning/end of time to TimePoint
This commit is contained in:
1 parent
fa4f5a8018
commit
741756a2ad
6 files changed
+17
-19
No files matched your search
@@ -6,14 +6,9 @@ import com.sap.sse.common.Duration;
|
||||
import com.sap.sse.common.TimePoint;
|
||||
|
||||
public interface TimeRange extends Comparable<TimeRange>, Serializable {
|
||||
/**
|
||||
* @return {@code null}, if the timepoint is at the beginning of time
|
||||
*/
|
||||
|
||||
TimePoint from();
|
||||
|
||||
/**
|
||||
* @return {@code null}, if the timepoint is at the beginning of time
|
||||
*/
|
||||
TimePoint to();
|
||||
|
||||
/**
|
||||
@@ -43,12 +38,12 @@ public interface TimeRange extends Comparable<TimeRange>, Serializable {
|
||||
/**
|
||||
* Is the time range open ended towards older timepoints?
|
||||
*/
|
||||
boolean openBeginning();
|
||||
boolean hasOpenBeginning();
|
||||
|
||||
/**
|
||||
* Is the time range open ended towards newer timepoints?
|
||||
*/
|
||||
boolean openEnd();
|
||||
boolean hasOpenEnd();
|
||||
|
||||
/**
|
||||
* Get time-difference between the timepoint and this timerange.
|
||||
|
||||
+5
-7
@@ -7,8 +7,6 @@ import com.sap.sse.common.Util;
|
||||
import com.sap.sse.common.impl.MillisecondsTimePoint;
|
||||
|
||||
public class TimeRangeImpl extends Util.Pair<TimePoint, TimePoint> implements TimeRange {
|
||||
public static final TimePoint BeginningOfTime = new MillisecondsTimePoint(Long.MIN_VALUE);
|
||||
public static final TimePoint EndOfTime = new MillisecondsTimePoint(Long.MAX_VALUE);
|
||||
private static final long serialVersionUID = 8710198176227507300L;
|
||||
|
||||
public static TimeRange create(long fromMillis, long toMillis) {
|
||||
@@ -16,7 +14,7 @@ public class TimeRangeImpl extends Util.Pair<TimePoint, TimePoint> implements Ti
|
||||
}
|
||||
|
||||
public TimeRangeImpl(TimePoint from, TimePoint to) {
|
||||
super(from == null ? BeginningOfTime : from, to == null ? EndOfTime : to);
|
||||
super(from == null ? TimePoint.BeginningOfTime : from, to == null ? TimePoint.EndOfTime : to);
|
||||
if (from().after(to())) {
|
||||
throw new IllegalArgumentException("from " + from() + " must lie before to " + to() + " in a TimeRange");
|
||||
}
|
||||
@@ -100,13 +98,13 @@ public class TimeRangeImpl extends Util.Pair<TimePoint, TimePoint> implements Ti
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean openBeginning() {
|
||||
return from().equals(BeginningOfTime);
|
||||
public boolean hasOpenBeginning() {
|
||||
return from().equals(TimePoint.BeginningOfTime);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean openEnd() {
|
||||
return to().equals(EndOfTime);
|
||||
public boolean hasOpenEnd() {
|
||||
return to().equals(TimePoint.EndOfTime);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+2
-2
@@ -94,8 +94,8 @@ public class TimeRangeTest {
|
||||
|
||||
one = create(Long.MIN_VALUE, 10);
|
||||
union = two.union(one);
|
||||
assertTrue(union.openBeginning());
|
||||
assertTrue(union.openEnd());
|
||||
assertTrue(union.hasOpenBeginning());
|
||||
assertTrue(union.hasOpenEnd());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
+2
-2
@@ -5020,8 +5020,8 @@ public class SailingServiceImpl extends ProxiedRemoteServiceServlet implements S
|
||||
DeviceMapping<?> mapping = convertToDeviceMapping(dto);
|
||||
TimePoint now = MillisecondsTimePoint.now();
|
||||
RaceLogEvent event = null;
|
||||
TimePoint from = mapping.getTimeRange().openBeginning() ? null : mapping.getTimeRange().from();
|
||||
TimePoint to = mapping.getTimeRange().openEnd() ? null : mapping.getTimeRange().to();
|
||||
TimePoint from = mapping.getTimeRange().hasOpenBeginning() ? null : mapping.getTimeRange().from();
|
||||
TimePoint to = mapping.getTimeRange().hasOpenEnd() ? null : mapping.getTimeRange().to();
|
||||
if (dto.mappedTo instanceof MarkDTO) {
|
||||
Mark mark = convertToMark(((MarkDTO) dto.mappedTo), true);
|
||||
event = RaceLogEventFactory.INSTANCE.createDeviceMarkMappingEvent(now, getService().getServerAuthor(),
|
||||
|
||||
File renamed without changes.
@@ -3,7 +3,12 @@ package com.sap.sse.common;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
import com.sap.sse.common.impl.MillisecondsTimePoint;
|
||||
|
||||
public interface TimePoint extends Comparable<TimePoint>, Serializable {
|
||||
TimePoint BeginningOfTime = new MillisecondsTimePoint(Long.MIN_VALUE);
|
||||
TimePoint EndOfTime = new MillisecondsTimePoint(Long.MAX_VALUE);
|
||||
|
||||
long asMillis();
|
||||
|
||||
Date asDate();
|
||||
|
||||
Reference in new issue
Block a user