FieldAdapterDetector.java

  1. /* Copyright 2002-2024 Luc Maisonobe
  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.CalculusFieldElement;
  19. import org.orekit.propagation.FieldSpacecraftState;
  20. import org.orekit.propagation.events.handlers.FieldEventHandler;
  21. import org.orekit.time.FieldAbsoluteDate;

  22. /** Base class for adapting an existing detector.
  23.  * <p>
  24.  * This class is intended to be a base class for changing behaviour
  25.  * of a wrapped existing detector. This base class delegates all
  26.  * its methods to the wrapped detector. Classes extending it can
  27.  * therefore override only the methods they want to change.
  28.  * </p>
  29.  * @author Luc Maisonobe
  30.  * @since 12.0
  31.  * @param <T> type of the field element
  32.  */
  33. public class FieldAdapterDetector<T extends CalculusFieldElement<T>> implements FieldEventDetector<T> {

  34.     /** Wrapped detector. */
  35.     private final FieldEventDetector<T> detector;

  36.     /** Build an adaptor wrapping an existing detector.
  37.      * @param detector detector to wrap
  38.      */
  39.     public FieldAdapterDetector(final FieldEventDetector<T> detector) {
  40.         this.detector = detector;
  41.     }

  42.     /** Get the wrapped detector.
  43.      * @return wrapped detector
  44.      */
  45.     public FieldEventDetector<T> getDetector() {
  46.         return detector;
  47.     }

  48.     /** {@inheritDoc} */
  49.     @Override
  50.     public void init(final FieldSpacecraftState<T> s0, final FieldAbsoluteDate<T> t) {
  51.         detector.init(s0, t);
  52.     }

  53.     /** {@inheritDoc} */
  54.     @Override
  55.     public T g(final FieldSpacecraftState<T> s) {
  56.         return detector.g(s);
  57.     }

  58.     /** {@inheritDoc} */
  59.     @Override
  60.     public T getThreshold() {
  61.         return detector.getThreshold();
  62.     }

  63.     /** {@inheritDoc} */
  64.     @Override
  65.     public FieldAdaptableInterval<T> getMaxCheckInterval() {
  66.         return detector.getMaxCheckInterval();
  67.     }

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

  73.     /** {@inheritDoc} */
  74.     @Override
  75.     public FieldEventHandler<T> getHandler() {
  76.         return detector.getHandler();
  77.     }

  78.     /** {@inheritDoc} */
  79.     @Override
  80.     public void finish(final FieldSpacecraftState<T> state) {
  81.         detector.finish(state);
  82.     }

  83.     /** {@inheritDoc} */
  84.     @Override
  85.     public FieldEventDetectionSettings<T> getDetectionSettings() {
  86.         return detector.getDetectionSettings();
  87.     }
  88. }