43
43
*
44
44
* @author Hardy Ferentschik
45
45
* @author Gunnar Morling
46
+ * @author Guillaume Smet
46
47
*/
47
48
public class PlatformResourceBundleLocator implements ResourceBundleLocator {
48
49
@@ -53,7 +54,6 @@ public class PlatformResourceBundleLocator implements ResourceBundleLocator {
53
54
private final ClassLoader classLoader ;
54
55
private final boolean aggregate ;
55
56
56
- private final boolean preloadResourceBundles ;
57
57
@ Immutable
58
58
private final Map <Locale , ResourceBundle > preloadedResourceBundles ;
59
59
@@ -63,7 +63,7 @@ public class PlatformResourceBundleLocator implements ResourceBundleLocator {
63
63
* @param bundleName the name of the bundle to load
64
64
*/
65
65
public PlatformResourceBundleLocator (String bundleName ) {
66
- this ( bundleName , false , Collections .emptySet () );
66
+ this ( bundleName , Collections .emptySet () );
67
67
}
68
68
69
69
/**
@@ -77,7 +77,7 @@ public PlatformResourceBundleLocator(String bundleName) {
77
77
* @since 5.2
78
78
*/
79
79
public PlatformResourceBundleLocator (String bundleName , ClassLoader classLoader ) {
80
- this ( bundleName , false , Collections .emptySet (), classLoader );
80
+ this ( bundleName , Collections .emptySet (), classLoader );
81
81
}
82
82
83
83
/**
@@ -92,46 +92,42 @@ public PlatformResourceBundleLocator(String bundleName, ClassLoader classLoader)
92
92
* @since 5.2
93
93
*/
94
94
public PlatformResourceBundleLocator (String bundleName , ClassLoader classLoader , boolean aggregate ) {
95
- this ( bundleName , false , Collections .emptySet (), classLoader , aggregate );
95
+ this ( bundleName , Collections .emptySet (), classLoader , aggregate );
96
96
}
97
97
98
98
/**
99
99
* Creates a new {@link PlatformResourceBundleLocator}.
100
100
*
101
101
* @param bundleName the name of the bundle to load
102
- * @param preloadResourceBundles if resource bundles should be initialized when initializing the locator
103
102
* @param localesToInitialize the set of locales to initialize at bootstrap
104
103
*
105
104
* @since 6.1.1
106
105
*/
107
106
@ Incubating
108
- public PlatformResourceBundleLocator (String bundleName , boolean preloadResourceBundles , Set <Locale > localesToInitialize ) {
109
- this ( bundleName , preloadResourceBundles , localesToInitialize , null );
107
+ public PlatformResourceBundleLocator (String bundleName , Set <Locale > localesToInitialize ) {
108
+ this ( bundleName , localesToInitialize , null );
110
109
}
111
110
112
111
/**
113
112
* Creates a new {@link PlatformResourceBundleLocator}.
114
113
*
115
114
* @param bundleName the name of the bundle to load
116
- * @param preloadResourceBundles if resource bundles should be initialized when initializing the locator
117
115
* @param localesToInitialize the set of locales to initialize at bootstrap
118
116
* @param classLoader the classloader to be used for loading the bundle. If {@code null}, the current thread context
119
117
* classloader and finally Hibernate Validator's own classloader will be used for loading the specified
120
118
* bundle.
121
- * @param preloadResourceBundles if resource bundles should be initialized when initializing the locator
122
119
*
123
120
* @since 6.1.1
124
121
*/
125
122
@ Incubating
126
- public PlatformResourceBundleLocator (String bundleName , boolean preloadResourceBundles , Set <Locale > localesToInitialize , ClassLoader classLoader ) {
127
- this ( bundleName , preloadResourceBundles , localesToInitialize , classLoader , false );
123
+ public PlatformResourceBundleLocator (String bundleName , Set <Locale > localesToInitialize , ClassLoader classLoader ) {
124
+ this ( bundleName , localesToInitialize , classLoader , false );
128
125
}
129
126
130
127
/**
131
128
* Creates a new {@link PlatformResourceBundleLocator}.
132
129
*
133
130
* @param bundleName the name of the bundle to load
134
- * @param preloadResourceBundles if resource bundles should be initialized when initializing the locator
135
131
* @param localesToInitialize the set of locales to initialize at bootstrap
136
132
* @param classLoader the classloader to be used for loading the bundle. If {@code null}, the current thread context
137
133
* classloader and finally Hibernate Validator's own classloader will be used for loading the specified
@@ -142,7 +138,6 @@ public PlatformResourceBundleLocator(String bundleName, boolean preloadResourceB
142
138
*/
143
139
@ Incubating
144
140
public PlatformResourceBundleLocator (String bundleName ,
145
- boolean preloadResourceBundles ,
146
141
Set <Locale > localesToInitialize ,
147
142
ClassLoader classLoader ,
148
143
boolean aggregate ) {
@@ -153,11 +148,7 @@ public PlatformResourceBundleLocator(String bundleName,
153
148
154
149
this .aggregate = aggregate && RESOURCE_BUNDLE_CONTROL_INSTANTIABLE ;
155
150
156
- this .preloadResourceBundles = preloadResourceBundles ;
157
-
158
- if ( preloadResourceBundles ) {
159
- Contracts .assertNotEmpty ( localesToInitialize , "localesToInitialize may not be empty if resource bundles have to be preloaded" );
160
-
151
+ if ( !localesToInitialize .isEmpty () ) {
161
152
Map <Locale , ResourceBundle > tmpPreloadedResourceBundles = CollectionHelper .newHashMap ( localesToInitialize .size () );
162
153
for ( Locale localeToPreload : localesToInitialize ) {
163
154
tmpPreloadedResourceBundles .put ( localeToPreload , doGetResourceBundle ( localeToPreload ) );
@@ -179,7 +170,7 @@ public PlatformResourceBundleLocator(String bundleName,
179
170
*/
180
171
@ Override
181
172
public ResourceBundle getResourceBundle (Locale locale ) {
182
- if ( preloadResourceBundles ) {
173
+ if ( ! preloadedResourceBundles . isEmpty () ) {
183
174
// we need to use containsKey() as the cached resource bundle can be null
184
175
if ( preloadedResourceBundles .containsKey ( locale ) ) {
185
176
return preloadedResourceBundles .get ( locale );
0 commit comments