Subversion Repository Public Repository

litesoft

Diff Revisions 931 vs 935 for /trunk/DeviceDesktopTest/src/org/litesoft/locale/Locales.java

Diff revisions: vs.
  @@ -1,25 +1,26 @@
1 1 package org.litesoft.locale;
2 2
3 - import java.util.ArrayList;
4 - import java.util.Collections;
5 - import java.util.HashSet;
6 - import java.util.List;
7 - import java.util.Set;
3 + import java.util.*;
8 4
9 5 @SuppressWarnings("Convert2Diamond")
10 - public final class Locales {
6 + public final class Locales
7 + {
11 8 private static Locales sInstance;
12 9
13 - public static synchronized Locales getInstance() {
14 - if (sInstance == null) {
15 - throw new IllegalStateException("Locales referenced before being initialized!");
10 + public static synchronized Locales getInstance()
11 + {
12 + if ( sInstance == null )
13 + {
14 + throw new IllegalStateException( "Locales referenced before being initialized!" );
16 15 }
17 16 return sInstance;
18 17 }
19 18
20 - private static synchronized void setInstance(Locales pInstance) {
21 - if (sInstance != null) {
22 - throw new IllegalStateException("Duplicate Locales created!");
19 + private static synchronized void setInstance( Locales pInstance )
20 + {
21 + if ( sInstance != null )
22 + {
23 + throw new IllegalStateException( "Duplicate Locales created!" );
23 24 }
24 25 sInstance = pInstance;
25 26 }
  @@ -27,28 +28,34 @@
27 28 private final Set<AbstractLocale> mSupported;
28 29 private final List<String> mActiveCodes = new ArrayList<String>();
29 30
30 - public Locales(AbstractLocale... pSupportedLocales) {
31 - mSupported = Collections.unmodifiableSet(toSet(pSupportedLocales));
32 - for (AbstractLocale zLocale : pSupportedLocales) {
33 - if (zLocale.isActive()) {
34 - mActiveCodes.add(zLocale.getCode());
31 + public Locales( AbstractLocale... pSupportedLocales )
32 + {
33 + mSupported = Collections.unmodifiableSet( toSet( pSupportedLocales ) );
34 + for ( AbstractLocale zLocale : pSupportedLocales )
35 + {
36 + if ( zLocale.isActive() )
37 + {
38 + mActiveCodes.add( zLocale.getCode() );
35 39 }
36 40 }
37 - setInstance(this); // 'this' leakage, but is final class!
41 + setInstance( this ); // 'this' leakage, but is final class!
38 42 }
39 43
40 - public static Set<AbstractLocale> getSupported() {
44 + public static Set<AbstractLocale> getSupported()
45 + {
41 46 return getInstance().mSupported;
42 47 }
43 48
44 - public static String[] getActiveCodes() {
49 + public static String[] getActiveCodes()
50 + {
45 51 List<String> zActiveCodes = getInstance().mActiveCodes;
46 - return zActiveCodes.toArray(new String[zActiveCodes.size()]);
52 + return zActiveCodes.toArray( new String[zActiveCodes.size()] );
47 53 }
48 54
49 - public static Set<AbstractLocale> toSet(AbstractLocale... pSupportedLocales) {
55 + public static Set<AbstractLocale> toSet( AbstractLocale... pSupportedLocales )
56 + {
50 57 Set<AbstractLocale> zLocales = new HashSet<>();
51 - Collections.addAll(zLocales, pSupportedLocales);
58 + Collections.addAll( zLocales, pSupportedLocales );
52 59 return zLocales;
53 60 }
54 61 }