1   /* Copyright 2002-2026 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  
18  package org.orekit.files.ccsds.ndm.odm.ocm;
19  
20  import java.util.List;
21  import java.util.Optional;
22  
23  import org.orekit.annotation.Nullable;
24  import org.orekit.files.ccsds.ndm.odm.UserDefined;
25  import org.orekit.files.ccsds.section.Data;
26  import org.orekit.files.ccsds.utils.Initializer;
27  
28  /** Data container for Orbit Comprehensive Messages.
29   * @author Luc Maisonobe
30   * @since 11.0
31   */
32  public class OcmData implements Data {
33  
34      /** Trajectory state histories logical blocks. */
35      private final List<TrajectoryStateHistory> trajectoryBlocks;
36  
37      /** Physical properties logical block. */
38      @Nullable
39      private final OrbitPhysicalProperties physicBlock;
40  
41      /** Covariance logical blocks. */
42      private final List<OrbitCovarianceHistory> covarianceBlocks;
43  
44      /** Maneuvers logical blocks. */
45      private final List<OrbitManeuverHistory> maneuverBlocks;
46  
47      /** Perturbations logical block. */
48      @Nullable
49      private final Perturbations perturbationsBlock;
50  
51      /** Orbit determination logical block. */
52      @Nullable
53      private final OrbitDetermination orbitDeterminationBlock;
54  
55      /** User defined parameters logical block. */
56      @Nullable
57      private final UserDefined userDefinedBlock;
58  
59      /** Simple constructor.
60       * @param trajectoryBlocks trajectory state histories logical blocks (may be empty)
61       * @param physicBlock physical properties logical block (may be null)
62       * @param covarianceBlocks covariance logical blocks (may be empty)
63       * @param maneuverBlocks maneuvers logical blocks (may be empty)
64       * @param perturbationsBlock perturbations logical block (may be null)
65       * @param orbitDeterminationBlock orbit determination logical block (may be null)
66       * @param userDefinedBlock user defined parameters logical block (may be null)
67       */
68      public OcmData(final List<TrajectoryStateHistory> trajectoryBlocks,
69                     final OrbitPhysicalProperties      physicBlock,
70                     final List<OrbitCovarianceHistory> covarianceBlocks,
71                     final List<OrbitManeuverHistory>   maneuverBlocks,
72                     final Perturbations                perturbationsBlock,
73                     final OrbitDetermination           orbitDeterminationBlock,
74                     final UserDefined                  userDefinedBlock) {
75          this.trajectoryBlocks         = Initializer.emptyListIfNull(trajectoryBlocks);
76          this.physicBlock              = physicBlock;
77          this.covarianceBlocks         = Initializer.emptyListIfNull(covarianceBlocks);
78          this.maneuverBlocks           = Initializer.emptyListIfNull(maneuverBlocks);
79          this.perturbationsBlock       = perturbationsBlock;
80          this.orbitDeterminationBlock  = orbitDeterminationBlock;
81          this.userDefinedBlock         = userDefinedBlock;
82      }
83  
84      /** {@inheritDoc} */
85      @Override
86      public void validate(final double version) {
87          trajectoryBlocks.forEach(osh -> osh.getMetadata().validate(version));
88          if (physicBlock != null) {
89              physicBlock.validate(version);
90          }
91          covarianceBlocks.forEach(ch -> ch.getMetadata().validate(version));
92          maneuverBlocks.forEach(mh -> mh.getMetadata().validate(version));
93          if (perturbationsBlock != null) {
94              perturbationsBlock.validate(version);
95          }
96          if (orbitDeterminationBlock != null) {
97              orbitDeterminationBlock.validate(version);
98          }
99          if (userDefinedBlock != null) {
100             userDefinedBlock.validate(version);
101         }
102     }
103 
104     /** Get trajectory state histories logical blocks.
105      * @return trajectory state histories logical blocks
106      * @since 12.0
107      */
108     public List<TrajectoryStateHistory> getTrajectoryBlocks() {
109         return trajectoryBlocks;
110     }
111 
112     /** Get physical properties logical block.
113      * @return physical properties logical block
114      */
115     public Optional<OrbitPhysicalProperties> getPhysicBlock() {
116         return Optional.ofNullable(physicBlock);
117     }
118 
119     /** Get covariance logical blocks.
120      * @return covariance logical blocks
121      */
122     public List<OrbitCovarianceHistory> getCovarianceBlocks() {
123         return covarianceBlocks;
124     }
125 
126     /** Get maneuvers logical blocks.
127      * @return maneuvers logical blocks
128      */
129     public List<OrbitManeuverHistory> getManeuverBlocks() {
130         return maneuverBlocks;
131     }
132 
133     /** Get perturbations logical block.
134      * @return perturbations logical block
135      */
136     public Optional<Perturbations> getPerturbationsBlock() {
137         return Optional.ofNullable(perturbationsBlock);
138     }
139 
140     /** Get orbit determination logical block.
141      * @return orbit determination logical block
142      */
143     public Optional<OrbitDetermination> getOrbitDeterminationBlock() {
144         return Optional.ofNullable(orbitDeterminationBlock);
145     }
146 
147     /** Get user defined parameters logical block.
148      * @return user defined parameters logical block
149      */
150     public Optional<UserDefined> getUserDefinedBlock() {
151         return Optional.ofNullable(userDefinedBlock);
152     }
153 
154 }