xref: /aosp_15_r20/external/cldr/tools/cldr-code/src/main/java/org/unicode/cldr/api/CldrDraftStatus.java (revision 912701f9769bb47905792267661f0baf2b85bed5)
1 package org.unicode.cldr.api;
2 
3 import com.google.common.base.Ascii;
4 import java.util.Optional;
5 import org.unicode.cldr.util.CLDRFile.DraftStatus;
6 
7 /**
8  * Draft status for controlling which values to visit. Draft statuses are ordered by ordinal value,
9  * with {@code UNCONFIRMED} being the most lenient status (include everything) and {@code APPROVED}
10  * being the strictest.
11  *
12  * <p>This enum is largely a wrapper for functionality found in the underlying CLDR classes, but
13  * repackaged for convenience and to minimize surface area (and to avoid anyone needing to import
14  * classes from outside the "api" package).
15  */
16 public enum CldrDraftStatus {
17     /** Include all values during visitation, performing no filtering. */
18     UNCONFIRMED(DraftStatus.unconfirmed),
19     /** Include only values with "provisional" status or higher during visitation. */
20     PROVISIONAL(DraftStatus.provisional),
21     /** Include only values with "contributed" status or higher during visitation. */
22     CONTRIBUTED(DraftStatus.contributed),
23     /** Include only "approved" values. */
24     APPROVED(DraftStatus.approved);
25 
26     private final DraftStatus rawStatus;
27     private final Optional<CldrDraftStatus> optStatus;
28 
CldrDraftStatus(DraftStatus rawType)29     CldrDraftStatus(DraftStatus rawType) {
30         this.rawStatus = rawType;
31         this.optStatus = Optional.of(this);
32     }
33 
getRawStatus()34     DraftStatus getRawStatus() {
35         return rawStatus;
36     }
37 
asOptional()38     Optional<CldrDraftStatus> asOptional() {
39         return optStatus;
40     }
41 
forString( String name)42     static /* @Nullable */ CldrDraftStatus forString(/* @Nullable */ String name) {
43         return name != null ? CldrDraftStatus.valueOf(Ascii.toUpperCase(name)) : null;
44     }
45 }
46