FieldTimeStampedPair.java

  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. import org.hipparchus.CalculusFieldElement;

  19. /**
  20.  * Pair of time stamped values being defined at the same date.
  21.  *
  22.  * @param <F> first time stamped value
  23.  * @param <S> second time stamped value
  24.  * @param <KK> type of the field element
  25.  *
  26.  * @author Vincent Cucchietti
  27.  * @see FieldTimeStamped
  28.  */
  29. public class FieldTimeStampedPair<F extends FieldTimeStamped<KK>, S extends FieldTimeStamped<KK>,
  30.         KK extends CalculusFieldElement<KK>> implements FieldTimeStamped<KK> {

  31.     /** Default date equality threshold of 1 ns. */
  32.     public static final double DEFAULT_DATE_EQUALITY_THRESHOLD = 1e-9;

  33.     /** First time stamped value. */
  34.     private final F first;

  35.     /** Second time stamped value. */
  36.     private final S second;

  37.     /**
  38.      * Constructor.
  39.      * <p>
  40.      * First and second value must have the same date.
  41.      *
  42.      * @param first first time stamped value
  43.      * @param second second time stamped value
  44.      */
  45.     public FieldTimeStampedPair(final F first, final S second) {
  46.         this(first, second, DEFAULT_DATE_EQUALITY_THRESHOLD);
  47.     }

  48.     /**
  49.      * Constructor.
  50.      * <p>
  51.      * First and second value must have the same date.
  52.      *
  53.      * @param first first time stamped value
  54.      * @param second second time stamped value
  55.      * @param dateEqualityThreshold threshold below which dates are considered equal
  56.      */
  57.     public FieldTimeStampedPair(final F first, final S second, final double dateEqualityThreshold) {
  58.         TimeStampedPair.checkDatesConsistency(first.getDate().toAbsoluteDate(), second.getDate().toAbsoluteDate(),
  59.                                               dateEqualityThreshold);
  60.         this.first  = first;
  61.         this.second = second;
  62.     }

  63.     /** {@inheritDoc} */
  64.     @Override
  65.     public FieldAbsoluteDate<KK> getDate() {
  66.         return first.getDate();
  67.     }

  68.     /** Get first time stamped value.
  69.      * @return first time stamped value
  70.      */
  71.     public F getFirst() {
  72.         return first;
  73.     }

  74.     /** Get second time stamped value.
  75.      * @return second time stamped value
  76.      */
  77.     public S getSecond() {
  78.         return second;
  79.     }
  80. }