1   /* Copyright 2002-2025 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.utils;
18  
19  import org.orekit.time.AbsoluteDate;
20  import org.orekit.time.TimeStamped;
21  
22  
23  /** {@link ParameterDriver Parameter driver} allowing to drive a date.
24   * @author Luc Maisonobe
25   * @since 11.1
26   */
27  public class DateDriver extends ParameterDriver implements TimeStamped {
28  
29      /** Base date corresponding to shift = 0. */
30      private final AbsoluteDate base;
31  
32      /** Indicator for start date. */
33      private boolean start;
34  
35      /** Simple constructor.
36       * <p>
37       * At construction, the parameter is configured as <em>not</em> selected,
38       * the reference date is set to {@code null}, the value (i.e. the date offset)
39       * is set to 0, the scale is set to 1 and the minimum and maximum values are
40       * set to negative and positive infinity respectively.
41       * </p>
42       * @param base base date corresponding to shift = 0
43       * @param name name of the parameter
44       * @param start if true, the driver corresponds to a start date
45       */
46      public DateDriver(final AbsoluteDate base, final String name, final boolean start) {
47          super(name, 0.0, 1.0, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY);
48          this.base  = base;
49          this.start = start;
50      }
51  
52      /** Get the base (unshifted) date.
53       * @return base (unshifted) date
54       */
55      public AbsoluteDate getBaseDate() {
56          return base;
57      }
58  
59      /** Check if driver corresponds to a start date.
60       * @return true if driver corresponds to a start date
61       */
62      public boolean isStart() {
63          return start;
64      }
65  
66      /** Get the shifted date.
67       * @return shifted date
68       */
69      public AbsoluteDate getDate() {
70          // date driver has no validity period, only 1 value is estimated
71          // over the all interval so there is no problem for calling getValue with null argument
72          // or any date, it would give the same result as there is only 1 span on the valueSpanMap
73          // of the driver
74          return base.shiftedBy(getValue(base));
75      }
76  
77  }