BodyFacade.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.files.ccsds.definitions;

  18. import org.orekit.annotation.DefaultDataContext;
  19. import org.orekit.bodies.CelestialBodies;
  20. import org.orekit.bodies.CelestialBody;
  21. import org.orekit.data.DataContext;

  22. /** Facade in front of several center bodies in CCSDS messages.
  23.  * @author Luc Maisonobe
  24.  * @since 11.0
  25.  */
  26. public class BodyFacade {

  27.     /** Name of the center. */
  28.     private final String name;

  29.     /** Celestial body (may be null). */
  30.     private final CelestialBody body;

  31.     /** Simple constructor.
  32.      * @param name name of the frame
  33.      * @param body celestial body (may be null)
  34.      */
  35.     public BodyFacade(final String name, final CelestialBody body) {
  36.         this.name = name;
  37.         this.body = body;
  38.     }

  39.     /** Get the CCSDS name for the body.
  40.      * @return CCSDS name
  41.      */
  42.     public String getName() {
  43.         return name;
  44.     }

  45.     /** Get the celestial body.
  46.      * @return celestial body (may be null)
  47.      */
  48.     public CelestialBody getBody() {
  49.         return body;
  50.     }

  51.     /**
  52.      * Create a body facade from an input center name.
  53.      *
  54.      * <p>This method uses the {@link DataContext#getDefault() default data context}.
  55.      *
  56.      * @param centerName input center name
  57.      * @return a body facade corresponding to the input center name
  58.      * @since 11.2
  59.      */
  60.     @DefaultDataContext
  61.     public static BodyFacade create(final CenterName centerName) {
  62.         return create(centerName, DataContext.getDefault());
  63.     }

  64.     /**
  65.      * Create a body facade from an input center name.
  66.      *
  67.      * @param centerName input center name
  68.      * @param context data context
  69.      * @return a body facade corresponding to the input center name
  70.      * @since 12.0
  71.      */
  72.     public static BodyFacade create(final CenterName centerName, final DataContext context) {
  73.         return create(centerName, context.getCelestialBodies());
  74.     }

  75.     /**
  76.      * Create a body facade from an input center name.
  77.      *
  78.      * @param centerName input center name
  79.      * @param bodies celestial bodies
  80.      * @return a body facade corresponding to the input center name
  81.      * @since 12.0
  82.      */
  83.     public static BodyFacade create(final CenterName centerName, final CelestialBodies bodies) {
  84.         return new BodyFacade(centerName.name(), centerName.getCelestialBody(bodies));
  85.     }

  86. }