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
19 import org.orekit.time.AbsoluteDate;
20
21 import java.util.function.BiConsumer;
22 import java.util.function.Predicate;
23
24 /** Predicate for EOP entries in SINEX files.
25 * @author Luc Maisonobe
26 * @since 13.0
27 */
28 enum EopPredicate implements Predicate<SinexParseInfo> {
29
30 /** Parser for XPO line. */
31 XPO(SinexEopEntry::setxPo),
32
33 /** Parser for YPO line. */
34 YPO(SinexEopEntry::setyPo),
35
36 /** Parser for LOD line. */
37 LOD(SinexEopEntry::setLod),
38
39 /** Parser for UT line. */
40 UT(SinexEopEntry::setUt1MinusUtc),
41
42 /** Parser for NUT_LN line. */
43 NUT_LN(SinexEopEntry::setNutLn),
44
45 /** Parser for NUT_OB line. */
46 NUT_OB(SinexEopEntry::setNutOb),
47
48 /** Parser for NUT_X line. */
49 NUT_X(SinexEopEntry::setNutX),
50
51 /** Parser for NUT_Y line. */
52 NUT_Y(SinexEopEntry::setNutY);
53
54 /** Consumer for value. */
55 private final BiConsumer<SinexEopEntry, Double> consumer;
56
57 /** Simple constructor.
58 * @param consumer consumer for value
59 */
60 EopPredicate(final BiConsumer<SinexEopEntry, Double> consumer) {
61 this.consumer = consumer;
62 }
63
64 /** {@inheritDoc} */
65 @Override
66 public boolean test(final SinexParseInfo parseInfo) {
67 if (name().equals(parseInfo.parseString(7, 6))) {
68 // this is the data type we are concerned with
69 final AbsoluteDate date = parseInfo.stringEpochToAbsoluteDate(parseInfo.parseString(27, 12), false);
70 consumer.accept(parseInfo.createEOPEntry(date), parseInfo.parseDoubleWithUnit(40, 4, 47, 21));
71 return true;
72 } else {
73 // it is a data type for another predicate
74 return false;
75 }
76 }
77
78 }