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