Subversion Repository Public Repository

litesoft

Diff Revisions 960 vs 961 for /trunk/DeviceDesktopTest/src/org/litesoft/locale/Locales.java

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