make static maps final

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1921340 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
PJ Fanning 2024-10-15 16:33:15 +00:00
parent c5986447d1
commit 822974aadc
10 changed files with 39 additions and 19 deletions

View File

@ -604,7 +604,7 @@ public enum Borders {
static { static {
final Map<Integer, Borders> tempMap = new HashMap<>(); final Map<Integer, Borders> tempMap = new HashMap<>();
for (Borders p : values()) { for (Borders p : values()) {
tempMap.put(Integer.valueOf(p.getValue()), p); tempMap.put(p.getValue(), p);
} }
imap = Collections.unmodifiableMap(tempMap); imap = Collections.unmodifiableMap(tempMap);
} }

View File

@ -16,6 +16,7 @@
==================================================================== */ ==================================================================== */
package org.apache.poi.xwpf.usermodel; package org.apache.poi.xwpf.usermodel;
import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -54,12 +55,14 @@ public enum BreakType {
*/ */
TEXT_WRAPPING(3); TEXT_WRAPPING(3);
private static Map<Integer, BreakType> imap = new HashMap<>(); private static final Map<Integer, BreakType> imap;
static { static {
final Map<Integer, BreakType> tempMap = new HashMap<>();
for (BreakType p : values()) { for (BreakType p : values()) {
imap.put(p.getValue(), p); tempMap.put(p.getValue(), p);
} }
imap = Collections.unmodifiableMap(tempMap);
} }
private final int value; private final int value;

View File

@ -16,6 +16,7 @@
==================================================================== */ ==================================================================== */
package org.apache.poi.xwpf.usermodel; package org.apache.poi.xwpf.usermodel;
import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -47,12 +48,14 @@ public enum LineSpacingRule {
AT_LEAST(3); AT_LEAST(3);
private static Map<Integer, LineSpacingRule> imap = new HashMap<>(); private static final Map<Integer, LineSpacingRule> imap;
static { static {
final Map<Integer, LineSpacingRule> tempMap = new HashMap<>();
for (LineSpacingRule p : values()) { for (LineSpacingRule p : values()) {
imap.put(p.getValue(), p); tempMap.put(p.getValue(), p);
} }
imap = Collections.unmodifiableMap(tempMap);
} }
private final int value; private final int value;

View File

@ -18,6 +18,7 @@ package org.apache.poi.xwpf.usermodel;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.STJcTable; import org.openxmlformats.schemas.wordprocessingml.x2006.main.STJcTable;
import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -30,12 +31,14 @@ public enum TableRowAlign {
CENTER(STJcTable.INT_CENTER), CENTER(STJcTable.INT_CENTER),
RIGHT(STJcTable.INT_END); RIGHT(STJcTable.INT_END);
private static Map<Integer, TableRowAlign> imap = new HashMap<>(); private static final Map<Integer, TableRowAlign> imap;
static { static {
final Map<Integer, TableRowAlign> tempMap = new HashMap<>();
for (TableRowAlign p : values()) { for (TableRowAlign p : values()) {
imap.put(p.getValue(), p); tempMap.put(p.getValue(), p);
} }
imap = Collections.unmodifiableMap(tempMap);
} }
private final int value; private final int value;

View File

@ -16,6 +16,7 @@
==================================================================== */ ==================================================================== */
package org.apache.poi.xwpf.usermodel; package org.apache.poi.xwpf.usermodel;
import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -28,12 +29,14 @@ public enum TableRowHeightRule {
EXACT(2), EXACT(2),
AT_LEAST(3); AT_LEAST(3);
private static Map<Integer, TableRowHeightRule> imap = new HashMap<>(); private static final Map<Integer, TableRowHeightRule> imap;
static { static {
final Map<Integer, TableRowHeightRule> tempMap = new HashMap<>();
for (TableRowHeightRule p : values()) { for (TableRowHeightRule p : values()) {
imap.put(p.getValue(), p); tempMap.put(p.getValue(), p);
} }
imap = Collections.unmodifiableMap(tempMap);
} }
private final int value; private final int value;

View File

@ -16,6 +16,7 @@
==================================================================== */ ==================================================================== */
package org.apache.poi.xwpf.usermodel; package org.apache.poi.xwpf.usermodel;
import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -50,12 +51,14 @@ public enum TextAlignment {
*/ */
AUTO(5); AUTO(5);
private static Map<Integer, TextAlignment> imap = new HashMap<>(); private static final Map<Integer, TextAlignment> imap;
static { static {
final Map<Integer, TextAlignment> tempMap = new HashMap<>();
for (TextAlignment p : values()) { for (TextAlignment p : values()) {
imap.put(p.getValue(), p); tempMap.put(p.getValue(), p);
} }
imap = Collections.unmodifiableMap(tempMap);
} }
private final int value; private final int value;

View File

@ -30,7 +30,7 @@ import java.util.Map;
* ones, so we can't just re-use the HSMF ones. * ones, so we can't just re-use the HSMF ones.
*/ */
public final class TNEFProperty { public final class TNEFProperty {
private static Map<Integer, List<TNEFProperty>> properties = new HashMap<>(); private static final Map<Integer, List<TNEFProperty>> properties = new HashMap<>();
// Types taken from http://msdn.microsoft.com/en-us/library/microsoft.exchange.data.contenttypes.tnef.tnefattributetype%28v=EXCHG.140%29.aspx // Types taken from http://msdn.microsoft.com/en-us/library/microsoft.exchange.data.contenttypes.tnef.tnefattributetype%28v=EXCHG.140%29.aspx
public static final int TYPE_TRIPLES = 0x0000; public static final int TYPE_TRIPLES = 0x0000;

View File

@ -46,7 +46,7 @@ import static org.apache.poi.hsmf.datatypes.Types.TIME;
*/ */
@SuppressWarnings("unused") @SuppressWarnings("unused")
public class MAPIProperty { public class MAPIProperty {
private static Map<Integer, MAPIProperty> attributes = new HashMap<>(); private static final Map<Integer, MAPIProperty> attributes = new HashMap<>();
public static final MAPIProperty AB_DEFAULT_DIR = public static final MAPIProperty AB_DEFAULT_DIR =
new MAPIProperty(0x3d06, BINARY, "AbDefaultDir", "PR_AB_DEFAULT_DIR"); new MAPIProperty(0x3d06, BINARY, "AbDefaultDir", "PR_AB_DEFAULT_DIR");

View File

@ -17,6 +17,7 @@
package org.apache.poi.ss.formula.functions; package org.apache.poi.ss.formula.functions;
import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
@ -75,16 +76,20 @@ public final class LookupUtils {
public int getIntValue() { return intValue; } public int getIntValue() { return intValue; }
} }
private static Map<Integer, MatchMode> matchModeMap = new HashMap<>(); private static final Map<Integer, MatchMode> matchModeMap;
private static Map<Integer, SearchMode> searchModeMap = new HashMap<>(); private static final Map<Integer, SearchMode> searchModeMap;
static { static {
final Map<Integer, MatchMode> mmMap = new HashMap<>();
for (MatchMode mode : MatchMode.values()) { for (MatchMode mode : MatchMode.values()) {
matchModeMap.put(mode.getIntValue(), mode); mmMap.put(mode.getIntValue(), mode);
} }
matchModeMap = Collections.unmodifiableMap(mmMap);
final Map<Integer, SearchMode> smMap = new HashMap<>();
for (SearchMode mode : SearchMode.values()) { for (SearchMode mode : SearchMode.values()) {
searchModeMap.put(mode.getIntValue(), mode); smMap.put(mode.getIntValue(), mode);
} }
searchModeMap = Collections.unmodifiableMap(smMap);
} }
public static MatchMode matchMode(int m) { public static MatchMode matchMode(int m) {
@ -588,7 +593,7 @@ public final class LookupUtils {
if (valEval instanceof StringEval) { if (valEval instanceof StringEval) {
String stringValue = ((StringEval) valEval).getStringValue(); String stringValue = ((StringEval) valEval).getStringValue();
if(stringValue.length() < 1) { if(stringValue.isEmpty()) {
// More trickiness: // More trickiness:
// Empty string is not the same as BlankEval. It causes #VALUE! error // Empty string is not the same as BlankEval. It causes #VALUE! error
throw EvaluationException.invalidValue(); throw EvaluationException.invalidValue();

View File

@ -26,7 +26,7 @@ import java.util.Map;
* Represents a type of a conditional formatting rule * Represents a type of a conditional formatting rule
*/ */
public class ConditionType { public class ConditionType {
private static Map<Integer,ConditionType> lookup = new HashMap<>(); private static final Map<Integer, ConditionType> lookup = new HashMap<>();
/** /**
* This conditional formatting rule compares a cell value * This conditional formatting rule compares a cell value