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