Commit 0e329630 authored by Luc Maisonobe's avatar Luc Maisonobe
Browse files

Merge branch 'remove-generics-in-event-handler' into develop

parents 6f4054de 3c0f73ba
......@@ -21,6 +21,9 @@
</properties>
<body>
<release version="12.0" date="TBD" description="TBD">
<action dev="luc" type="update" issue="1017">
Removed generics in EventHandler.
</action>
<action dev="luc" type="update" issue="1013">
Use SI units (i.e. seconds) in GNSSDate.
</action>
......
......@@ -39,10 +39,10 @@
package handlers #CBDBC8 {
interface "EventHandler<T extends EventDetector>" as EventHandler_T_ {
+init(SpacecraftState s0, AbsoluteDate target, T detector)
+Action eventOccurred(SpacecraftState s, T detector, boolean increasing)
+SpacecraftState resetState(T detector, SpacecraftState oldState)
interface EventHandler {
+init(SpacecraftState s0, AbsoluteDate target, EventDetector detector)
+Action eventOccurred(SpacecraftState s, EventDetector detector, boolean increasing)
+SpacecraftState resetState(EventDetector detector, SpacecraftState oldState)
}
enum Action {
......@@ -52,10 +52,10 @@
+CONTINUE
}
ContinueOnEvent --|> EventHandler_T_
StopOnEvent --|> EventHandler_T_
StopOnDecreasingEvent --|> EventHandler_T_
StopOnIncreasingEvent --|> EventHandler_T_
ContinueOnEvent --|> EventHandler
StopOnEvent --|> EventHandler
StopOnDecreasingEvent --|> EventHandler
StopOnIncreasingEvent --|> EventHandler
}
......@@ -77,12 +77,12 @@
}
EventDetector <--* "1" EventShifter
class "AbstractDetector<T extends EventDetector>" as AbstractDetector_T_ {
class "AbstractDetector<T extends AbstractDetector<T>>" as AbstractDetector_T_ {
+T withMaxCheck(double maxCheck)
+T withThreshold(double threshold)
+T withMaxIter(int maxIter)
+T withHandler(EventHandler<T> handler)
+EventHandler<T> getHandler()
+T withHandler(EventHandler handler)
+EventHandler getHandler()
}
enum FilterType {
......@@ -107,7 +107,7 @@
AbstractDetector_T_ <|-- EventSlopeFilter
AbstractDetector_T_ <|-- EventEnablingPredicateFilter
Action <-left- EventHandler_T_
Action <-left- EventHandler
EventDetector <|.. AbstractDetector_T_
AbstractDetector_T_ <|-- EclipseDetector
AbstractDetector_T_ <|-- ElevationDetector
......@@ -119,7 +119,7 @@
sake of diagram clarity
end note
EventHandler_T_ "1" <--o AbstractDetector_T_ : handler
EventHandler "1" <--o AbstractDetector_T_ : handler
}
......
......@@ -337,7 +337,7 @@ public class TimeSpanDragForce extends AbstractDragForceModel {
final FieldDateDetector<T> datesDetector =
new FieldDateDetector<>(new FieldAbsoluteDate<>(field, transitionDates[0])).
withMaxCheck(field.getZero().add(60.)).
withHandler((FieldSpacecraftState<T> state, FieldDateDetector<T> detector, boolean increasing) ->
withHandler((FieldSpacecraftState<T> state, FieldEventDetector<T> detector, boolean increasing) ->
Action.RESET_DERIVATIVES);
// Add all transitions' dates to the date detector
for (int i = 1; i < transitionDates.length; i++) {
......
......@@ -64,16 +64,15 @@ import org.orekit.utils.PVCoordinates;
* node on an equatorial orbit! This is a real case that has been encountered
* during validation ...</p>
* @see org.orekit.propagation.Propagator#addEventDetector(EventDetector)
* @param <T> class type for the generic version
* @author Luc Maisonobe
*/
public class ImpulseManeuver<T extends EventDetector> extends AbstractDetector<ImpulseManeuver<T>> {
public class ImpulseManeuver extends AbstractDetector<ImpulseManeuver> {
/** The attitude to override during the maneuver, if set. */
private final AttitudeProvider attitudeOverride;
/** Triggering event. */
private final T trigger;
private final EventDetector trigger;
/** Velocity increment in satellite frame. */
private final Vector3D deltaVSat;
......@@ -92,9 +91,9 @@ public class ImpulseManeuver<T extends EventDetector> extends AbstractDetector<I
* @param deltaVSat velocity increment in satellite frame
* @param isp engine specific impulse (s)
*/
public ImpulseManeuver(final T trigger, final Vector3D deltaVSat, final double isp) {
public ImpulseManeuver(final EventDetector trigger, final Vector3D deltaVSat, final double isp) {
this(trigger.getMaxCheckInterval(), trigger.getThreshold(),
trigger.getMaxIterationCount(), new Handler<T>(),
trigger.getMaxIterationCount(), new Handler(),
trigger, null, deltaVSat, isp);
}
......@@ -105,9 +104,9 @@ public class ImpulseManeuver<T extends EventDetector> extends AbstractDetector<I
* @param deltaVSat velocity increment in satellite frame
* @param isp engine specific impulse (s)
*/
public ImpulseManeuver(final T trigger, final AttitudeProvider attitudeOverride, final Vector3D deltaVSat, final double isp) {
public ImpulseManeuver(final EventDetector trigger, final AttitudeProvider attitudeOverride, final Vector3D deltaVSat, final double isp) {
this(trigger.getMaxCheckInterval(), trigger.getThreshold(),
trigger.getMaxIterationCount(), new Handler<T>(),
trigger.getMaxIterationCount(), new Handler(),
trigger, attitudeOverride, deltaVSat, isp);
}
......@@ -128,8 +127,8 @@ public class ImpulseManeuver<T extends EventDetector> extends AbstractDetector<I
* @since 6.1
*/
private ImpulseManeuver(final double maxCheck, final double threshold,
final int maxIter, final EventHandler<? super ImpulseManeuver<T>> handler,
final T trigger, final AttitudeProvider attitudeOverride, final Vector3D deltaVSat,
final int maxIter, final EventHandler handler,
final EventDetector trigger, final AttitudeProvider attitudeOverride, final Vector3D deltaVSat,
final double isp) {
super(maxCheck, threshold, maxIter, handler);
this.attitudeOverride = attitudeOverride;
......@@ -141,10 +140,10 @@ public class ImpulseManeuver<T extends EventDetector> extends AbstractDetector<I
/** {@inheritDoc} */
@Override
protected ImpulseManeuver<T> create(final double newMaxCheck, final double newThreshold,
final int newMaxIter, final EventHandler<? super ImpulseManeuver<T>> newHandler) {
return new ImpulseManeuver<T>(newMaxCheck, newThreshold, newMaxIter, newHandler,
trigger, attitudeOverride, deltaVSat, isp);
protected ImpulseManeuver create(final double newMaxCheck, final double newThreshold,
final int newMaxIter, final EventHandler newHandler) {
return new ImpulseManeuver(newMaxCheck, newThreshold, newMaxIter, newHandler,
trigger, attitudeOverride, deltaVSat, isp);
}
/** {@inheritDoc} */
......@@ -170,7 +169,7 @@ public class ImpulseManeuver<T extends EventDetector> extends AbstractDetector<I
/** Get the triggering event.
* @return triggering event
*/
public T getTrigger() {
public EventDetector getTrigger() {
return trigger;
}
......@@ -188,16 +187,15 @@ public class ImpulseManeuver<T extends EventDetector> extends AbstractDetector<I
return isp;
}
/** Local handler.
* @param <T> class type for the generic version
*/
private static class Handler<T extends EventDetector> implements EventHandler<ImpulseManeuver<T>> {
/** Local handler. */
private static class Handler implements EventHandler {
/** {@inheritDoc} */
public Action eventOccurred(final SpacecraftState s, final ImpulseManeuver<T> im,
public Action eventOccurred(final SpacecraftState s, final EventDetector detector,
final boolean increasing) {
// filter underlying event
final ImpulseManeuver im = (ImpulseManeuver) detector;
final Action underlyingAction = im.trigger.eventOccurred(s, increasing);
return (underlyingAction == Action.STOP) ? Action.RESET_STATE : Action.CONTINUE;
......@@ -206,8 +204,9 @@ public class ImpulseManeuver<T extends EventDetector> extends AbstractDetector<I
/** {@inheritDoc} */
@Override
public SpacecraftState resetState(final ImpulseManeuver<T> im, final SpacecraftState oldState) {
public SpacecraftState resetState(final EventDetector detector, final SpacecraftState oldState) {
final ImpulseManeuver im = (ImpulseManeuver) detector;
final AbsoluteDate date = oldState.getDate();
final AttitudeProvider override = im.getAttitudeOverride();
final Attitude attitude;
......
......@@ -23,7 +23,6 @@ import org.hipparchus.CalculusFieldElement;
import org.hipparchus.Field;
import org.hipparchus.util.FastMath;
import org.orekit.propagation.events.FieldAbstractDetector;
import org.orekit.propagation.events.FieldEventDetector;
import org.orekit.propagation.events.FieldParameterDrivenDateIntervalDetector;
import org.orekit.propagation.events.ParameterDrivenDateIntervalDetector;
import org.orekit.time.AbsoluteDate;
......@@ -115,7 +114,7 @@ public class DateBasedManeuverTriggers extends IntervalEventTrigger<ParameterDri
/** {@inheritDoc} */
@Override
protected <D extends FieldEventDetector<S>, S extends CalculusFieldElement<S>>
protected <D extends FieldAbstractDetector<D, S>, S extends CalculusFieldElement<S>>
FieldAbstractDetector<D, S> convertIntervalDetector(final Field<S> field, final ParameterDrivenDateIntervalDetector detector) {
final FieldParameterDrivenDateIntervalDetector<S> fd =
......
......@@ -42,7 +42,7 @@ import org.orekit.time.FieldAbsoluteDate;
* @author Andrea Fiorentino
* @since 10.2
*/
public class EventBasedManeuverTriggers implements ManeuverTriggers, EventHandler<EventDetector> {
public class EventBasedManeuverTriggers implements ManeuverTriggers, EventHandler {
/** Detector to start firing, only detect increasing sign change. */
private final AbstractDetector<? extends EventDetector> startFiringDetector;
......
......@@ -176,25 +176,25 @@ public abstract class IntervalEventTrigger<T extends AbstractDetector<T>> extend
* @param <S> type of the field elements
* @return converted firing intervals detector
*/
protected abstract <D extends FieldEventDetector<S>, S extends CalculusFieldElement<S>>
protected abstract <D extends FieldAbstractDetector<D, S>, S extends CalculusFieldElement<S>>
FieldAbstractDetector<D, S> convertIntervalDetector(Field<S> field, T detector);
/** Local handler for both start and stop triggers. */
private class Handler implements EventHandler<T> {
private class Handler implements EventHandler {
/** Propagation direction. */
private boolean forward;
/** {@inheritDoc} */
@Override
public void init(final SpacecraftState initialState, final AbsoluteDate target, final T detector) {
public void init(final SpacecraftState initialState, final AbsoluteDate target, final EventDetector detector) {
forward = target.isAfterOrEqualTo(initialState);
initializeResetters(initialState, target);
}
/** {@inheritDoc} */
@Override
public Action eventOccurred(final SpacecraftState s, final T detector, final boolean increasing) {
public Action eventOccurred(final SpacecraftState s, final EventDetector detector, final boolean increasing) {
if (forward) {
getFirings().addValidAfter(increasing, s.getDate(), false);
} else {
......@@ -206,7 +206,7 @@ public abstract class IntervalEventTrigger<T extends AbstractDetector<T>> extend
/** {@inheritDoc} */
@Override
public SpacecraftState resetState(final T detector, final SpacecraftState oldState) {
public SpacecraftState resetState(final EventDetector detector, final SpacecraftState oldState) {
return applyResetters(oldState);
}
......@@ -215,7 +215,7 @@ public abstract class IntervalEventTrigger<T extends AbstractDetector<T>> extend
/** Local handler for both start and stop triggers.
* @param <S> type of the field elements
*/
private class FieldHandler<D extends FieldEventDetector<S>, S extends CalculusFieldElement<S>> implements FieldEventHandler<D, S> {
private class FieldHandler<D extends FieldAbstractDetector<D, S>, S extends CalculusFieldElement<S>> implements FieldEventHandler<S> {
/** Propagation direction. */
private boolean forward;
......@@ -224,14 +224,14 @@ public abstract class IntervalEventTrigger<T extends AbstractDetector<T>> extend
@Override
public void init(final FieldSpacecraftState<S> initialState,
final FieldAbsoluteDate<S> target,
final D detector) {
final FieldEventDetector<S> detector) {
forward = target.isAfterOrEqualTo(initialState);
initializeResetters(initialState, target);
}
/** {@inheritDoc} */
@Override
public Action eventOccurred(final FieldSpacecraftState<S> s, final D detector, final boolean increasing) {
public Action eventOccurred(final FieldSpacecraftState<S> s, final FieldEventDetector<S> detector, final boolean increasing) {
if (forward) {
getFirings().addValidAfter(increasing, s.getDate().toAbsoluteDate(), false);
} else {
......@@ -243,7 +243,7 @@ public abstract class IntervalEventTrigger<T extends AbstractDetector<T>> extend
/** {@inheritDoc} */
@Override
public FieldSpacecraftState<S> resetState(final D detector, final FieldSpacecraftState<S> oldState) {
public FieldSpacecraftState<S> resetState(final FieldEventDetector<S> detector, final FieldSpacecraftState<S> oldState) {
return applyResetters(oldState);
}
......
......@@ -228,7 +228,7 @@ public abstract class StartStopEventsTrigger<A extends AbstractDetector<A>, O ex
* considering these detectors are created from a date and a number parameter is:
* </p>
* <pre>{@code
* protected <D extends FieldEventDetector<S>, S extends CalculusFieldElement<S>>
* protected <D extends FieldAbstractDetector<D, S>, S extends CalculusFieldElement<S>>
* FieldAbstractDetector<D, S> convertStartDetector(final Field<S> field, final XyzDetector detector) {
*
* final FieldAbsoluteDate<S> date = new FieldAbsoluteDate<>(field, detector.getDate());
......@@ -246,7 +246,7 @@ public abstract class StartStopEventsTrigger<A extends AbstractDetector<A>, O ex
* @param <S> type of the field elements
* @return converted firing start detector
*/
protected abstract <D extends FieldEventDetector<S>, S extends CalculusFieldElement<S>> FieldAbstractDetector<D, S>
protected abstract <D extends FieldAbstractDetector<D, S>, S extends CalculusFieldElement<S>> FieldAbstractDetector<D, S>
convertStartDetector(Field<S> field, A detector);
/** Convert a primitive firing stop detector into a field firing stop detector.
......@@ -261,7 +261,7 @@ public abstract class StartStopEventsTrigger<A extends AbstractDetector<A>, O ex
* considering these detectors are created from a date and a number parameter is:
* </p>
* <pre>{@code
* protected <D extends FieldEventDetector<S>, S extends CalculusFieldElement<S>>
* protected <D extends FieldAbstractDetector<D, S>, S extends CalculusFieldElement<S>>
* FieldAbstractDetector<D, S> convertStopDetector(final Field<S> field, final XyzDetector detector) {
*
* final FieldAbsoluteDate<S> date = new FieldAbsoluteDate<>(field, detector.getDate());
......@@ -279,25 +279,25 @@ public abstract class StartStopEventsTrigger<A extends AbstractDetector<A>, O ex
* @param <S> type of the field elements
* @return converted firing stop detector
*/
protected abstract <D extends FieldEventDetector<S>, S extends CalculusFieldElement<S>> FieldAbstractDetector<D, S>
protected abstract <D extends FieldAbstractDetector<D, S>, S extends CalculusFieldElement<S>> FieldAbstractDetector<D, S>
convertStopDetector(Field<S> field, O detector);
/** Local handler for start triggers. */
private class StartHandler implements EventHandler<A> {
private class StartHandler implements EventHandler {
/** Propagation direction. */
private boolean forward;
/** {@inheritDoc} */
@Override
public void init(final SpacecraftState initialState, final AbsoluteDate target, final A detector) {
public void init(final SpacecraftState initialState, final AbsoluteDate target, final EventDetector detector) {
forward = target.isAfterOrEqualTo(initialState);
initializeResetters(initialState, target);
}
/** {@inheritDoc} */
@Override
public Action eventOccurred(final SpacecraftState s, final A detector, final boolean increasing) {
public Action eventOccurred(final SpacecraftState s, final EventDetector detector, final boolean increasing) {
if (increasing) {
// the event is meaningful for maneuver firing
if (forward) {
......@@ -315,28 +315,28 @@ public abstract class StartStopEventsTrigger<A extends AbstractDetector<A>, O ex
/** {@inheritDoc} */
@Override
public SpacecraftState resetState(final A detector, final SpacecraftState oldState) {
public SpacecraftState resetState(final EventDetector detector, final SpacecraftState oldState) {
return applyResetters(oldState);
}
}
/** Local handler for stop triggers. */
private class StopHandler implements EventHandler<O> {
private class StopHandler implements EventHandler {
/** Propagation direction. */
private boolean forward;
/** {@inheritDoc} */
@Override
public void init(final SpacecraftState initialState, final AbsoluteDate target, final O detector) {
public void init(final SpacecraftState initialState, final AbsoluteDate target, final EventDetector detector) {
forward = target.isAfterOrEqualTo(initialState);
initializeResetters(initialState, target);
}
/** {@inheritDoc} */
@Override
public Action eventOccurred(final SpacecraftState s, final O detector, final boolean increasing) {
public Action eventOccurred(final SpacecraftState s, final EventDetector detector, final boolean increasing) {
if (increasing) {
// the event is meaningful for maneuver firing
if (forward) {
......@@ -354,7 +354,7 @@ public abstract class StartStopEventsTrigger<A extends AbstractDetector<A>, O ex
/** {@inheritDoc} */
@Override
public SpacecraftState resetState(final O detector, final SpacecraftState oldState) {
public SpacecraftState resetState(final EventDetector detector, final SpacecraftState oldState) {
return applyResetters(oldState);
}
......@@ -363,7 +363,7 @@ public abstract class StartStopEventsTrigger<A extends AbstractDetector<A>, O ex
/** Local handler for start triggers.
* @param <S> type of the field elements
*/
private class FieldStartHandler<D extends FieldEventDetector<S>, S extends CalculusFieldElement<S>> implements FieldEventHandler<D, S> {
private class FieldStartHandler<S extends CalculusFieldElement<S>> implements FieldEventHandler<S> {
/** Propagation direction. */
private boolean forward;
......@@ -372,14 +372,14 @@ public abstract class StartStopEventsTrigger<A extends AbstractDetector<A>, O ex
@Override
public void init(final FieldSpacecraftState<S> initialState,
final FieldAbsoluteDate<S> target,
final D detector) {
final FieldEventDetector<S> detector) {
forward = target.isAfterOrEqualTo(initialState);
initializeResetters(initialState, target);
}
/** {@inheritDoc} */
@Override
public Action eventOccurred(final FieldSpacecraftState<S> s, final D detector, final boolean increasing) {
public Action eventOccurred(final FieldSpacecraftState<S> s, final FieldEventDetector<S> detector, final boolean increasing) {
if (increasing) {
// the event is meaningful for maneuver firing
if (forward) {
......@@ -397,7 +397,7 @@ public abstract class StartStopEventsTrigger<A extends AbstractDetector<A>, O ex
/** {@inheritDoc} */
@Override
public FieldSpacecraftState<S> resetState(final D detector, final FieldSpacecraftState<S> oldState) {
public FieldSpacecraftState<S> resetState(final FieldEventDetector<S> detector, final FieldSpacecraftState<S> oldState) {
return applyResetters(oldState);
}
......@@ -406,7 +406,7 @@ public abstract class StartStopEventsTrigger<A extends AbstractDetector<A>, O ex
/** Local handler for stop triggers.
* @param <S> type of the field elements
*/
private class FieldStopHandler<D extends FieldEventDetector<S>, S extends CalculusFieldElement<S>> implements FieldEventHandler<D, S> {
private class FieldStopHandler<S extends CalculusFieldElement<S>> implements FieldEventHandler<S> {
/** Propagation direction. */
private boolean forward;
......@@ -415,14 +415,14 @@ public abstract class StartStopEventsTrigger<A extends AbstractDetector<A>, O ex
@Override
public void init(final FieldSpacecraftState<S> initialState,
final FieldAbsoluteDate<S> target,
final D detector) {
final FieldEventDetector<S> detector) {
forward = target.isAfterOrEqualTo(initialState);
initializeResetters(initialState, target);
}
/** {@inheritDoc} */
@Override
public Action eventOccurred(final FieldSpacecraftState<S> s, final D detector, final boolean increasing) {
public Action eventOccurred(final FieldSpacecraftState<S> s, final FieldEventDetector<S> detector, final boolean increasing) {
if (increasing) {
// the event is meaningful for maneuver firing
if (forward) {
......@@ -440,7 +440,7 @@ public abstract class StartStopEventsTrigger<A extends AbstractDetector<A>, O ex
/** {@inheritDoc} */
@Override
public FieldSpacecraftState<S> resetState(final D detector, final FieldSpacecraftState<S> oldState) {
public FieldSpacecraftState<S> resetState(final FieldEventDetector<S> detector, final FieldSpacecraftState<S> oldState) {
return applyResetters(oldState);
}
......
......@@ -32,7 +32,6 @@ import org.hipparchus.util.MathArrays;
import org.orekit.bodies.OneAxisEllipsoid;
import org.orekit.forces.AbstractForceModel;
import org.orekit.frames.Frame;
import org.orekit.propagation.FieldSpacecraftState;
import org.orekit.propagation.events.EclipseDetector;
import org.orekit.propagation.events.EventDetector;
import org.orekit.propagation.events.FieldEclipseDetector;
......@@ -125,15 +124,13 @@ public abstract class AbstractRadiationForceModel extends AbstractForceModel {
withMargin(zero.newInstance(-ANGULAR_MARGIN)).
withMaxCheck(zero.newInstance(ECLIPSE_MAX_CHECK)).
withThreshold(zero.newInstance(ECLIPSE_THRESHOLD)).
withHandler((FieldSpacecraftState<T> state, FieldEclipseDetector<T> detector, boolean increasing) ->
Action.RESET_DERIVATIVES);
withHandler((state, detector, increasing) -> Action.RESET_DERIVATIVES);
detectors[2 * i + 1] = new FieldEclipseDetector<>(field, occulting).
withPenumbra().
withMargin(zero.newInstance(ANGULAR_MARGIN)).
withMaxCheck(zero.newInstance(ECLIPSE_MAX_CHECK)).
withThreshold(zero.newInstance(ECLIPSE_THRESHOLD)).
withHandler((FieldSpacecraftState<T> state, FieldEclipseDetector<T> detector, boolean increasing) ->
Action.RESET_DERIVATIVES);
withHandler((state, detector, increasing) -> Action.RESET_DERIVATIVES);
}
return Stream.of(detectors);
}
......
......@@ -18,7 +18,7 @@ package org.orekit.models.earth.tessellation;
import org.hipparchus.ode.events.Action;
import org.orekit.propagation.SpacecraftState;
import org.orekit.propagation.events.LatitudeExtremumDetector;
import org.orekit.propagation.events.EventDetector;
import org.orekit.propagation.events.handlers.EventHandler;
import org.orekit.time.AbsoluteDate;
......@@ -27,7 +27,7 @@ import org.orekit.time.AbsoluteDate;
* @see AlongTrackAiming
* @author Luc Maisonobe
*/
class HalfTrackSpanHandler implements EventHandler<LatitudeExtremumDetector> {
class HalfTrackSpanHandler implements EventHandler {
/** Indicator for zone tiling with respect to ascending or descending orbits. */
private final boolean isAscending;
......@@ -64,9 +64,7 @@ class HalfTrackSpanHandler implements EventHandler<LatitudeExtremumDetector> {
/** {@inheritDoc} */
@Override
public Action eventOccurred(final SpacecraftState s,
final LatitudeExtremumDetector detector,
final boolean increasing) {
public Action eventOccurred(final SpacecraftState s, final EventDetector detector, final boolean increasing) {
if (increasing ^ isAscending) {
// we have found an end event
if (start == null) {
......
......@@ -24,6 +24,7 @@ import org.orekit.propagation.events.handlers.EventHandler;
import org.orekit.time.AbsoluteDate;
/** Common parts shared by several orbital events finders.
* @param <T> type of the detector
* @see org.orekit.propagation.Propagator#addEventDetector(EventDetector)
* @author Luc Maisonobe
*/
......@@ -48,7 +49,7 @@ public abstract class AbstractDetector<T extends AbstractDetector<T>> implements
private final int maxIter;
/** Default handler for event overrides. */
private final EventHandler<? super T> handler;
private final EventHandler handler;
/** Propagation direction. */
private boolean forward;
......@@ -60,7 +61,7 @@ public abstract class AbstractDetector<T extends AbstractDetector<T>> implements
* @param handler event handler to call at event occurrences
*/
protected AbstractDetector(final double maxCheck, final double threshold, final int maxIter,
final EventHandler<? super T> handler) {
final EventHandler handler) {
checkStrictlyPositive(maxCheck);
checkStrictlyPositive(threshold);
this.maxCheck = maxCheck;
......@@ -88,11 +89,10 @@ public abstract class AbstractDetector<T extends AbstractDetector<T>> implements
* handler. If a subclass overrides this method it should call {@code
* super.init(s0, t)}.
*/
@SuppressWarnings("unchecked")
public void init(final SpacecraftState s0,
final AbsoluteDate t) {
forward = t.durationFrom(s0.getDate()) >= 0.0;
getHandler().init(s0, t, (T) this);
getHandler().init(s0, t, this);
}
/** {@inheritDoc} */
......@@ -161,14 +161,14 @@ public abstract class AbstractDetector<T extends AbstractDetector<T>> implements
* @return a new detector with updated configuration (the instance is not changed)
* @since 6.1
*/
public T withHandler(final EventHandler<? super T> newHandler) {
public T withHandler(final EventHandler newHandler) {
return create(getMaxCheckInterval(), getThreshold(), getMaxIterationCount(), newHandler);
}
/** Get the handler.
* @return event handler to call at event occurrences
*/
public EventHandler<? super T> getHandler() {
public EventHandler getHandler() {
return handler;
}
......@@ -194,7 +194,7 @@ public abstract class AbstractDetector<T extends AbstractDetector<T>> implements
* @return a new instance of the appropriate sub-type
*/
protected abstract T create(double newMaxCheck, double newThreshold,
int newMaxIter, EventHandler<? super T> newHandler);
int newMaxIter, EventHandler newHandler);
/** Check if the current propagation is forward or backward.
* @return true if the current propagation is forward
......
......@@ -74,7 +74,7 @@ public class AlignmentDetector extends AbstractDetector<AlignmentDetector> {