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.rinex.navigation;
18
19 import java.util.HashMap;
20 import java.util.Map;
21
22 /** Enumerate for region code.
23 * @see IonosphereKlobucharMessage
24 * @author Luc Maisonobe
25 * @since 12.0
26 */
27 public enum RegionCode {
28
29 /** Wide Area. */
30 WIDE_AREA(0, "WIDE"),
31
32 /** Japan area (for QZSS only). */
33 JAPAN(1, "JAPN");
34
35 /** Parsing map.
36 * @since 14.0
37 */
38 private static final Map<Integer, RegionCode> INTEGERS_MAP = new HashMap<>();
39
40 /** Parsing map.
41 * @since 14.0
42 */
43 private static final Map<String, RegionCode> STRINGS_MAP = new HashMap<>();
44
45 static {
46 for (final RegionCode regionCode : values()) {
47 INTEGERS_MAP.put(regionCode.getIntegerId(), regionCode);
48 STRINGS_MAP.put(regionCode.getStringId(), regionCode);
49 }
50 }
51
52 /** Integer identifier for region code.
53 * @since 14.0
54 */
55 private final int intId;
56
57 /** String identifier for region code.
58 * @since 14.0
59 */
60 private final String stringId;
61
62 /** Simple constructor.
63 * @param intId integer identifier for region code
64 * @param stringId string identifier for region code
65 * @since 14.0
66 */
67 RegionCode(final int intId, final String stringId) {
68 this.intId = intId;
69 this.stringId = stringId;
70 }
71
72 /** Get the integer identifier.
73 * @return integer identifier
74 * @since 14.0
75 */
76 public int getIntegerId() {
77 return intId;
78 }
79
80 /** Get the string identifier.
81 * @return string identifier
82 * @since 14.0
83 */
84 public String getStringId() {
85 return stringId;
86 }
87
88 /** Parse the integer to get the region code.
89 * @param i integer to parse
90 * @return the region code corresponding to the string
91 * @exception IllegalArgumentException if the string does not correspond to a region code
92 * @since 14.0
93 */
94 public static RegionCode parseRegionCode(final int i) {
95 return INTEGERS_MAP.get(i);
96 }
97
98 /** Parse the string to get the region code.
99 * @param s string to parse
100 * @return the region code corresponding to the string
101 * @exception IllegalArgumentException if the string does not correspond to a region code
102 * @since 14.0
103 */
104 public static RegionCode parseRegionCode(final String s) {
105 return STRINGS_MAP.get(s);
106 }
107
108 }