AbstractSolarActivityDataLoader.java

  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.models.earth.atmosphere.data;

  18. import org.orekit.data.DataLoader;
  19. import org.orekit.time.AbsoluteDate;
  20. import org.orekit.time.TimeScale;
  21. import org.orekit.time.TimeStamped;

  22. import java.io.Serializable;
  23. import java.util.SortedSet;

  24. /**
  25.  * Abstract class for solar activity data loader.
  26.  *
  27.  * @author Vincent Cucchietti
  28.  * @since 12.0
  29.  */
  30. public abstract class AbstractSolarActivityDataLoader<L extends AbstractSolarActivityDataLoader.LineParameters>
  31.         implements DataLoader {

  32.     /** UTC time scale. */
  33.     private final TimeScale utc;

  34.     /** First available date. */
  35.     private AbsoluteDate firstDate;

  36.     /** Last available date. */
  37.     private AbsoluteDate lastDate;

  38.     /**
  39.      * Constructor.
  40.      *
  41.      * @param utc UTC time scale
  42.      */
  43.     protected AbstractSolarActivityDataLoader(final TimeScale utc) {
  44.         this.utc = utc;
  45.     }

  46.     /** {@inheritDoc} */
  47.     @Override
  48.     public boolean stillAcceptsData() {
  49.         return true;
  50.     }

  51.     /**
  52.      * Get the data set.
  53.      *
  54.      * @return the data set
  55.      */
  56.     public abstract SortedSet<L> getDataSet();

  57.     /**
  58.      * Get the UTC timescale.
  59.      *
  60.      * @return the UTC timescale
  61.      */
  62.     public TimeScale getUTC() {
  63.         return utc;
  64.     }

  65.     /**
  66.      * Gets the available data range minimum date.
  67.      *
  68.      * @return the minimum date.
  69.      */
  70.     public AbsoluteDate getMinDate() {
  71.         return firstDate;
  72.     }

  73.     /**
  74.      * Gets the available data range maximum date.
  75.      *
  76.      * @return the maximum date.
  77.      */
  78.     public AbsoluteDate getMaxDate() {
  79.         return lastDate;
  80.     }

  81.     /** Container class for Solar activity indexes. */
  82.     public abstract static class LineParameters implements TimeStamped, Comparable<LineParameters>, Serializable {

  83.         /** Serializable UID. */
  84.         private static final long serialVersionUID = 6607862001953526475L;

  85.         /** Entry date. */
  86.         private final AbsoluteDate date;

  87.         /**
  88.          * Constructor.
  89.          *
  90.          * @param date entry date
  91.          */
  92.         protected LineParameters(final AbsoluteDate date) {
  93.             this.date = date;
  94.         }

  95.         /** {@inheritDoc} */
  96.         @Override
  97.         public abstract int compareTo(LineParameters lineParameters);

  98.         /** Check if the instance represents the same parameters as given line parameters.
  99.          * @param lineParameters other line parameters
  100.          * @return true if the instance and the other line parameter contain the same parameters
  101.          */
  102.         @Override
  103.         public abstract boolean equals(Object lineParameters);

  104.         /** Get a hashcode for this date.
  105.          * @return hashcode
  106.          */
  107.         @Override
  108.         public abstract int hashCode();

  109.         /** @return entry date */
  110.         @Override
  111.         public AbsoluteDate getDate() {
  112.             return date;
  113.         }
  114.     }

  115.     /**
  116.      * Set the available data range minimum date.
  117.      *
  118.      * @param date available data range minimum date
  119.      */
  120.     public void setMinDate(final AbsoluteDate date) {
  121.         this.firstDate = date;
  122.     }

  123.     /**
  124.      * Set the available data range maximum date.
  125.      *
  126.      * @param date available data range maximum date
  127.      */
  128.     public void setMaxDate(final AbsoluteDate date) {
  129.         this.lastDate = date;
  130.     }
  131. }