package org.apache.poi.xdgf.usermodel.section;
+import java.util.Collections;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
return l.constructor.apply(row);
}
- private static final Map<String, GeometryRowTypes> LOOKUP =
- Stream.of(values()).collect(Collectors.toMap(GeometryRowTypes::getRowType, Function.identity()));
+ private static final Map<String, GeometryRowTypes> LOOKUP = Collections.unmodifiableMap(
+ Stream.of(values()).collect(Collectors.toMap(GeometryRowTypes::getRowType, Function.identity())));
}
package org.apache.poi.xdgf.usermodel.section;
+import java.util.Collections;
import java.util.Map;
import java.util.function.BiFunction;
import java.util.function.Function;
return l.constructor.apply(section, containingSheet);
}
- private static final Map<String, XDGFSectionTypes> LOOKUP =
- Stream.of(values()).collect(Collectors.toMap(XDGFSectionTypes::getSectionType, Function.identity()));
+ private static final Map<String, XDGFSectionTypes> LOOKUP = Collections.unmodifiableMap(
+ Stream.of(values()).collect(Collectors.toMap(XDGFSectionTypes::getSectionType, Function.identity())));
}
package org.apache.poi.hslf.record;
+import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
private static final Map<Short,RecordTypes> LOOKUP;
static {
- LOOKUP = new HashMap<>();
+ final Map<Short,RecordTypes> map = new HashMap<>();
for(RecordTypes s : values()) {
- LOOKUP.put(s.typeID, s);
+ map.put(s.typeID, s);
}
+ LOOKUP = Collections.unmodifiableMap(map);
}
public final short typeID;
import java.time.format.DateTimeFormatterBuilder;
import java.time.format.FormatStyle;
import java.util.AbstractMap;
+import java.util.Collections;
import java.util.Locale;
import java.util.Map;
import java.util.function.Function;
private final LocaleID lcid;
private final Object[] mapping;
- private static final Map<LocaleID,MapFormatPPT> LCID_LOOKUP =
- Stream.of(values()).collect(Collectors.toMap(MapFormatPPT::getLocaleID, Function.identity()));
+ private static final Map<LocaleID,MapFormatPPT> LCID_LOOKUP = Collections.unmodifiableMap(
+ Stream.of(values()).collect(Collectors.toMap(MapFormatPPT::getLocaleID, Function.identity())));
MapFormatPPT(LocaleID lcid, Object... mapping) {
this.lcid = lcid;
private final LocaleID[] lcid;
private final Object[] mapping;
- private static final Map<LocaleID, MapFormatException> LCID_LOOKUP =
+ private static final Map<LocaleID, MapFormatException> LCID_LOOKUP = Collections.unmodifiableMap(
Stream.of(values()).flatMap(m -> Stream.of(m.lcid).map(l -> new AbstractMap.SimpleEntry<>(l, m)))
- .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
+ .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)));
MapFormatException(LocaleID[] lcid, Object... mapping) {
this.lcid = lcid;
package org.apache.poi.ddf;
+import java.util.Collections;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
return propNumber;
}
- private static final Map<Short, EscherPropertyTypes> LOOKUP =
- Stream.of(values()).collect(Collectors.toMap(EscherPropertyTypes::getPropertyId, Function.identity()));
+ private static final Map<Short, EscherPropertyTypes> LOOKUP = Collections.unmodifiableMap(
+ Stream.of(values()).collect(Collectors.toMap(EscherPropertyTypes::getPropertyId, Function.identity())));
public static EscherPropertyTypes forPropertyID(int propertyId) {
EscherPropertyTypes rt = LOOKUP.get((short)(propertyId & 0x3FFF));
package org.apache.poi.ddf;
+import java.util.Collections;
import java.util.Map;
import java.util.function.Function;
import java.util.function.Supplier;
return typeID;
}
- private static final Map<Short, EscherRecordTypes> LOOKUP =
- Stream.of(values()).collect(Collectors.toMap(EscherRecordTypes::getTypeId, Function.identity()));
+ private static final Map<Short, EscherRecordTypes> LOOKUP = Collections.unmodifiableMap(
+ Stream.of(values()).collect(Collectors.toMap(EscherRecordTypes::getTypeId, Function.identity())));
public static EscherRecordTypes forTypeID(int typeID) {
// Section 2.2.23: 0xF02A is treated as 0xF01D
package org.apache.poi.hssf.record;
import java.util.Arrays;
+import java.util.Collections;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
T apply(RecordInputStream in);
}
- private static final Map<Short,HSSFRecordTypes> LOOKUP =
- Arrays.stream(values()).collect(Collectors.toMap(HSSFRecordTypes::getSid, Function.identity()));
+ private static final Map<Short,HSSFRecordTypes> LOOKUP = Collections.unmodifiableMap(
+ Arrays.stream(values()).collect(Collectors.toMap(HSSFRecordTypes::getSid, Function.identity())));
public final short sid;
public final Class<? extends org.apache.poi.hssf.record.Record> clazz;
package org.apache.poi.hssf.record;
import java.util.Arrays;
+import java.util.Collections;
import java.util.Map;
import java.util.function.Function;
import java.util.function.Supplier;
T apply(LittleEndianInput in, int size, int cmoOt);
}
- private static final Map<Short,SubRecordTypes> LOOKUP =
- Arrays.stream(values()).collect(Collectors.toMap(SubRecordTypes::getSid, Function.identity()));
+ private static final Map<Short,SubRecordTypes> LOOKUP = Collections.unmodifiableMap(
+ Arrays.stream(values()).collect(Collectors.toMap(SubRecordTypes::getSid, Function.identity())));
public final short sid;
public final RecordConstructor<?> recordConstructor;
==================================================================== */
package org.apache.poi.ss.usermodel;
+import java.util.Collections;
import java.util.Map;
import org.apache.poi.util.Internal;
return repr;
}
- private static final Map<String, FormulaError> smap = new HashMap<>();
- private static final Map<Byte, FormulaError> bmap = new HashMap<>();
- private static final Map<Integer, FormulaError> imap = new HashMap<>();
- static{
+ private static final Map<String, FormulaError> smap;
+ private static final Map<Byte, FormulaError> bmap;
+ private static final Map<Integer, FormulaError> imap;
+ static {
+ final Map<String, FormulaError> mapS = new HashMap<>();
+ final Map<Byte, FormulaError> mapB = new HashMap<>();
+ final Map<Integer, FormulaError> mapI = new HashMap<>();
for (FormulaError error : values()) {
- bmap.put(error.getCode(), error);
- imap.put(error.getLongCode(), error);
- smap.put(error.getString(), error);
+ mapB.put(error.getCode(), error);
+ mapI.put(error.getLongCode(), error);
+ mapS.put(error.getString(), error);
}
+ smap = Collections.unmodifiableMap(mapS);
+ bmap = Collections.unmodifiableMap(mapB);
+ imap = Collections.unmodifiableMap(mapI);
}
public static boolean isValidCode(int errorCode) {
==================================================================== */
package org.apache.poi.ss.usermodel;
+import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
private static final Map<Short, PageMargin> PAGE_MARGIN_BY_LEGACY_API_VALUE;
static {
- PAGE_MARGIN_BY_LEGACY_API_VALUE = new HashMap<>();
-
+ final Map<Short, PageMargin> map = new HashMap<>();
for (PageMargin margin : values()) {
- PAGE_MARGIN_BY_LEGACY_API_VALUE.put(margin.legacyApiValue, margin);
+ map.put(margin.legacyApiValue, margin);
}
+ PAGE_MARGIN_BY_LEGACY_API_VALUE = Collections.unmodifiableMap(map);
}
/**
public static final String QUOTE_PREFIXED = "quotePrefixed";
// FIXME Must be deleted along with string constants
- static final Map<String, CellPropertyType> namePropertyMap = new HashMap<>();
+ static final Map<String, CellPropertyType> namePropertyMap;
static {
- namePropertyMap.put(ALIGNMENT, CellPropertyType.ALIGNMENT);
- namePropertyMap.put(BORDER_BOTTOM, CellPropertyType.BORDER_BOTTOM);
- namePropertyMap.put(BORDER_LEFT, CellPropertyType.BORDER_LEFT);
- namePropertyMap.put(BORDER_RIGHT, CellPropertyType.BORDER_RIGHT);
- namePropertyMap.put(BORDER_TOP, CellPropertyType.BORDER_TOP);
- namePropertyMap.put(BOTTOM_BORDER_COLOR, CellPropertyType.BOTTOM_BORDER_COLOR);
- namePropertyMap.put(LEFT_BORDER_COLOR, CellPropertyType.LEFT_BORDER_COLOR);
- namePropertyMap.put(RIGHT_BORDER_COLOR, CellPropertyType.RIGHT_BORDER_COLOR);
- namePropertyMap.put(TOP_BORDER_COLOR, CellPropertyType.TOP_BORDER_COLOR);
- namePropertyMap.put(FILL_BACKGROUND_COLOR, CellPropertyType.FILL_BACKGROUND_COLOR);
- namePropertyMap.put(FILL_FOREGROUND_COLOR, CellPropertyType.FILL_FOREGROUND_COLOR);
- namePropertyMap.put(FILL_BACKGROUND_COLOR_COLOR, CellPropertyType.FILL_BACKGROUND_COLOR_COLOR);
- namePropertyMap.put(FILL_FOREGROUND_COLOR_COLOR, CellPropertyType.FILL_FOREGROUND_COLOR_COLOR);
- namePropertyMap.put(FILL_PATTERN, CellPropertyType.FILL_PATTERN);
- namePropertyMap.put(FONT, CellPropertyType.FONT);
- namePropertyMap.put(HIDDEN, CellPropertyType.HIDDEN);
- namePropertyMap.put(INDENTION, CellPropertyType.INDENTION);
- namePropertyMap.put(LOCKED, CellPropertyType.LOCKED);
- namePropertyMap.put(ROTATION, CellPropertyType.ROTATION);
- namePropertyMap.put(VERTICAL_ALIGNMENT, CellPropertyType.VERTICAL_ALIGNMENT);
- namePropertyMap.put(SHRINK_TO_FIT, CellPropertyType.SHRINK_TO_FIT);
- namePropertyMap.put(QUOTE_PREFIXED, CellPropertyType.QUOTE_PREFIXED);
+ final Map<String, CellPropertyType> map = new HashMap<>();
+ map.put(ALIGNMENT, CellPropertyType.ALIGNMENT);
+ map.put(BORDER_BOTTOM, CellPropertyType.BORDER_BOTTOM);
+ map.put(BORDER_LEFT, CellPropertyType.BORDER_LEFT);
+ map.put(BORDER_RIGHT, CellPropertyType.BORDER_RIGHT);
+ map.put(BORDER_TOP, CellPropertyType.BORDER_TOP);
+ map.put(BOTTOM_BORDER_COLOR, CellPropertyType.BOTTOM_BORDER_COLOR);
+ map.put(LEFT_BORDER_COLOR, CellPropertyType.LEFT_BORDER_COLOR);
+ map.put(RIGHT_BORDER_COLOR, CellPropertyType.RIGHT_BORDER_COLOR);
+ map.put(TOP_BORDER_COLOR, CellPropertyType.TOP_BORDER_COLOR);
+ map.put(FILL_BACKGROUND_COLOR, CellPropertyType.FILL_BACKGROUND_COLOR);
+ map.put(FILL_FOREGROUND_COLOR, CellPropertyType.FILL_FOREGROUND_COLOR);
+ map.put(FILL_BACKGROUND_COLOR_COLOR, CellPropertyType.FILL_BACKGROUND_COLOR_COLOR);
+ map.put(FILL_FOREGROUND_COLOR_COLOR, CellPropertyType.FILL_FOREGROUND_COLOR_COLOR);
+ map.put(FILL_PATTERN, CellPropertyType.FILL_PATTERN);
+ map.put(FONT, CellPropertyType.FONT);
+ map.put(HIDDEN, CellPropertyType.HIDDEN);
+ map.put(INDENTION, CellPropertyType.INDENTION);
+ map.put(LOCKED, CellPropertyType.LOCKED);
+ map.put(ROTATION, CellPropertyType.ROTATION);
+ map.put(VERTICAL_ALIGNMENT, CellPropertyType.VERTICAL_ALIGNMENT);
+ map.put(SHRINK_TO_FIT, CellPropertyType.SHRINK_TO_FIT);
+ map.put(QUOTE_PREFIXED, CellPropertyType.QUOTE_PREFIXED);
+ namePropertyMap = Collections.unmodifiableMap(map);
}
private static final UnicodeMapping[] unicodeMappings;
import static java.util.Calendar.SUNDAY;
import java.util.Calendar;
+import java.util.Collections;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
private final int defaultCodepage;
private final int firstWeekday;
- private static final Map<String, LocaleID> languageTagLookup =
- Stream.of(values()).filter(LocaleID::isValid).collect(Collectors.toMap(LocaleID::getLanguageTag, Function.identity()));
+ private static final Map<String, LocaleID> languageTagLookup = Collections.unmodifiableMap(
+ Stream.of(values()).filter(LocaleID::isValid)
+ .collect(Collectors.toMap(LocaleID::getLanguageTag, Function.identity())));
- private static final Map<Integer, LocaleID> lcidLookup =
- Stream.of(values()).collect(Collectors.toMap(LocaleID::getLcid, Function.identity()));
+ private static final Map<Integer, LocaleID> lcidLookup = Collections.unmodifiableMap(
+ Stream.of(values()).collect(Collectors.toMap(LocaleID::getLcid, Function.identity())));
LocaleID(int lcid, String windowsId, String languageTag, String description, int defaultCodepage, int firstWeekday) {
this.lcid = lcid;