xref: /aosp_15_r20/external/cldr/tools/cldr-code/src/main/java/org/unicode/cldr/util/Organization.java (revision 912701f9769bb47905792267661f0baf2b85bed5)
1 package org.unicode.cldr.util;
2 
3 import com.google.common.collect.ImmutableSet;
4 import java.util.EnumSet;
5 import java.util.HashMap;
6 import java.util.Map;
7 import java.util.Set;
8 
9 /**
10  * This list needs updating as a new organizations are added; that's by design so that we know when
11  * new ones show up.
12  */
13 public enum Organization {
14     // Please update Locales.txt for default coverage when adding an organization here.
15     adlam("Winden Jangen Adlam"),
16     adobe("Adobe"),
17     afghan_csa("Afghan CSA"),
18     afghan_mcit("Afghan MCIT"),
19     afrigen("Afrigen"),
20     anii("Anii Research Group"),
21     apple("Apple"),
22     bangladesh("Bangladesh", "Bangladesh Computer Council"),
23     bangor_univ("Bangor Univ."),
24     bhutan("Bhutan DDC"),
25     breton("Office of Breton Lang"),
26     cherokee("Cherokee Nation"),
27     choctaw("Choctaw Nation"),
28     cldr("Cldr"),
29     gaeilge("Foras na Gaeilge"),
30     georgia_isi("Georgia ISI"),
31     gnome("Gnome Foundation"),
32     google("Google"),
33     ibm("IBM"),
34     india("India MIT"),
35     iran_hci("Iran HCI"),
36     kendra("Kendra (Nepal)"),
37     kotoistus("Kotoistus (Finnish IT Ctr)"),
38     kunsill_malti(
39             "Il-Kunsill Nazzjonali tal-Ilsien Malti",
40             "National Council for the Maltese Language",
41             "malta",
42             "malti"),
43     lakota_lc("Lakota LC"),
44     lao_dpt("Lao Posts/Telecom"),
45     longnow("The Long Now Foundation", "Long Now", "PanLex", "Utilika", "Utilka Foundation"),
46     meta("Meta", "Facebook"),
47     microsoft("Microsoft"),
48     mikmaw_kinamatnewey("Mi'kmaw Kina'matnewey"),
49     mozilla("Mozilla"),
50     netflix("Netflix"),
51     nyiakeng_puachue_hmong("Nyiakeng Puachue Hmong"),
52     openinstitute("Open Inst (Cambodia)"),
53     openoffice_org("Open Office"),
54     oracle("Oracle", "sun", "Sun Micro"),
55     pakistan("Pakistan"),
56     rodakych("Rodakych", "Nigerian Pidgin"),
57     rohingyazuban("Rohingya Language Council", "RLC", "Rohingya Zuban"),
58     rumantscha("Lia Rumantscha"),
59     sardware("Sardware", "Sardware"),
60     sil("SIL", "SIL International"),
61     special("High Coverage and Generated"),
62     srilanka("Sri Lanka ICTA", "Sri Lanka"),
63     surveytool("Survey Tool"),
64     unaffiliated("Unaffiliated", "Guest"),
65     venetian("VeC - Lengua Veneta"),
66     welsh_lc("Welsh LC"),
67     wikimedia("Wikimedia Foundation"),
68     wod_nko("WOD N’ko", "World Organization for the Development of N’ko", "WODN"),
69     wsci_wg("WSC+I WG", "Western Swampy Cree+Internet Working Group"),
70     yahoo("Yahoo"),
71     ;
72 
73     private static final Set<Organization> TC_ORGS =
74             ImmutableSet.copyOf(EnumSet.of(apple, google, meta, microsoft));
75 
76     /**
77      * Get a list of the TC Organizations
78      *
79      * @return the set
80      */
getTCOrgs()81     public static Set<Organization> getTCOrgs() {
82         return TC_ORGS;
83     }
84 
85     /**
86      * Is this organization a TC Org?
87      *
88      * @return true if it is TC
89      */
isTCOrg()90     public boolean isTCOrg() {
91         return getTCOrgs().contains(this);
92     }
93 
94     private final String displayName;
95     private final String[] names;
96 
fromString(String name)97     public static Organization fromString(String name) {
98         if (name == null) {
99             throw new NullPointerException("Organization.fromString(null) called");
100         }
101         if (name.contains("Government of Pakistan")) {
102             /*
103              * "Government of Pakistan - National Language Authority"
104              * occurs in the cldr_users table; avoid problems with hyphen
105              */
106             return Organization.pakistan;
107         } else if (name.contains("Utilika")) {
108             /*
109              * "Utilika" and "Utilika Foundation" occur in the cldr_users table.
110              * Compare "Utilka Foundation", one of the variants for Organization.longnow
111              */
112             return Organization.longnow;
113         }
114         name = name.toLowerCase().replace('-', '_').replace('.', '_');
115         return OrganizationNameMap.get(name);
116     }
117 
getDisplayName()118     public String getDisplayName() {
119         return displayName;
120     }
121 
122     static final Map<String, Organization> OrganizationNameMap;
123 
124     static {
125         OrganizationNameMap = new HashMap<>();
126         for (Organization x : values()) {
127             OrganizationNameMap.put(
128                     x.displayName.toLowerCase().replace('-', '_').replace('.', '_'), x);
129             for (String name : x.names) {
130                 OrganizationNameMap.put(name.toLowerCase().replace('-', '_').replace('.', '_'), x);
131             }
132             OrganizationNameMap.put(x.name().toLowerCase().replace('-', '_').replace('.', '_'), x);
133         }
134     }
135 
136     /**
137      * @param displayName Preferred display name for the organization
138      * @param names Alternate aliases for this organization
139      */
Organization(String displayName, String... names)140     Organization(String displayName, String... names) {
141         this.displayName = displayName;
142         this.names = names;
143     }
144 
145     private LocaleSet localeSet = null;
146 
getCoveredLocales()147     public LocaleSet getCoveredLocales() {
148         if (localeSet == null) {
149             final Set<String> localeNameSet = StandardCodes.make().getLocaleCoverageLocales(this);
150             if (localeNameSet.contains(LocaleNormalizer.ALL_LOCALES)) {
151                 localeSet = LocaleNormalizer.ALL_LOCALES_SET;
152             } else {
153                 localeSet = new LocaleSet(localeNameSet);
154             }
155         }
156         return localeSet;
157     }
158 
visibleOnFrontEnd()159     public boolean visibleOnFrontEnd() {
160         return this != Organization.special;
161     }
162 }
163