diff options
author | PJ Fanning <fanningpj@apache.org> | 2024-10-15 16:33:15 +0000 |
---|---|---|
committer | PJ Fanning <fanningpj@apache.org> | 2024-10-15 16:33:15 +0000 |
commit | 822974aadc69be4482b710505fae4b220eecf29c (patch) | |
tree | 0af6e4f7059a57f38a19c563b67dbca4631be29d | |
parent | c5986447d18d6bb3a06f5a31888a244355c963ac (diff) | |
download | poi-822974aadc69be4482b710505fae4b220eecf29c.tar.gz poi-822974aadc69be4482b710505fae4b220eecf29c.zip |
make static maps final
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1921340 13f79535-47bb-0310-9956-ffa450edef68
10 files changed, 39 insertions, 19 deletions
diff --git a/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/Borders.java b/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/Borders.java index 2ab27d37da..6b08e0ee25 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/Borders.java +++ b/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/Borders.java @@ -604,7 +604,7 @@ public enum Borders { static { final Map<Integer, Borders> tempMap = new HashMap<>(); for (Borders p : values()) { - tempMap.put(Integer.valueOf(p.getValue()), p); + tempMap.put(p.getValue(), p); } imap = Collections.unmodifiableMap(tempMap); } diff --git a/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/BreakType.java b/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/BreakType.java index f86a89e25f..5eaebd9b68 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/BreakType.java +++ b/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/BreakType.java @@ -16,6 +16,7 @@ ==================================================================== */ package org.apache.poi.xwpf.usermodel; +import java.util.Collections; import java.util.HashMap; import java.util.Map; @@ -54,12 +55,14 @@ public enum BreakType { */ TEXT_WRAPPING(3); - private static Map<Integer, BreakType> imap = new HashMap<>(); + private static final Map<Integer, BreakType> imap; static { + final Map<Integer, BreakType> tempMap = new HashMap<>(); for (BreakType p : values()) { - imap.put(p.getValue(), p); + tempMap.put(p.getValue(), p); } + imap = Collections.unmodifiableMap(tempMap); } private final int value; diff --git a/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/LineSpacingRule.java b/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/LineSpacingRule.java index b8b6fbde71..4b9cb9804e 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/LineSpacingRule.java +++ b/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/LineSpacingRule.java @@ -16,6 +16,7 @@ ==================================================================== */ package org.apache.poi.xwpf.usermodel; +import java.util.Collections; import java.util.HashMap; import java.util.Map; @@ -47,12 +48,14 @@ public enum LineSpacingRule { AT_LEAST(3); - private static Map<Integer, LineSpacingRule> imap = new HashMap<>(); + private static final Map<Integer, LineSpacingRule> imap; static { + final Map<Integer, LineSpacingRule> tempMap = new HashMap<>(); for (LineSpacingRule p : values()) { - imap.put(p.getValue(), p); + tempMap.put(p.getValue(), p); } + imap = Collections.unmodifiableMap(tempMap); } private final int value; diff --git a/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/TableRowAlign.java b/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/TableRowAlign.java index 35e80d33b1..06653cdb33 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/TableRowAlign.java +++ b/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/TableRowAlign.java @@ -18,6 +18,7 @@ package org.apache.poi.xwpf.usermodel; import org.openxmlformats.schemas.wordprocessingml.x2006.main.STJcTable; +import java.util.Collections; import java.util.HashMap; import java.util.Map; @@ -30,12 +31,14 @@ public enum TableRowAlign { CENTER(STJcTable.INT_CENTER), RIGHT(STJcTable.INT_END); - private static Map<Integer, TableRowAlign> imap = new HashMap<>(); + private static final Map<Integer, TableRowAlign> imap; static { + final Map<Integer, TableRowAlign> tempMap = new HashMap<>(); for (TableRowAlign p : values()) { - imap.put(p.getValue(), p); + tempMap.put(p.getValue(), p); } + imap = Collections.unmodifiableMap(tempMap); } private final int value; diff --git a/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/TableRowHeightRule.java b/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/TableRowHeightRule.java index 2a42c76baf..cbe41afc6e 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/TableRowHeightRule.java +++ b/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/TableRowHeightRule.java @@ -16,6 +16,7 @@ ==================================================================== */ package org.apache.poi.xwpf.usermodel; +import java.util.Collections; import java.util.HashMap; import java.util.Map; @@ -28,12 +29,14 @@ public enum TableRowHeightRule { EXACT(2), AT_LEAST(3); - private static Map<Integer, TableRowHeightRule> imap = new HashMap<>(); + private static final Map<Integer, TableRowHeightRule> imap; static { + final Map<Integer, TableRowHeightRule> tempMap = new HashMap<>(); for (TableRowHeightRule p : values()) { - imap.put(p.getValue(), p); + tempMap.put(p.getValue(), p); } + imap = Collections.unmodifiableMap(tempMap); } private final int value; diff --git a/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/TextAlignment.java b/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/TextAlignment.java index 3fb8231589..97d9e3cd53 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/TextAlignment.java +++ b/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/TextAlignment.java @@ -16,6 +16,7 @@ ==================================================================== */ package org.apache.poi.xwpf.usermodel; +import java.util.Collections; import java.util.HashMap; import java.util.Map; @@ -50,12 +51,14 @@ public enum TextAlignment { */ AUTO(5); - private static Map<Integer, TextAlignment> imap = new HashMap<>(); + private static final Map<Integer, TextAlignment> imap; static { + final Map<Integer, TextAlignment> tempMap = new HashMap<>(); for (TextAlignment p : values()) { - imap.put(p.getValue(), p); + tempMap.put(p.getValue(), p); } + imap = Collections.unmodifiableMap(tempMap); } private final int value; diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hmef/attribute/TNEFProperty.java b/poi-scratchpad/src/main/java/org/apache/poi/hmef/attribute/TNEFProperty.java index e90c910470..151ac152ff 100644 --- a/poi-scratchpad/src/main/java/org/apache/poi/hmef/attribute/TNEFProperty.java +++ b/poi-scratchpad/src/main/java/org/apache/poi/hmef/attribute/TNEFProperty.java @@ -30,7 +30,7 @@ import java.util.Map; * ones, so we can't just re-use the HSMF ones. */ 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 public static final int TYPE_TRIPLES = 0x0000; diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hsmf/datatypes/MAPIProperty.java b/poi-scratchpad/src/main/java/org/apache/poi/hsmf/datatypes/MAPIProperty.java index b09e39cc7a..5afe53b6bf 100644 --- a/poi-scratchpad/src/main/java/org/apache/poi/hsmf/datatypes/MAPIProperty.java +++ b/poi-scratchpad/src/main/java/org/apache/poi/hsmf/datatypes/MAPIProperty.java @@ -46,7 +46,7 @@ import static org.apache.poi.hsmf.datatypes.Types.TIME; */ @SuppressWarnings("unused") 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 = new MAPIProperty(0x3d06, BINARY, "AbDefaultDir", "PR_AB_DEFAULT_DIR"); diff --git a/poi/src/main/java/org/apache/poi/ss/formula/functions/LookupUtils.java b/poi/src/main/java/org/apache/poi/ss/formula/functions/LookupUtils.java index d36ae34b7a..0c260e3975 100644 --- a/poi/src/main/java/org/apache/poi/ss/formula/functions/LookupUtils.java +++ b/poi/src/main/java/org/apache/poi/ss/formula/functions/LookupUtils.java @@ -17,6 +17,7 @@ package org.apache.poi.ss.formula.functions; +import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; @@ -75,16 +76,20 @@ public final class LookupUtils { public int getIntValue() { return intValue; } } - private static Map<Integer, MatchMode> matchModeMap = new HashMap<>(); - private static Map<Integer, SearchMode> searchModeMap = new HashMap<>(); + private static final Map<Integer, MatchMode> matchModeMap; + private static final Map<Integer, SearchMode> searchModeMap; static { + final Map<Integer, MatchMode> mmMap = new HashMap<>(); 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()) { - searchModeMap.put(mode.getIntValue(), mode); + smMap.put(mode.getIntValue(), mode); } + searchModeMap = Collections.unmodifiableMap(smMap); } public static MatchMode matchMode(int m) { @@ -588,7 +593,7 @@ public final class LookupUtils { if (valEval instanceof StringEval) { String stringValue = ((StringEval) valEval).getStringValue(); - if(stringValue.length() < 1) { + if(stringValue.isEmpty()) { // More trickiness: // Empty string is not the same as BlankEval. It causes #VALUE! error throw EvaluationException.invalidValue(); diff --git a/poi/src/main/java/org/apache/poi/ss/usermodel/ConditionType.java b/poi/src/main/java/org/apache/poi/ss/usermodel/ConditionType.java index a5681cd4b9..111cc93f1a 100644 --- a/poi/src/main/java/org/apache/poi/ss/usermodel/ConditionType.java +++ b/poi/src/main/java/org/apache/poi/ss/usermodel/ConditionType.java @@ -26,7 +26,7 @@ import java.util.Map; * Represents a type of a conditional formatting rule */ 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 |