mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-09 13:50:57 +00:00
added before/after/plus to TimePoint/AbstractTimePoint
This commit is contained in:
1 parent
5d04b737cb
commit
b03b4b0e41
2 files changed
+21
No files matched your search
Executable → Regular
+6
@@ -7,4 +7,10 @@ public interface TimePoint extends Comparable<TimePoint>, Serializable {
|
||||
long asMillis();
|
||||
|
||||
Date asDate();
|
||||
|
||||
TimePoint plus(long milliseconds);
|
||||
|
||||
boolean after(TimePoint other);
|
||||
|
||||
boolean before(TimePoint other);
|
||||
}
|
||||
Executable → Regular
+15
@@ -37,6 +37,21 @@ public abstract class AbstractTimePoint implements TimePoint {
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TimePoint plus(long milliseconds) {
|
||||
return new MillisecondsTimePoint(asMillis()+milliseconds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean after(TimePoint other) {
|
||||
return this.compareTo(other) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean before(TimePoint other) {
|
||||
return this.compareTo(other) < 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return (int) (asMillis() & Integer.MAX_VALUE);
|
||||
|
||||
Reference in new issue
Block a user