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.time;
18  
19  import org.hipparchus.CalculusFieldElement;
20  
21  /**
22   * Pair of time stamped values being defined at the same date.
23   *
24   * @param <F> first time stamped value
25   * @param <S> second time stamped value
26   * @param <KK> type of the field element
27   *
28   * @author Vincent Cucchietti
29   * @see FieldTimeStamped
30   */
31  public class FieldTimeStampedPair<F extends FieldTimeStamped<KK>, S extends FieldTimeStamped<KK>,
32          KK extends CalculusFieldElement<KK>> implements FieldTimeStamped<KK> {
33  
34      /** Default date equality threshold of 1 ns. */
35      public static final double DEFAULT_DATE_EQUALITY_THRESHOLD = 1e-9;
36  
37      /** First time stamped value. */
38      private final F first;
39  
40      /** Second time stamped value. */
41      private final S second;
42  
43      /**
44       * Constructor.
45       * <p>
46       * First and second value must have the same date.
47       *
48       * @param first first time stamped value
49       * @param second second time stamped value
50       */
51      public FieldTimeStampedPair(final F first, final S second) {
52          this(first, second, DEFAULT_DATE_EQUALITY_THRESHOLD);
53      }
54  
55      /**
56       * Constructor.
57       * <p>
58       * First and second value must have the same date.
59       *
60       * @param first first time stamped value
61       * @param second second time stamped value
62       * @param dateEqualityThreshold threshold below which dates are considered equal
63       */
64      public FieldTimeStampedPair(final F first, final S second, final double dateEqualityThreshold) {
65          TimeStampedPair.checkDatesConsistency(first.getDate().toAbsoluteDate(), second.getDate().toAbsoluteDate(),
66                                                dateEqualityThreshold);
67          this.first  = first;
68          this.second = second;
69      }
70  
71      /** {@inheritDoc} */
72      @Override
73      public FieldAbsoluteDate<KK> getDate() {
74          return first.getDate();
75      }
76  
77      /** Get first time stamped value.
78       * @return first time stamped value
79       */
80      public F getFirst() {
81          return first;
82      }
83  
84      /** Get second time stamped value.
85       * @return second time stamped value
86       */
87      public S getSecond() {
88          return second;
89      }
90  }