*/
public final class ExcelAntWorkbookUtilFactory {
- private static Map<String, ExcelAntWorkbookUtil> workbookUtilMap;
+ private static final Map<String, ExcelAntWorkbookUtil> workbookUtilMap = new HashMap<>();
private ExcelAntWorkbookUtilFactory() {
}
* a freshly instantiated one if none did exist before.
*/
public static ExcelAntWorkbookUtil getInstance(String fileName) {
- if(workbookUtilMap == null) {
- workbookUtilMap = new HashMap<>();
+ synchronized (workbookUtilMap) {
+ if(workbookUtilMap.containsKey(fileName)) {
+ return workbookUtilMap.get(fileName);
+ }
+
+ ExcelAntWorkbookUtil wbu = new ExcelAntWorkbookUtil(fileName);
+ workbookUtilMap.put(fileName, wbu);
+ return wbu;
}
-
- if(workbookUtilMap.containsKey(fileName)) {
- return workbookUtilMap.get(fileName);
- }
-
- ExcelAntWorkbookUtil wbu = new ExcelAntWorkbookUtil(fileName);
- workbookUtilMap.put(fileName, wbu);
- return wbu;
}
}
==================================================================== */
package org.apache.poi.xwpf.usermodel;
+import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
*/
SUBSCRIPT(3);
- private static final Map<Integer, VerticalAlign> imap = new HashMap<>();
+ private static final Map<Integer, VerticalAlign> imap;
static {
+ final Map<Integer, VerticalAlign> tempMap = new HashMap<>();
for (VerticalAlign p : values()) {
- imap.put(p.getValue(), p);
+ tempMap.put(p.getValue(), p);
}
+ imap = Collections.unmodifiableMap(tempMap);
}
private final int value;