From 64a6f6533a1e9690ef497d646c9c3c90de5a3864 Mon Sep 17 00:00:00 2001 From: Axel Uhl Date: Fri, 23 Dec 2011 11:17:49 +0100 Subject: [PATCH] consistently use getInternalRawFixes() to encapsulate fixes field; this will allow us to have specialized WindTracks for estimations that virtualize the fixes --- .../domain/tracking/impl/TrackImpl.java | 34 ++++++++----------- 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/java/com.sap.sailing.domain/src/com/sap/sailing/domain/tracking/impl/TrackImpl.java b/java/com.sap.sailing.domain/src/com/sap/sailing/domain/tracking/impl/TrackImpl.java index 6af2c1e48f3..fe4a381a211 100755 --- a/java/com.sap.sailing.domain/src/com/sap/sailing/domain/tracking/impl/TrackImpl.java +++ b/java/com.sap.sailing.domain/src/com/sap/sailing/domain/tracking/impl/TrackImpl.java @@ -1,6 +1,5 @@ package com.sap.sailing.domain.tracking.impl; -import java.util.Collections; import java.util.Iterator; import java.util.NavigableSet; @@ -48,7 +47,7 @@ public abstract class TrackImpl implements Track /** * @return the smoothened fixes; this implementation simply delegates to {@link #getFixes()} because for only - * {@link Timed} fixes we can't know how to smoothen anything. Subclasses that constrain the + * {@link Timed} fixes we can't know how to remove outliers. Subclasses that constrain the * FixType may provide smoothening implementations. */ protected NavigableSet getInternalFixes() { @@ -59,20 +58,19 @@ public abstract class TrackImpl implements Track /** * Iterates the fixes with outliers getting skipped, in the order of their time points. - * Relies on {@link #getInternalFixes()} to smoothen the track. + * Relies on {@link #getInternalFixes()} to void the track view from outliers. */ @Override - public Iterable getFixes() { - return (Iterable) Collections.unmodifiableSet(getInternalFixes()); + public NavigableSet getFixes() { + return new UnmodifiableNavigableSet(getInternalFixes()); } /** * Iterates over the raw sequence of fixes, all potential outliers included */ - @SuppressWarnings("unchecked") @Override public NavigableSet getRawFixes() { - return (NavigableSet) new UnmodifiableNavigableSet(fixes); + return new UnmodifiableNavigableSet(getInternalRawFixes()); } @SuppressWarnings("unchecked") @@ -84,13 +82,13 @@ public abstract class TrackImpl implements Track @SuppressWarnings("unchecked") @Override public FixType getLastRawFixAtOrBefore(TimePoint timePoint) { - return (FixType) fixes.floor(new DummyTimed(timePoint)); + return (FixType) getInternalRawFixes().floor((FixType) new DummyTimed(timePoint)); } @SuppressWarnings("unchecked") @Override public FixType getFirstRawFixAtOrAfter(TimePoint timePoint) { - return (FixType) fixes.ceiling(new DummyTimed(timePoint)); + return (FixType) getInternalRawFixes().ceiling((FixType) new DummyTimed(timePoint)); } @SuppressWarnings("unchecked") @@ -102,7 +100,7 @@ public abstract class TrackImpl implements Track @SuppressWarnings("unchecked") @Override public FixType getLastRawFixBefore(TimePoint timePoint) { - return (FixType) fixes.lower(new DummyTimed(timePoint)); + return (FixType) getInternalRawFixes().lower((FixType) new DummyTimed(timePoint)); } @SuppressWarnings("unchecked") @@ -114,26 +112,24 @@ public abstract class TrackImpl implements Track @SuppressWarnings("unchecked") @Override public FixType getFirstRawFixAfter(TimePoint timePoint) { - return (FixType) fixes.higher(new DummyTimed(timePoint)); + return (FixType) getInternalRawFixes().higher((FixType) new DummyTimed(timePoint)); } - @SuppressWarnings("unchecked") @Override public FixType getFirstRawFix() { - if (fixes.isEmpty()) { + if (getInternalFixes().isEmpty()) { return null; } else { - return (FixType) fixes.first(); + return (FixType) getInternalFixes().first(); } } - @SuppressWarnings("unchecked") @Override public FixType getLastRawFix() { - if (fixes.isEmpty()) { + if (getInternalRawFixes().isEmpty()) { return null; } else { - return (FixType) fixes.last(); + return (FixType) getInternalRawFixes().last(); } } @@ -148,8 +144,8 @@ public abstract class TrackImpl implements Track @Override public Iterator getRawFixesIterator(TimePoint startingAt, boolean inclusive) { @SuppressWarnings("unchecked") - Iterator result = (Iterator) fixes.tailSet( - new DummyTimed(startingAt), inclusive).iterator(); + Iterator result = (Iterator) getInternalRawFixes().tailSet( + (FixType) new DummyTimed(startingAt), inclusive).iterator(); return result; }