AdapterDetector.java

  1. /* Copyright 2002-2022 CS GROUP
  2.  * Licensed to CS GROUP (CS) under one or more
  3.  * contributor license agreements.  See the NOTICE file distributed with
  4.  * this work for additional information regarding copyright ownership.
  5.  * CS licenses this file to You under the Apache License, Version 2.0
  6.  * (the "License"); you may not use this file except in compliance with
  7.  * the License.  You may obtain a copy of the License at
  8.  *
  9.  *   http://www.apache.org/licenses/LICENSE-2.0
  10.  *
  11.  * Unless required by applicable law or agreed to in writing, software
  12.  * distributed under the License is distributed on an "AS IS" BASIS,
  13.  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14.  * See the License for the specific language governing permissions and
  15.  * limitations under the License.
  16.  */
  17. package org.orekit.propagation.events;

  18. import org.hipparchus.ode.events.Action;
  19. import org.orekit.propagation.SpacecraftState;
  20. import org.orekit.time.AbsoluteDate;

  21. /** Base class for adapting an existing detector.
  22.  * <p>
  23.  * This class is intended to be a base class for changing behaviour
  24.  * of a wrapped existing detector. This base class delegates all
  25.  * its methods to the wrapped detector. Classes extending it can
  26.  * therefore override only the methods they want to change.
  27.  * </p>
  28.  * @author Luc Maisonobe
  29.  * @since 9.3
  30.  */
  31. public class AdapterDetector implements EventDetector {

  32.     /** Wrapped detector. */
  33.     private final EventDetector detector;

  34.     /** Build an adaptor wrapping an existing detector.
  35.      * @param detector detector to wrap
  36.      */
  37.     public AdapterDetector(final EventDetector detector) {
  38.         this.detector = detector;
  39.     }

  40.     /** Get the wrapped detector.
  41.      * @return wrapped detector
  42.      */
  43.     public EventDetector getDetector() {
  44.         return detector;
  45.     }

  46.     /** {@inheritDoc} */
  47.     @Override
  48.     public void init(final SpacecraftState s0, final AbsoluteDate t) {
  49.         detector.init(s0, t);
  50.     }

  51.     /** {@inheritDoc} */
  52.     @Override
  53.     public double g(final SpacecraftState s) {
  54.         return detector.g(s);
  55.     }

  56.     /** {@inheritDoc} */
  57.     @Override
  58.     public double getThreshold() {
  59.         return detector.getThreshold();
  60.     }

  61.     /** {@inheritDoc} */
  62.     @Override
  63.     public double getMaxCheckInterval() {
  64.         return detector.getMaxCheckInterval();
  65.     }

  66.     /** {@inheritDoc} */
  67.     @Override
  68.     public int getMaxIterationCount() {
  69.         return detector.getMaxIterationCount();
  70.     }

  71.     /** {@inheritDoc} */
  72.     @Override
  73.     public Action eventOccurred(final SpacecraftState s, final boolean increasing) {
  74.         return detector.eventOccurred(s, increasing);
  75.     }

  76.     /** {@inheritDoc} */
  77.     @Override
  78.     public SpacecraftState resetState(final SpacecraftState oldState) {
  79.         return detector.resetState(oldState);
  80.     }

  81. }