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.models.earth.atmosphere.data;
18  
19  import org.orekit.data.DataLoader;
20  import org.orekit.time.AbsoluteDate;
21  import org.orekit.time.TimeScale;
22  import org.orekit.time.TimeStamped;
23  
24  import java.io.Serializable;
25  import java.util.SortedSet;
26  
27  /**
28   * Abstract class for solar activity data loader.
29   *
30   * @author Vincent Cucchietti
31   * @since 12.0
32   */
33  public abstract class AbstractSolarActivityDataLoader<L extends AbstractSolarActivityDataLoader.LineParameters>
34          implements DataLoader {
35  
36      /** UTC time scale. */
37      private final TimeScale utc;
38  
39      /** First available date. */
40      private AbsoluteDate firstDate;
41  
42      /** Last available date. */
43      private AbsoluteDate lastDate;
44  
45      /**
46       * Constructor.
47       *
48       * @param utc UTC time scale
49       */
50      protected AbstractSolarActivityDataLoader(final TimeScale utc) {
51          this.utc = utc;
52      }
53  
54      /** {@inheritDoc} */
55      @Override
56      public boolean stillAcceptsData() {
57          return true;
58      }
59  
60      /**
61       * Get the data set.
62       *
63       * @return the data set
64       */
65      public abstract SortedSet<L> getDataSet();
66  
67      /**
68       * Get the UTC timescale.
69       *
70       * @return the UTC timescale
71       */
72      public TimeScale getUTC() {
73          return utc;
74      }
75  
76      /**
77       * Gets the available data range minimum date.
78       *
79       * @return the minimum date.
80       */
81      public AbsoluteDate getMinDate() {
82          return firstDate;
83      }
84  
85      /**
86       * Gets the available data range maximum date.
87       *
88       * @return the maximum date.
89       */
90      public AbsoluteDate getMaxDate() {
91          return lastDate;
92      }
93  
94      /** Container class for Solar activity indexes. */
95      public abstract static class LineParameters implements TimeStamped, Comparable<LineParameters>, Serializable {
96  
97          /** Serializable UID. */
98          private static final long serialVersionUID = 6607862001953526475L;
99  
100         /** Entry date. */
101         private final AbsoluteDate date;
102 
103         /**
104          * Constructor.
105          *
106          * @param date entry date
107          */
108         protected LineParameters(final AbsoluteDate date) {
109             this.date = date;
110         }
111 
112         /** {@inheritDoc} */
113         @Override
114         public abstract int compareTo(LineParameters lineParameters);
115 
116         /** Check if the instance represents the same parameters as given line parameters.
117          * @param lineParameters other line parameters
118          * @return true if the instance and the other line parameter contain the same parameters
119          */
120         @Override
121         public abstract boolean equals(Object lineParameters);
122 
123         /** Get a hashcode for this date.
124          * @return hashcode
125          */
126         @Override
127         public abstract int hashCode();
128 
129         /** @return entry date */
130         @Override
131         public AbsoluteDate getDate() {
132             return date;
133         }
134     }
135 
136     /**
137      * Set the available data range minimum date.
138      *
139      * @param date available data range minimum date
140      */
141     public void setMinDate(final AbsoluteDate date) {
142         this.firstDate = date;
143     }
144 
145     /**
146      * Set the available data range maximum date.
147      *
148      * @param date available data range maximum date
149      */
150     public void setMaxDate(final AbsoluteDate date) {
151         this.lastDate = date;
152     }
153 }