Override of ElevationDetector methods [ solved... I need to better know Orekit... ]

Hello,

I have a little problem with the override of ElevationDetector methods.
I just want to override the init function in the ElevationDetector method to add a “fake” event when the g function is above 0 at start of propagation.
Naively, I coded it roughly like this:

    final ElevationDetector elevationDetector = new ElevationDetector(MAX_CHECK_INTERVAL, THRESHOLD, stationFrame) {
      @Override
      public void init(final SpacecraftState s0,
                       final AbsoluteDate t) {
        super.init(s0, t);
        if (g(s0) > 0) getHandler().eventOccurred(s0, this, true);
      }
    }.withConstantElevation(minElevation).withHandler(visibilityHandler);

The problem is that my override is not taken into account because the “withConstantElevation” and “withHandler” methods return an original ElevationDetector object and not my anonymous class.
Do you have an elegant solution in Java to this simple override without almost duplicating all the ElevationDetector class ?

At the moment, the ElevationDetector class is immutable but do you think it will not be better to change it to a mutable class and to allow “withXXX” method to be coded like this ?

    public ElevationDetector withConstantElevation(final double newMinElevation) {
        minElevation = newMinElevation;
        return this;
    }

This remark is general for detectors because I think it will allow to create a subclass of the existing classes more easily. It seems they are almost “final” classes now.

Thanks for your advices.

Christophe

PS: I use Orekit v9.3.1 (and I can not switch easily to current Orekit version because the code I use serializes IntegratedEphemeris objects and it’s no more available in 10.0)

Ok… Forget my question: I found the AdapterDetector class that covers my needs!

Sorry.

    final AdapterDetector elevationDetector = new AdapterDetector(
        new ElevationDetector(MAX_CHECK_INTERVAL, THRESHOLD, stationFrame).withConstantElevation(minElevation)
            .withHandler(visibilityHandler)) {
      @Override
      public void init(final SpacecraftState s0,
                       final AbsoluteDate t) {
        getDetector().init(s0, t);
        if (g(s0) > 0) eventOccurred(s0, true);
      }
    };