EopPredicate.java

  1. /* Copyright 2022-2025 Luc Maisonobe
  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.sinex;

  18. import org.orekit.time.AbsoluteDate;

  19. import java.util.function.BiConsumer;
  20. import java.util.function.Predicate;

  21. /** Predicate for EOP entries in SINEX files.
  22.  * @author Luc Maisonobe
  23.  * @since 13.0
  24.  */
  25. enum EopPredicate implements Predicate<SinexParseInfo> {

  26.     /** Parser for XPO line. */
  27.     XPO(SinexEopEntry::setxPo),

  28.     /** Parser for YPO line. */
  29.     YPO(SinexEopEntry::setyPo),

  30.     /** Parser for LOD line. */
  31.     LOD(SinexEopEntry::setLod),

  32.     /** Parser for UT line. */
  33.     UT(SinexEopEntry::setUt1MinusUtc),

  34.     /** Parser for NUT_LN line. */
  35.     NUT_LN(SinexEopEntry::setNutLn),

  36.     /** Parser for NUT_OB line. */
  37.     NUT_OB(SinexEopEntry::setNutOb),

  38.     /** Parser for NUT_X line. */
  39.     NUT_X(SinexEopEntry::setNutX),

  40.     /** Parser for NUT_Y line. */
  41.     NUT_Y(SinexEopEntry::setNutY);

  42.     /** Consumer for value. */
  43.     private final BiConsumer<SinexEopEntry, Double> consumer;

  44.     /** Simple constructor.
  45.      * @param consumer consumer for value
  46.      */
  47.     EopPredicate(final BiConsumer<SinexEopEntry, Double> consumer) {
  48.         this.consumer = consumer;
  49.     }

  50.     /** {@inheritDoc} */
  51.     @Override
  52.     public boolean test(final SinexParseInfo parseInfo) {
  53.         if (name().equals(parseInfo.parseString(7, 6))) {
  54.             // this is the data type we are concerned with
  55.             final AbsoluteDate date = parseInfo.stringEpochToAbsoluteDate(parseInfo.parseString(27, 12), false);
  56.             consumer.accept(parseInfo.createEOPEntry(date), parseInfo.parseDoubleWithUnit(40, 4, 47, 21));
  57.             return true;
  58.         } else {
  59.             // it is a data type for another predicate
  60.             return false;
  61.         }
  62.     }

  63. }