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  
19  import org.hipparchus.CalculusFieldElement;
20  import org.orekit.propagation.FieldSpacecraftState;
21  import org.orekit.propagation.events.handlers.FieldEventHandler;
22  import org.orekit.time.FieldAbsoluteDate;
23  
24  /** Base class for adapting an existing detector.
25   * <p>
26   * This class is intended to be a base class for changing behaviour
27   * of a wrapped existing detector. This base class delegates all
28   * its methods to the wrapped detector. Classes extending it can
29   * therefore override only the methods they want to change.
30   * </p>
31   * @author Luc Maisonobe
32   * @since 12.0
33   * @param <T> type of the field element
34   */
35  public class FieldAdapterDetector<T extends CalculusFieldElement<T>> implements FieldEventDetector<T> {
36  
37      /** Wrapped detector. */
38      private final FieldEventDetector<T> detector;
39  
40      /** Build an adaptor wrapping an existing detector.
41       * @param detector detector to wrap
42       */
43      public FieldAdapterDetector(final FieldEventDetector<T> detector) {
44          this.detector = detector;
45      }
46  
47      /** Get the wrapped detector.
48       * @return wrapped detector
49       */
50      public FieldEventDetector<T> getDetector() {
51          return detector;
52      }
53  
54      /** {@inheritDoc} */
55      @Override
56      public void init(final FieldSpacecraftState<T> s0, final FieldAbsoluteDate<T> t) {
57          detector.init(s0, t);
58      }
59  
60      /** {@inheritDoc} */
61      @Override
62      public T g(final FieldSpacecraftState<T> s) {
63          return detector.g(s);
64      }
65  
66      /** {@inheritDoc} */
67      @Override
68      public T getThreshold() {
69          return detector.getThreshold();
70      }
71  
72      /** {@inheritDoc} */
73      @Override
74      public FieldAdaptableInterval<T> getMaxCheckInterval() {
75          return detector.getMaxCheckInterval();
76      }
77  
78      /** {@inheritDoc} */
79      @Override
80      public int getMaxIterationCount() {
81          return detector.getMaxIterationCount();
82      }
83  
84      /** {@inheritDoc} */
85      @Override
86      public FieldEventHandler<T> getHandler() {
87          return detector.getHandler();
88      }
89  
90  }