This is an automated email from the ASF dual-hosted git repository.

pjfanning pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/poi.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 46b25f6063 more use of java 17 switch (#1141)
46b25f6063 is described below

commit 46b25f60630455da2a6ac5ac9d7fa903824c7889
Author: PJ Fanning <[email protected]>
AuthorDate: Fri Jun 12 15:49:14 2026 +0100

    more use of java 17 switch (#1141)
    
    * more use of java 17 switch
    
    * Update HemfPlusImage.java
---
 .../poi/xslf/usermodel/XSLFTextParagraph.java      | 22 ++---
 .../org/apache/poi/xssf/usermodel/XSSFCell.java    | 17 ++--
 .../apache/poi/xssf/usermodel/XSSFCellStyle.java   | 19 ++---
 .../usermodel/XSSFConditionalFormattingRule.java   | 22 ++---
 .../poi/xssf/usermodel/XSSFFontFormatting.java     | 14 +--
 .../usermodel/helpers/XSSFIgnoredErrorHelper.java  | 34 +++-----
 .../org/apache/poi/xssf/util/NumericRanges.java    | 20 ++---
 .../org/apache/poi/hdgf/chunks/ChunkHeaderV6.java  | 11 +--
 .../org/apache/poi/hdgf/pointers/PointerV5.java    | 42 ++++-----
 .../org/apache/poi/hemf/draw/HemfGraphics.java     | 11 +--
 .../record/emfplus/HemfPlusGDIImageRenderer.java   | 19 ++---
 .../poi/hemf/record/emfplus/HemfPlusImage.java     | 98 +++++++++------------
 .../poi/hemf/record/emfplus/HemfPlusPen.java       | 37 +++-----
 .../poi/hemf/usermodel/HemfEmbeddedIterator.java   | 43 +++-------
 .../org/apache/poi/hpbf/model/qcbits/QCPLCBit.java | 20 ++---
 .../java/org/apache/poi/hslf/dev/PPTXMLDump.java   | 12 +--
 .../model/textproperties/FontAlignmentProp.java    | 19 ++---
 .../model/textproperties/TextAlignmentProp.java    | 23 ++---
 .../poi/hslf/model/textproperties/TextProp.java    | 11 ++-
 .../org/apache/poi/hslf/record/Comment2000.java    |  3 +-
 .../org/apache/poi/hslf/record/ExEmbedAtom.java    | 14 ++-
 .../org/apache/poi/hslf/usermodel/HSLFFill.java    | 30 +++----
 .../apache/poi/hslf/usermodel/HSLFFontInfo.java    | 18 ++--
 .../apache/poi/hslf/usermodel/HSLFHyperlink.java   | 27 +++---
 .../apache/poi/hslf/usermodel/HSLFPictureData.java | 25 ++----
 .../poi/hslf/usermodel/HSLFPlaceholderDetails.java | 38 +++------
 .../usermodel/HSLFShapePlaceholderDetails.java     | 71 +++++-----------
 .../apache/poi/hslf/usermodel/HSLFSimpleShape.java | 24 ++----
 .../org/apache/poi/hslf/usermodel/HSLFSlide.java   | 15 ++--
 .../apache/poi/hslf/usermodel/HSLFSlideMaster.java | 18 ++--
 .../apache/poi/hslf/usermodel/HSLFTableCell.java   | 99 ++++++++++------------
 .../poi/hslf/usermodel/HSLFTextParagraph.java      | 65 +++++++-------
 .../org/apache/poi/hslf/usermodel/HSLFTextRun.java | 38 +++------
 .../org/apache/poi/hssf/model/RecordOrderer.java   | 69 ++++++---------
 .../java/org/apache/poi/hssf/record/BOFRecord.java | 18 ++--
 .../hssf/record/EmbeddedObjectRefSubRecord.java    | 14 +--
 .../org/apache/poi/hssf/usermodel/HSSFCell.java    |  8 +-
 .../org/apache/poi/ss/formula/FormulaShifter.java  | 23 ++---
 .../apache/poi/ss/formula/SheetNameFormatter.java  | 18 ++--
 .../ss/formula/constant/ConstantValueParser.java   | 15 ++--
 .../formula/function/FunctionMetadataReader.java   | 13 +--
 .../poi/ss/formula/functions/DStarRunner.java      | 23 ++---
 .../java/org/apache/poi/ss/formula/ptg/ErrPtg.java | 21 +++--
 .../java/org/apache/poi/ss/formula/ptg/Ptg.java    | 66 +++++++--------
 .../java/org/apache/poi/ss/usermodel/DateUtil.java | 20 +----
 .../java/org/apache/poi/ss/util/CellRangeUtil.java | 29 ++++---
 46 files changed, 515 insertions(+), 801 deletions(-)

diff --git 
a/poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XSLFTextParagraph.java 
b/poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XSLFTextParagraph.java
index 00308c73ea..45febd4fac 100644
--- 
a/poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XSLFTextParagraph.java
+++ 
b/poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XSLFTextParagraph.java
@@ -727,22 +727,12 @@ public class XSLFTextParagraph implements 
TextParagraph<XSLFShape,XSLFTextParagr
     @Internal
     public CTTextParagraphProperties getDefaultMasterStyle() {
         CTPlaceholder ph = 
_shape.getPlaceholderDetails().getCTPlaceholder(false);
-        String defaultStyleSelector;
-        switch(ph == null ? -1 : ph.getType().intValue()) {
-            case STPlaceholderType.INT_TITLE:
-            case STPlaceholderType.INT_CTR_TITLE:
-                defaultStyleSelector = "titleStyle";
-                break;
-            case -1: // no placeholder means plain text box
-            case STPlaceholderType.INT_FTR:
-            case STPlaceholderType.INT_SLD_NUM:
-            case STPlaceholderType.INT_DT:
-                defaultStyleSelector = "otherStyle";
-                break;
-            default:
-                defaultStyleSelector = "bodyStyle";
-                break;
-        }
+        String defaultStyleSelector = switch (ph == null ? -1 : 
ph.getType().intValue()) {
+            case STPlaceholderType.INT_TITLE, STPlaceholderType.INT_CTR_TITLE 
->
+                    "titleStyle"; // no placeholder means plain text box
+            case -1, STPlaceholderType.INT_FTR, STPlaceholderType.INT_SLD_NUM, 
STPlaceholderType.INT_DT -> "otherStyle";
+            default -> "bodyStyle";
+        };
         int level = getIndentLevel();
 
         // wind up and find the root master sheet which must be slide master
diff --git 
a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFCell.java 
b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFCell.java
index 30b5138af2..67e3dbdb08 100644
--- a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFCell.java
+++ b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFCell.java
@@ -197,17 +197,14 @@ public final class XSSFCell extends CellBase {
     @Override
     public boolean getBooleanCellValue() {
         CellType cellType = getCellType();
-        switch(cellType) {
-            case BLANK:
-                return false;
-            case BOOLEAN:
-                return _cell.isSetV() && TRUE_AS_STRING.equals(_cell.getV());
-            case FORMULA:
+        return switch (cellType) {
+            case BLANK -> false;
+            case BOOLEAN -> _cell.isSetV() && 
TRUE_AS_STRING.equals(_cell.getV());
+            case FORMULA ->
                 //YK: should throw an exception if requesting boolean value 
from a non-boolean formula
-                return _cell.isSetV() && TRUE_AS_STRING.equals(_cell.getV());
-            default:
-                throw typeMismatch(CellType.BOOLEAN, cellType, false);
-        }
+                    _cell.isSetV() && TRUE_AS_STRING.equals(_cell.getV());
+            default -> throw typeMismatch(CellType.BOOLEAN, cellType, false);
+        };
     }
 
     /**
diff --git 
a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFCellStyle.java 
b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFCellStyle.java
index 5a0ddfbbc3..095fd64096 100644
--- a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFCellStyle.java
+++ b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFCellStyle.java
@@ -1234,18 +1234,13 @@ public class XSSFCellStyle implements CellStyle, 
Duplicatable {
      * @return the used color
      */
     public XSSFColor getBorderColor(BorderSide side) {
-        switch(side){
-            case BOTTOM:
-                return getBottomBorderXSSFColor();
-            case RIGHT:
-                return getRightBorderXSSFColor();
-            case TOP:
-                return getTopBorderXSSFColor();
-            case LEFT:
-                return getLeftBorderXSSFColor();
-            default:
-                throw new IllegalArgumentException("Unknown border: " + side);
-        }
+        return switch (side) {
+            case BOTTOM -> getBottomBorderXSSFColor();
+            case RIGHT -> getRightBorderXSSFColor();
+            case TOP -> getTopBorderXSSFColor();
+            case LEFT -> getLeftBorderXSSFColor();
+            default -> throw new IllegalArgumentException("Unknown border: " + 
side);
+        };
     }
 
     /**
diff --git 
a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFConditionalFormattingRule.java
 
b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFConditionalFormattingRule.java
index 987dc81b73..e872e658a5 100644
--- 
a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFConditionalFormattingRule.java
+++ 
b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFConditionalFormattingRule.java
@@ -386,17 +386,17 @@ public class XSSFConditionalFormattingRule implements 
ConditionalFormattingRule
         STConditionalFormattingOperator.Enum op = _cfRule.getOperator();
         if(op == null) return ComparisonOperator.NO_COMPARISON;
 
-        switch(op.intValue()){
-            case STConditionalFormattingOperator.INT_LESS_THAN: return 
ComparisonOperator.LT;
-            case STConditionalFormattingOperator.INT_LESS_THAN_OR_EQUAL: 
return ComparisonOperator.LE;
-            case STConditionalFormattingOperator.INT_GREATER_THAN: return 
ComparisonOperator.GT;
-            case STConditionalFormattingOperator.INT_GREATER_THAN_OR_EQUAL: 
return ComparisonOperator.GE;
-            case STConditionalFormattingOperator.INT_EQUAL: return 
ComparisonOperator.EQUAL;
-            case STConditionalFormattingOperator.INT_NOT_EQUAL: return 
ComparisonOperator.NOT_EQUAL;
-            case STConditionalFormattingOperator.INT_BETWEEN: return 
ComparisonOperator.BETWEEN;
-            case STConditionalFormattingOperator.INT_NOT_BETWEEN: return 
ComparisonOperator.NOT_BETWEEN;
-        }
-        return ComparisonOperator.NO_COMPARISON;
+        return switch (op.intValue()) {
+            case STConditionalFormattingOperator.INT_LESS_THAN -> 
ComparisonOperator.LT;
+            case STConditionalFormattingOperator.INT_LESS_THAN_OR_EQUAL -> 
ComparisonOperator.LE;
+            case STConditionalFormattingOperator.INT_GREATER_THAN -> 
ComparisonOperator.GT;
+            case STConditionalFormattingOperator.INT_GREATER_THAN_OR_EQUAL -> 
ComparisonOperator.GE;
+            case STConditionalFormattingOperator.INT_EQUAL -> 
ComparisonOperator.EQUAL;
+            case STConditionalFormattingOperator.INT_NOT_EQUAL -> 
ComparisonOperator.NOT_EQUAL;
+            case STConditionalFormattingOperator.INT_BETWEEN -> 
ComparisonOperator.BETWEEN;
+            case STConditionalFormattingOperator.INT_NOT_BETWEEN -> 
ComparisonOperator.NOT_BETWEEN;
+            default -> ComparisonOperator.NO_COMPARISON;
+        };
     }
 
     /**
diff --git 
a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFFontFormatting.java 
b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFFontFormatting.java
index 03977aea6f..cd1b53d1d6 100644
--- 
a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFFontFormatting.java
+++ 
b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFFontFormatting.java
@@ -168,13 +168,13 @@ public class XSSFFontFormatting implements FontFormatting 
{
     public short getUnderlineType(){
         if(_font.sizeOfUArray() == 0) return Font.U_NONE;
         CTUnderlineProperty u = _font.getUArray(0);
-        switch(u.getVal().intValue()){
-            case STUnderlineValues.INT_SINGLE: return Font.U_SINGLE;
-            case STUnderlineValues.INT_DOUBLE: return Font.U_DOUBLE;
-            case STUnderlineValues.INT_SINGLE_ACCOUNTING: return 
Font.U_SINGLE_ACCOUNTING;
-            case STUnderlineValues.INT_DOUBLE_ACCOUNTING: return 
Font.U_DOUBLE_ACCOUNTING;
-            default: return Font.U_NONE;
-        }
+        return switch (u.getVal().intValue()) {
+            case STUnderlineValues.INT_SINGLE -> Font.U_SINGLE;
+            case STUnderlineValues.INT_DOUBLE -> Font.U_DOUBLE;
+            case STUnderlineValues.INT_SINGLE_ACCOUNTING -> 
Font.U_SINGLE_ACCOUNTING;
+            case STUnderlineValues.INT_DOUBLE_ACCOUNTING -> 
Font.U_DOUBLE_ACCOUNTING;
+            default -> Font.U_NONE;
+        };
     }
 
     /**
diff --git 
a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/helpers/XSSFIgnoredErrorHelper.java
 
b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/helpers/XSSFIgnoredErrorHelper.java
index 2fd4218ca6..7825983e13 100644
--- 
a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/helpers/XSSFIgnoredErrorHelper.java
+++ 
b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/helpers/XSSFIgnoredErrorHelper.java
@@ -29,28 +29,18 @@ import 
org.openxmlformats.schemas.spreadsheetml.x2006.main.CTIgnoredError;
  */
 public class XSSFIgnoredErrorHelper {
     public static boolean isSet(IgnoredErrorType errorType, CTIgnoredError 
error) {
-        switch(errorType) {
-            case CALCULATED_COLUMN:
-                return error.isSetCalculatedColumn();
-            case EMPTY_CELL_REFERENCE:
-                return error.isSetEmptyCellReference();
-            case EVALUATION_ERROR:
-                return error.isSetEvalError();
-            case FORMULA:
-                return error.isSetFormula();
-            case FORMULA_RANGE:
-                return error.isSetFormulaRange();
-            case LIST_DATA_VALIDATION:
-                return error.isSetListDataValidation();
-            case NUMBER_STORED_AS_TEXT:
-                return error.isSetNumberStoredAsText();
-            case TWO_DIGIT_TEXT_YEAR:
-                return error.isSetTwoDigitTextYear();
-            case UNLOCKED_FORMULA:
-                return error.isSetUnlockedFormula();
-            default:
-                throw new IllegalStateException();
-            }
+        return switch (errorType) {
+            case CALCULATED_COLUMN -> error.isSetCalculatedColumn();
+            case EMPTY_CELL_REFERENCE -> error.isSetEmptyCellReference();
+            case EVALUATION_ERROR -> error.isSetEvalError();
+            case FORMULA -> error.isSetFormula();
+            case FORMULA_RANGE -> error.isSetFormulaRange();
+            case LIST_DATA_VALIDATION -> error.isSetListDataValidation();
+            case NUMBER_STORED_AS_TEXT -> error.isSetNumberStoredAsText();
+            case TWO_DIGIT_TEXT_YEAR -> error.isSetTwoDigitTextYear();
+            case UNLOCKED_FORMULA -> error.isSetUnlockedFormula();
+            default -> throw new IllegalStateException();
+        };
     }
     
     public static void set(IgnoredErrorType errorType, CTIgnoredError error) {
diff --git 
a/poi-ooxml/src/main/java/org/apache/poi/xssf/util/NumericRanges.java 
b/poi-ooxml/src/main/java/org/apache/poi/xssf/util/NumericRanges.java
index 0a853cc7c8..2a5cd0a3af 100644
--- a/poi-ooxml/src/main/java/org/apache/poi/xssf/util/NumericRanges.java
+++ b/poi-ooxml/src/main/java/org/apache/poi/xssf/util/NumericRanges.java
@@ -26,19 +26,13 @@ public class NumericRanges {
     public static final int OVERLAPS_2_WRAPS = 3;
     
     public static long[] getOverlappingRange(long[] range1, long[] range2) {
-        switch(getOverlappingType(range1, range2)) {
-            case OVERLAPS_1_MINOR:
-                return new long[]{range2[0], range1[1]};
-            case OVERLAPS_2_MINOR:
-                return new long[]{range1[0], range2[1]};
-            case OVERLAPS_2_WRAPS:
-                return range1;
-            case OVERLAPS_1_WRAPS:
-                return range2;
-            default:
-            case NO_OVERLAPS:
-                return new long[]{-1, -1};
-        }
+        return switch (getOverlappingType(range1, range2)) {
+            case OVERLAPS_1_MINOR -> new long[]{range2[0], range1[1]};
+            case OVERLAPS_2_MINOR -> new long[]{range1[0], range2[1]};
+            case OVERLAPS_2_WRAPS -> range1;
+            case OVERLAPS_1_WRAPS -> range2;
+            default -> new long[]{-1, -1};
+        };
     }
     
     public static int getOverlappingType(long[] range1, long[] range2) {
diff --git 
a/poi-scratchpad/src/main/java/org/apache/poi/hdgf/chunks/ChunkHeaderV6.java 
b/poi-scratchpad/src/main/java/org/apache/poi/hdgf/chunks/ChunkHeaderV6.java
index 9029b47880..d17bb131bf 100644
--- a/poi-scratchpad/src/main/java/org/apache/poi/hdgf/chunks/ChunkHeaderV6.java
+++ b/poi-scratchpad/src/main/java/org/apache/poi/hdgf/chunks/ChunkHeaderV6.java
@@ -46,13 +46,10 @@ public class ChunkHeaderV6 extends ChunkHeader {
      * Does the chunk have a trailer?
      */
     public boolean hasTrailer() {
-        switch (getType()) {
-            case 0x2c: case 0x65: case 0x66: case 0x69:
-            case 0x6a: case 0x6b: case 0x70: case 0x71:
-                return true;
-            default:
-                return (getUnknown1() != 0);
-        }
+        return switch (getType()) {
+            case 0x2c, 0x65, 0x66, 0x69, 0x6a, 0x6b, 0x70, 0x71 -> true;
+            default -> (getUnknown1() != 0);
+        };
     }
 
     /**
diff --git 
a/poi-scratchpad/src/main/java/org/apache/poi/hdgf/pointers/PointerV5.java 
b/poi-scratchpad/src/main/java/org/apache/poi/hdgf/pointers/PointerV5.java
index d276b909de..e4fe73dc99 100644
--- a/poi-scratchpad/src/main/java/org/apache/poi/hdgf/pointers/PointerV5.java
+++ b/poi-scratchpad/src/main/java/org/apache/poi/hdgf/pointers/PointerV5.java
@@ -29,25 +29,19 @@ public final class PointerV5 extends Pointer {
     }
     
     public boolean destinationHasPointers() {
-        switch (getType()) {
-            case 20:
-                return true;
-            case 22:
-                return false;
-            default:
-                return isFormatBetween(0x1d, 0x1f) || isFormatBetween(0x50, 
0x60);
-        }
+        return switch (getType()) {
+            case 20 -> true;
+            case 22 -> false;
+            default -> isFormatBetween(0x1d, 0x1f) || isFormatBetween(0x50, 
0x60);
+        };
     }
  
     public boolean destinationHasChunks() {
-        switch (getType()) {
-            case 21:
-                return true;
-            case 24:
-                return true;
-            default:
-                return isFormatBetween(0xd0, 0xdf);
-        }
+        return switch (getType()) {
+            case 21 -> true;
+            case 24 -> true;
+            default -> isFormatBetween(0xd0, 0xdf);
+        };
     }
 
     public boolean destinationCompressed() {
@@ -64,16 +58,12 @@ public final class PointerV5 extends Pointer {
      * Depends on the type only, not stored
      */
     public int getNumPointersOffset(byte[] data) {
-        switch (getType()) {
-            case 0x1d:
-            case 0x4e:
-                return 30;
-            case 0x1e:
-                return 54;
-            case 0x14:
-                return 130;
-        }
-        return 10;
+        return switch (getType()) {
+            case 0x1d, 0x4e -> 30;
+            case 0x1e -> 54;
+            case 0x14 -> 130;
+            default -> 10;
+        };
     }
     /**
      * 16 bit int at the given offset
diff --git 
a/poi-scratchpad/src/main/java/org/apache/poi/hemf/draw/HemfGraphics.java 
b/poi-scratchpad/src/main/java/org/apache/poi/hemf/draw/HemfGraphics.java
index 113f8ede25..c6374855f8 100644
--- a/poi-scratchpad/src/main/java/org/apache/poi/hemf/draw/HemfGraphics.java
+++ b/poi-scratchpad/src/main/java/org/apache/poi/hemf/draw/HemfGraphics.java
@@ -101,11 +101,6 @@ public class HemfGraphics extends HwmfGraphics {
 
     public void draw(HemfRecord r) {
         switch (getRenderState()) {
-            default:
-            case EMF_DCONTEXT:
-            case INITIAL:
-                r.draw(this);
-                break;
             case EMF_ONLY:
                 if (!(r instanceof EmfComment)) {
                     r.draw(this);
@@ -116,6 +111,12 @@ public class HemfGraphics extends HwmfGraphics {
                     r.draw(this);
                 }
                 break;
+            default:
+            case EMF_DCONTEXT:
+            case INITIAL:
+                r.draw(this);
+                break;
+
         }
     }
 
diff --git 
a/poi-scratchpad/src/main/java/org/apache/poi/hemf/record/emfplus/HemfPlusGDIImageRenderer.java
 
b/poi-scratchpad/src/main/java/org/apache/poi/hemf/record/emfplus/HemfPlusGDIImageRenderer.java
index dfa4685fe1..6c88fdd808 100644
--- 
a/poi-scratchpad/src/main/java/org/apache/poi/hemf/record/emfplus/HemfPlusGDIImageRenderer.java
+++ 
b/poi-scratchpad/src/main/java/org/apache/poi/hemf/record/emfplus/HemfPlusGDIImageRenderer.java
@@ -93,18 +93,17 @@ public class HemfPlusGDIImageRenderer extends 
BitmapImageRenderer {
      */
     public BufferedImage readGDIImage(final byte[] data) {
         int[] nBits, bOffs;
-        switch (pixelFormat) {
-            case ARGB_32BPP:
+        bOffs = switch (pixelFormat) {
+            case ARGB_32BPP -> {
                 nBits = new int[]{8, 8, 8, 8};
-                bOffs = new int[]{2, 1, 0, 3};
-                break;
-            case RGB_24BPP:
+                yield new int[]{2, 1, 0, 3};
+            }
+            case RGB_24BPP -> {
                 nBits = new int[]{8, 8, 8};
-                bOffs = new int[]{2, 1, 0};
-                break;
-            default:
-                throw new IllegalStateException("not yet implemented");
-        }
+                yield new int[]{2, 1, 0};
+            }
+            default -> throw new IllegalStateException("not yet implemented");
+        };
 
         ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_sRGB);
         ComponentColorModel cm = new ComponentColorModel
diff --git 
a/poi-scratchpad/src/main/java/org/apache/poi/hemf/record/emfplus/HemfPlusImage.java
 
b/poi-scratchpad/src/main/java/org/apache/poi/hemf/record/emfplus/HemfPlusImage.java
index 76436f697d..4aa21cd62a 100644
--- 
a/poi-scratchpad/src/main/java/org/apache/poi/hemf/record/emfplus/HemfPlusImage.java
+++ 
b/poi-scratchpad/src/main/java/org/apache/poi/hemf/record/emfplus/HemfPlusImage.java
@@ -33,6 +33,7 @@ import javax.imageio.ImageIO;
 
 import org.apache.commons.io.input.UnsynchronizedByteArrayInputStream;
 import org.apache.commons.io.output.UnsynchronizedByteArrayOutputStream;
+import org.apache.logging.log4j.Logger;
 import org.apache.poi.hemf.draw.HemfDrawProperties;
 import org.apache.poi.hemf.draw.HemfGraphics;
 import 
org.apache.poi.hemf.record.emfplus.HemfPlusHeader.EmfPlusGraphicsVersion;
@@ -40,6 +41,7 @@ import 
org.apache.poi.hemf.record.emfplus.HemfPlusObject.EmfPlusObjectData;
 import org.apache.poi.hemf.record.emfplus.HemfPlusObject.EmfPlusObjectType;
 import org.apache.poi.hemf.usermodel.HemfPicture;
 import org.apache.poi.hwmf.usermodel.HwmfPicture;
+import org.apache.poi.logging.PoiLogManager;
 import org.apache.poi.poifs.filesystem.FileMagic;
 import org.apache.poi.sl.draw.ImageRenderer;
 import org.apache.poi.sl.usermodel.PictureData.PictureType;
@@ -52,6 +54,8 @@ import org.apache.poi.util.LittleEndianConsts;
 import org.apache.poi.util.LittleEndianInputStream;
 
 public class HemfPlusImage {
+    private static final Logger LOG = 
PoiLogManager.getLogger(HemfPlusImage.class);
+
     /** The ImageDataType enumeration defines types of image data formats. */
     public enum EmfPlusImageDataType {
         /** The type of image is not known. */
@@ -270,7 +274,6 @@ public class HemfPlusImage {
         }
     }
 
-
     public static class EmfPlusImage implements EmfPlusObjectData {
         private static final int MAX_OBJECT_SIZE = 50_000_000;
         private static final String GDI_CONTENT = "GDI";
@@ -337,20 +340,8 @@ public class HemfPlusImage {
                 imageDataType = EmfPlusImageDataType.UNKNOWN;
             }
 
-            int fileSize;
+            long fileSize;
             switch (imageDataType) {
-                default:
-                case UNKNOWN:
-                case CONTINUED:
-                    bitmapWidth = -1;
-                    bitmapHeight = -1;
-                    bitmapStride = -1;
-                    bitmapType = null;
-                    pixelFormat = null;
-
-                    fileSize = (int) (dataSize);
-                    break;
-
                 case BITMAP:
                     // A 32-bit signed integer that specifies the width in 
pixels of the area occupied by the bitmap.
                     // If the image is compressed, according to the Type 
field, this value is undefined and MUST be ignored.
@@ -377,7 +368,7 @@ public class HemfPlusImage {
                             : EmfPlusPixelFormat.UNDEFINED;
                     assert (pixelFormat != null);
 
-                    fileSize = (int) (dataSize - size);
+                    fileSize = dataSize - size;
 
                     break;
 
@@ -394,8 +385,21 @@ public class HemfPlusImage {
 
                     // ignore metafileDataSize, which might ignore a 
(placeable) header in front
                     // and also use the remaining bytes, which might contain 
padding bytes ...
-                    fileSize = (int) (dataSize - size);
+                    fileSize = dataSize - size;
                     break;
+
+                case UNKNOWN:
+                case CONTINUED:
+                default:
+                    bitmapWidth = -1;
+                    bitmapHeight = -1;
+                    bitmapStride = -1;
+                    bitmapType = null;
+                    pixelFormat = null;
+
+                    fileSize = dataSize;
+                    break;
+
             }
 
             assert (fileSize <= dataSize - size);
@@ -426,23 +430,22 @@ public class HemfPlusImage {
                         }
                     case METAFILE:
                         try(UnsynchronizedByteArrayInputStream bis = 
UnsynchronizedByteArrayInputStream.builder().setByteArray(getRawData(continuedObjectData)).get())
 {
-                            switch (getMetafileType()) {
-                                case Wmf:
-                                case WmfPlaceable:
+                            return switch (getMetafileType()) {
+                                case Wmf, WmfPlaceable -> {
                                     HwmfPicture wmf = new HwmfPicture(bis);
-                                    return wmf.getBounds();
-                                case Emf:
-                                case EmfPlusDual:
-                                case EmfPlusOnly:
+                                    yield wmf.getBounds();
+                                }
+                                case Emf, EmfPlusDual, EmfPlusOnly -> {
                                     HemfPicture emf = new HemfPicture(bis);
-                                    return emf.getBounds();
-                            }
+                                    yield emf.getBounds();
+                                }
+                            };
                         }
-                        break;
                     default:
                         break;
                 }
-            } catch (Exception ignored) {
+            } catch (Exception e) {
+                LOG.info("Unable to read image bounds, returning default 
bounds of (1,1,1,1)", e);
             }
             return new Rectangle2D.Double(1,1,1,1);
         }
@@ -514,39 +517,22 @@ public class HemfPlusImage {
                         return GDI_CONTENT;
                     }
 
-                    switch (FileMagic.valueOf(data)) {
-                        case GIF:
-                            pictureType = PictureType.GIF;
-                            break;
-                        case TIFF:
-                            pictureType = PictureType.TIFF;
-                            break;
-                        case PNG:
-                            pictureType = PictureType.PNG;
-                            break;
-                        case JPEG:
-                            pictureType = PictureType.JPEG;
-                            break;
-                        case BMP:
-                            pictureType = PictureType.BMP;
-                            break;
-                    }
+                    pictureType = switch (FileMagic.valueOf(data)) {
+                        case GIF -> PictureType.GIF;
+                        case TIFF -> PictureType.TIFF;
+                        case PNG -> PictureType.PNG;
+                        case JPEG -> PictureType.JPEG;
+                        case BMP -> PictureType.BMP;
+                        default -> pictureType;
+                    };
                     break;
 
                 case METAFILE:
                     assert (getMetafileType() != null);
-                    switch (getMetafileType()) {
-                        case Wmf:
-                        case WmfPlaceable:
-                            pictureType = PictureType.WMF;
-                            break;
-
-                        case Emf:
-                        case EmfPlusDual:
-                        case EmfPlusOnly:
-                            pictureType = PictureType.EMF;
-                            break;
-                    }
+                    pictureType = switch (getMetafileType()) {
+                        case Wmf, WmfPlaceable -> PictureType.WMF;
+                        case Emf, EmfPlusDual, EmfPlusOnly -> PictureType.EMF;
+                    };
                     break;
             }
 
diff --git 
a/poi-scratchpad/src/main/java/org/apache/poi/hemf/record/emfplus/HemfPlusPen.java
 
b/poi-scratchpad/src/main/java/org/apache/poi/hemf/record/emfplus/HemfPlusPen.java
index 2f6085f391..b7274b6ccd 100644
--- 
a/poi-scratchpad/src/main/java/org/apache/poi/hemf/record/emfplus/HemfPlusPen.java
+++ 
b/poi-scratchpad/src/main/java/org/apache/poi/hemf/record/emfplus/HemfPlusPen.java
@@ -562,35 +562,18 @@ public class HemfPlusPen {
             brush.applyPen(ctx, continuedObjectData);
             prop.setPenWidth(penWidth);
 
-            HwmfLineCap cap;
+            HwmfLineCap cap = switch (startCap) {
+                case ROUND -> HwmfLineCap.ROUND;
+                case SQUARE -> HwmfLineCap.SQUARE;
+                default -> HwmfLineCap.FLAT;
+            };
             // ignore endCap for now
-            switch(startCap) {
-                default:
-                case FLAT:
-                    cap = HwmfLineCap.FLAT;
-                    break;
-                case ROUND:
-                    cap = HwmfLineCap.ROUND;
-                    break;
-                case SQUARE:
-                    cap = HwmfLineCap.SQUARE;
-                    break;
-            }
 
-            HwmfLineJoin lineJoin;
-            switch (this.lineJoin) {
-                default:
-                case BEVEL:
-                    lineJoin = HwmfLineJoin.BEVEL;
-                    break;
-                case ROUND:
-                    lineJoin = HwmfLineJoin.ROUND;
-                    break;
-                case MITER_CLIPPED:
-                case MITER:
-                    lineJoin = HwmfLineJoin.MITER;
-                    break;
-            }
+            HwmfLineJoin lineJoin = switch (this.lineJoin) {
+                case ROUND -> HwmfLineJoin.ROUND;
+                case MITER_CLIPPED, MITER -> HwmfLineJoin.MITER;
+                default -> HwmfLineJoin.BEVEL;
+            };
 
             HwmfLineDash lineDash = (dashedLineData == null) ? 
HwmfLineDash.SOLID : HwmfLineDash.USERSTYLE;
 
diff --git 
a/poi-scratchpad/src/main/java/org/apache/poi/hemf/usermodel/HemfEmbeddedIterator.java
 
b/poi-scratchpad/src/main/java/org/apache/poi/hemf/usermodel/HemfEmbeddedIterator.java
index 89f8799614..03401a36af 100644
--- 
a/poi-scratchpad/src/main/java/org/apache/poi/hemf/usermodel/HemfEmbeddedIterator.java
+++ 
b/poi-scratchpad/src/main/java/org/apache/poi/hemf/usermodel/HemfEmbeddedIterator.java
@@ -239,23 +239,13 @@ public class HemfEmbeddedIterator implements 
Iterator<HwmfEmbedded> {
         switch (img.getImageDataType()) {
             case BITMAP:
                 if (img.getBitmapType() == EmfPlusBitmapDataType.COMPRESSED) {
-                    switch (FileMagic.valueOf(emb.getRawData())) {
-                        case JPEG:
-                            et = HwmfEmbeddedType.JPEG;
-                            break;
-                        case GIF:
-                            et = HwmfEmbeddedType.GIF;
-                            break;
-                        case PNG:
-                            et = HwmfEmbeddedType.PNG;
-                            break;
-                        case TIFF:
-                            et = HwmfEmbeddedType.TIFF;
-                            break;
-                        default:
-                            et = HwmfEmbeddedType.BITMAP;
-                            break;
-                    }
+                    et = switch (FileMagic.valueOf(emb.getRawData())) {
+                        case JPEG -> HwmfEmbeddedType.JPEG;
+                        case GIF -> HwmfEmbeddedType.GIF;
+                        case PNG -> HwmfEmbeddedType.PNG;
+                        case TIFF -> HwmfEmbeddedType.TIFF;
+                        default -> HwmfEmbeddedType.BITMAP;
+                    };
                 } else {
                     et = HwmfEmbeddedType.PNG;
                     compressGDIBitmap(img, emb, et);
@@ -263,20 +253,11 @@ public class HemfEmbeddedIterator implements 
Iterator<HwmfEmbedded> {
                 break;
             case METAFILE:
                 assert(img.getMetafileType() != null);
-                switch (img.getMetafileType()) {
-                    case Wmf:
-                    case WmfPlaceable:
-                        et = HwmfEmbeddedType.WMF;
-                        break;
-                    case Emf:
-                    case EmfPlusDual:
-                    case EmfPlusOnly:
-                        et = HwmfEmbeddedType.EMF;
-                        break;
-                    default:
-                        et = HwmfEmbeddedType.UNKNOWN;
-                        break;
-                }
+                et = switch (img.getMetafileType()) {
+                    case Wmf, WmfPlaceable -> HwmfEmbeddedType.WMF;
+                    case Emf, EmfPlusDual, EmfPlusOnly -> HwmfEmbeddedType.EMF;
+                    default -> HwmfEmbeddedType.UNKNOWN;
+                };
                 break;
             default:
                 et = HwmfEmbeddedType.UNKNOWN;
diff --git 
a/poi-scratchpad/src/main/java/org/apache/poi/hpbf/model/qcbits/QCPLCBit.java 
b/poi-scratchpad/src/main/java/org/apache/poi/hpbf/model/qcbits/QCPLCBit.java
index 5d448575a6..d15413e65b 100644
--- 
a/poi-scratchpad/src/main/java/org/apache/poi/hpbf/model/qcbits/QCPLCBit.java
+++ 
b/poi-scratchpad/src/main/java/org/apache/poi/hpbf/model/qcbits/QCPLCBit.java
@@ -98,18 +98,14 @@ public abstract class QCPLCBit extends QCBit {
     public static QCPLCBit createQCPLCBit(String thingType, String bitType, 
byte[] data) {
         // Grab the type
         int type = (int)LittleEndian.getUInt(data, 4);
-        switch(type) {
-            case 0:
-                return new Type0(thingType, bitType, data);
-            case 4:
-                return new Type4(thingType, bitType, data);
-            case 8:
-                return new Type8(thingType, bitType, data);
-            case 12: // 0xc
-                return new Type12(thingType, bitType, data);
-            default:
-                throw new IllegalArgumentException("Sorry, I don't know how to 
deal with PLCs of type " + type);
-        }
+        return switch (type) {
+            case 0 -> new Type0(thingType, bitType, data);
+            case 4 -> new Type4(thingType, bitType, data);
+            case 8 -> new Type8(thingType, bitType, data);
+            case 12 -> // 0xc
+                    new Type12(thingType, bitType, data);
+            default -> throw new IllegalArgumentException("Sorry, I don't know 
how to deal with PLCs of type " + type);
+        };
     }
 
 
diff --git 
a/poi-scratchpad/src/main/java/org/apache/poi/hslf/dev/PPTXMLDump.java 
b/poi-scratchpad/src/main/java/org/apache/poi/hslf/dev/PPTXMLDump.java
index 784a815b70..d02506202a 100644
--- a/poi-scratchpad/src/main/java/org/apache/poi/hslf/dev/PPTXMLDump.java
+++ b/poi-scratchpad/src/main/java/org/apache/poi/hslf/dev/PPTXMLDump.java
@@ -241,12 +241,12 @@ public final class PPTXMLDump {
         String type;
         int meta = LittleEndian.getUShort(header, 0);
 
-        switch(meta){
-            case 0x46A0: type = "jpeg"; break;
-            case 0x2160: type = "wmf"; break;
-            case 0x6E00: type = "png"; break;
-            default: type = "unknown"; break;
-        }
+        type = switch (meta) {
+            case 0x46A0 -> "jpeg";
+            case 0x2160 -> "wmf";
+            case 0x6E00 -> "png";
+            default -> "unknown";
+        };
         return type;
     }
 
diff --git 
a/poi-scratchpad/src/main/java/org/apache/poi/hslf/model/textproperties/FontAlignmentProp.java
 
b/poi-scratchpad/src/main/java/org/apache/poi/hslf/model/textproperties/FontAlignmentProp.java
index e6cfea21be..4c3e76bd68 100644
--- 
a/poi-scratchpad/src/main/java/org/apache/poi/hslf/model/textproperties/FontAlignmentProp.java
+++ 
b/poi-scratchpad/src/main/java/org/apache/poi/hslf/model/textproperties/FontAlignmentProp.java
@@ -42,18 +42,13 @@ public class FontAlignmentProp extends TextProp {
     }
 
     public FontAlign getFontAlign() {
-        switch (getValue()) {
-            default:
-                return FontAlign.AUTO;
-            case BASELINE:
-                return FontAlign.BASELINE;
-            case TOP:
-                return FontAlign.TOP;
-            case CENTER:
-                return FontAlign.CENTER;
-            case BOTTOM:
-                return FontAlign.BOTTOM;
-        }
+        return switch (getValue()) {
+            case BASELINE -> FontAlign.BASELINE;
+            case TOP -> FontAlign.TOP;
+            case CENTER -> FontAlign.CENTER;
+            case BOTTOM -> FontAlign.BOTTOM;
+            default -> FontAlign.AUTO;
+        };
     }
 
     @Override
diff --git 
a/poi-scratchpad/src/main/java/org/apache/poi/hslf/model/textproperties/TextAlignmentProp.java
 
b/poi-scratchpad/src/main/java/org/apache/poi/hslf/model/textproperties/TextAlignmentProp.java
index 18b4f8894d..9edf12071b 100644
--- 
a/poi-scratchpad/src/main/java/org/apache/poi/hslf/model/textproperties/TextAlignmentProp.java
+++ 
b/poi-scratchpad/src/main/java/org/apache/poi/hslf/model/textproperties/TextAlignmentProp.java
@@ -76,21 +76,14 @@ public class TextAlignmentProp extends TextProp {
     }
 
     public TextAlign getTextAlign() {
-        switch (getValue()) {
-            default:
-            case LEFT:
-                return TextAlign.LEFT;
-            case CENTER:
-                return TextAlign.CENTER;
-            case RIGHT:
-                return TextAlign.RIGHT;
-            case JUSTIFY:
-                return TextAlign.JUSTIFY;
-            case DISTRIBUTED:
-                return TextAlign.DIST;
-            case THAIDISTRIBUTED:
-                return TextAlign.THAI_DIST;
-        }
+        return switch (getValue()) {
+            case CENTER -> TextAlign.CENTER;
+            case RIGHT -> TextAlign.RIGHT;
+            case JUSTIFY -> TextAlign.JUSTIFY;
+            case DISTRIBUTED -> TextAlign.DIST;
+            case THAIDISTRIBUTED -> TextAlign.THAI_DIST;
+            default -> TextAlign.LEFT;
+        };
     }
 
     @Override
diff --git 
a/poi-scratchpad/src/main/java/org/apache/poi/hslf/model/textproperties/TextProp.java
 
b/poi-scratchpad/src/main/java/org/apache/poi/hslf/model/textproperties/TextProp.java
index eb61970be1..1335b802ed 100644
--- 
a/poi-scratchpad/src/main/java/org/apache/poi/hslf/model/textproperties/TextProp.java
+++ 
b/poi-scratchpad/src/main/java/org/apache/poi/hslf/model/textproperties/TextProp.java
@@ -143,12 +143,11 @@ public class TextProp implements Duplicatable, 
GenericRecord {
 
     @Override
     public String toString() {
-        int len;
-        switch (getSize()) {
-        case 1: len = 4; break;
-        case 2: len = 6; break;
-        default: len = 10; break;
-        }
+        int len = switch (getSize()) {
+            case 1 -> 4;
+            case 2 -> 6;
+            default -> 10;
+        };
         return String.format(Locale.ROOT, "%s = %d (%0#"+len+"X mask / %d 
bytes)", getName(), getValue(), getMask(), getSize());
     }
 
diff --git 
a/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/Comment2000.java 
b/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/Comment2000.java
index 5a54cbfb53..9cc2d6d4dc 100644
--- a/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/Comment2000.java
+++ b/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/Comment2000.java
@@ -117,8 +117,7 @@ public final class Comment2000 extends RecordContainer {
     private void findInterestingChildren() {
 
         for(org.apache.poi.hslf.record.Record r : _children){
-            if (r instanceof CString){
-                CString cs = (CString)r;
+            if (r instanceof CString cs) {
                 int recInstance = cs.getOptions() >> 4;
                 switch(recInstance){
                     case 0: authorRecord = cs; break;
diff --git 
a/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/ExEmbedAtom.java 
b/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/ExEmbedAtom.java
index c0d4362bf7..828330c69a 100644
--- a/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/ExEmbedAtom.java
+++ b/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/ExEmbedAtom.java
@@ -175,14 +175,10 @@ public class ExEmbedAtom extends RecordAtom {
     }
 
     private String getFollowColorSchemeString() {
-        switch (getFollowColorScheme()) {
-            default:
-            case DOES_NOT_FOLLOW_COLOR_SCHEME:
-                return "DOES_NOT_FOLLOW_COLOR_SCHEME";
-            case FOLLOWS_ENTIRE_COLOR_SCHEME:
-                return "FOLLOWS_ENTIRE_COLOR_SCHEME";
-            case FOLLOWS_TEXT_AND_BACKGROUND_SCHEME:
-                return "FOLLOWS_TEXT_AND_BACKGROUND_SCHEME";
-        }
+        return switch (getFollowColorScheme()) {
+            case FOLLOWS_ENTIRE_COLOR_SCHEME -> "FOLLOWS_ENTIRE_COLOR_SCHEME";
+            case FOLLOWS_TEXT_AND_BACKGROUND_SCHEME -> 
"FOLLOWS_TEXT_AND_BACKGROUND_SCHEME";
+            default -> "DOES_NOT_FOLLOW_COLOR_SCHEME";
+        };
     }
 }
diff --git 
a/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFFill.java 
b/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFFill.java
index ab0061ab57..5c93202d20 100644
--- a/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFFill.java
+++ b/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFFill.java
@@ -259,26 +259,18 @@ public final class HSLFFill {
         // TODO: fix gradient types, this mismatches with the MS-ODRAW 
definition ...
         // need to handle (not only) the type (radial,rectangular,linear),
         // the direction, e.g. top right, and bounds (e.g. for rectangular 
boxes)
-        switch (fillType) {
-            case FILL_BACKGROUND:
-                return DrawPaint.createSolidPaint(getBackgroundColor());
-            case FILL_SOLID:
-                return DrawPaint.createSolidPaint(getForegroundColor());
-            case FILL_SHADE_SHAPE:
-                return getGradientPaint(GradientType.shape);
-            case FILL_SHADE_CENTER:
-            case FILL_SHADE_TITLE:
-                return getGradientPaint(GradientType.circular);
-            case FILL_SHADE:
-            case FILL_SHADE_SCALE:
-                return getGradientPaint(GradientType.linear);
-            case FILL_TEXTURE:
-            case FILL_PICTURE:
-                return getTexturePaint();
-            default:
+        return switch (fillType) {
+            case FILL_BACKGROUND -> 
DrawPaint.createSolidPaint(getBackgroundColor());
+            case FILL_SOLID -> 
DrawPaint.createSolidPaint(getForegroundColor());
+            case FILL_SHADE_SHAPE -> getGradientPaint(GradientType.shape);
+            case FILL_SHADE_CENTER, FILL_SHADE_TITLE -> 
getGradientPaint(GradientType.circular);
+            case FILL_SHADE, FILL_SHADE_SCALE -> 
getGradientPaint(GradientType.linear);
+            case FILL_TEXTURE, FILL_PICTURE -> getTexturePaint();
+            default -> {
                 LOG.atWarn().log("unsupported fill type: {}", box(fillType));
-                return null;
-        }
+                yield null;
+            }
+        };
     }
 
     private boolean isRotatedWithShape() {
diff --git 
a/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFFontInfo.java 
b/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFFontInfo.java
index 9988f9ae5d..ceb064062c 100644
--- 
a/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFFontInfo.java
+++ 
b/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFFontInfo.java
@@ -206,19 +206,11 @@ public class HSLFFontInfo implements FontInfo {
         fnt.setCharSet(getCharset().getNativeId());
         fnt.setFontFlags((byte)(isEmbedSubsetted() ? 1 : 0));
 
-        int typeFlag;
-        switch (renderType) {
-        case device:
-            typeFlag = FLAGS_RENDER_FONTTYPE.setValue(0, 1);
-            break;
-        case raster:
-            typeFlag = FLAGS_RENDER_FONTTYPE.setValue(0, 2);
-            break;
-        default:
-        case truetype:
-            typeFlag = FLAGS_RENDER_FONTTYPE.setValue(0, 4);
-            break;
-        }
+        int typeFlag = switch (renderType) {
+            case device -> FLAGS_RENDER_FONTTYPE.setValue(0, 1);
+            case raster -> FLAGS_RENDER_FONTTYPE.setValue(0, 2);
+            default -> FLAGS_RENDER_FONTTYPE.setValue(0, 4);
+        };
         typeFlag = FLAGS_NO_FONT_SUBSTITUTION.setBoolean(typeFlag, 
isFontSubstitutable());
         fnt.setFontType(typeFlag);
         
diff --git 
a/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFHyperlink.java 
b/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFHyperlink.java
index be27af04fe..2268ccde8e 100644
--- 
a/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFHyperlink.java
+++ 
b/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFHyperlink.java
@@ -131,23 +131,16 @@ public final class HSLFHyperlink implements 
Hyperlink<HSLFShape,HSLFTextParagrap
      */
     @Override
     public HyperlinkType getType() {
-        switch (info.getInteractiveInfoAtom().getHyperlinkType()) {
-            case InteractiveInfoAtom.LINK_Url:
-                return (exHyper.getLinkURL().startsWith("mailto:";)) ? 
HyperlinkType.EMAIL : HyperlinkType.URL;
-            case InteractiveInfoAtom.LINK_NextSlide:
-            case InteractiveInfoAtom.LINK_PreviousSlide:
-            case InteractiveInfoAtom.LINK_FirstSlide:
-            case InteractiveInfoAtom.LINK_LastSlide:
-            case InteractiveInfoAtom.LINK_SlideNumber:
-                return HyperlinkType.DOCUMENT;
-            case InteractiveInfoAtom.LINK_CustomShow:
-            case InteractiveInfoAtom.LINK_OtherPresentation:
-            case InteractiveInfoAtom.LINK_OtherFile:
-                return HyperlinkType.FILE;
-            default:
-            case InteractiveInfoAtom.LINK_NULL:
-                return HyperlinkType.NONE;
-        }
+        return switch (info.getInteractiveInfoAtom().getHyperlinkType()) {
+            case InteractiveInfoAtom.LINK_Url ->
+                    (exHyper.getLinkURL().startsWith("mailto:";)) ? 
HyperlinkType.EMAIL : HyperlinkType.URL;
+            case InteractiveInfoAtom.LINK_NextSlide, 
InteractiveInfoAtom.LINK_PreviousSlide,
+                 InteractiveInfoAtom.LINK_FirstSlide, 
InteractiveInfoAtom.LINK_LastSlide,
+                 InteractiveInfoAtom.LINK_SlideNumber -> 
HyperlinkType.DOCUMENT;
+            case InteractiveInfoAtom.LINK_CustomShow, 
InteractiveInfoAtom.LINK_OtherPresentation,
+                 InteractiveInfoAtom.LINK_OtherFile -> HyperlinkType.FILE;
+            default -> HyperlinkType.NONE;
+        };
     }
 
     @Override
diff --git 
a/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFPictureData.java
 
b/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFPictureData.java
index 2d90e69e9d..4c3810a837 100644
--- 
a/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFPictureData.java
+++ 
b/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFPictureData.java
@@ -258,22 +258,15 @@ public abstract class HSLFPictureData implements 
PictureData, GenericRecord {
             EscherContainerRecord recordContainer,
             EscherBSERecord bse
     ) {
-        switch (type) {
-            case EMF:
-                return new EMF(recordContainer, bse);
-            case WMF:
-                return new WMF(recordContainer, bse);
-            case PICT:
-                return new PICT(recordContainer, bse);
-            case JPEG:
-                return new JPEG(recordContainer, bse);
-            case PNG:
-                return new PNG(recordContainer, bse);
-            case DIB:
-                return new DIB(recordContainer, bse);
-            default:
-                throw new IllegalArgumentException("Unsupported picture type: 
" + type);
-        }
+        return switch (type) {
+            case EMF -> new EMF(recordContainer, bse);
+            case WMF -> new WMF(recordContainer, bse);
+            case PICT -> new PICT(recordContainer, bse);
+            case JPEG -> new JPEG(recordContainer, bse);
+            case PNG -> new PNG(recordContainer, bse);
+            case DIB -> new DIB(recordContainer, bse);
+            default -> throw new IllegalArgumentException("Unsupported picture 
type: " + type);
+        };
     }
 
     /**
diff --git 
a/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFPlaceholderDetails.java
 
b/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFPlaceholderDetails.java
index d7b23709d8..1460f1750f 100644
--- 
a/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFPlaceholderDetails.java
+++ 
b/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFPlaceholderDetails.java
@@ -45,19 +45,13 @@ public class HSLFPlaceholderDetails implements 
PlaceholderDetails {
 
         final HeadersFooters headersFooters = sheet.getHeadersFooters();
 
-        switch (ph) {
-            case HEADER:
-            case TITLE:
-                return headersFooters.isHeaderVisible();
-            case FOOTER:
-                return headersFooters.isFooterVisible();
-            case DATETIME:
-                return headersFooters.isDateTimeVisible();
-            case SLIDE_NUMBER:
-                return headersFooters.isSlideNumberVisible();
-            default:
-                return false;
-        }
+        return switch (ph) {
+            case HEADER, TITLE -> headersFooters.isHeaderVisible();
+            case FOOTER -> headersFooters.isFooterVisible();
+            case DATETIME -> headersFooters.isDateTimeVisible();
+            case SLIDE_NUMBER -> headersFooters.isSlideNumberVisible();
+            default -> false;
+        };
     }
 
     @Override
@@ -121,18 +115,12 @@ public class HSLFPlaceholderDetails implements 
PlaceholderDetails {
 
         final HeadersFooters headersFooters = sheet.getHeadersFooters();
 
-        switch (ph) {
-            case TITLE:
-            case HEADER:
-                return headersFooters.getHeaderText();
-            case FOOTER:
-                return headersFooters.getFooterText();
-            case DATETIME:
-                return headersFooters.getDateTimeText();
-            case SLIDE_NUMBER:
-            default:
-                return null;
-        }
+        return switch (ph) {
+            case TITLE, HEADER -> headersFooters.getHeaderText();
+            case FOOTER -> headersFooters.getFooterText();
+            case DATETIME -> headersFooters.getDateTimeText();
+            default -> null;
+        };
     }
 
     @Override
diff --git 
a/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFShapePlaceholderDetails.java
 
b/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFShapePlaceholderDetails.java
index 04dd8aefa6..476e2fc661 100644
--- 
a/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFShapePlaceholderDetails.java
+++ 
b/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFShapePlaceholderDetails.java
@@ -152,17 +152,12 @@ public class HSLFShapePlaceholderDetails extends 
HSLFPlaceholderDetails {
             return null;
         }
 
-        switch (source) {
-        case slide:
-            return Placeholder.lookupNativeSlide(phId);
-        default:
-        case master:
-            return Placeholder.lookupNativeSlideMaster(phId);
-        case notes:
-            return Placeholder.lookupNativeNotes(phId);
-        case notesMaster:
-            return Placeholder.lookupNativeNotesMaster(phId);
-        }
+        return switch (source) {
+            case slide -> Placeholder.lookupNativeSlide(phId);
+            case notes -> Placeholder.lookupNativeNotes(phId);
+            case notesMaster -> Placeholder.lookupNativeNotesMaster(phId);
+            default -> Placeholder.lookupNativeSlideMaster(phId);
+        };
     }
 
     @Override
@@ -193,15 +188,11 @@ public class HSLFShapePlaceholderDetails extends 
HSLFPlaceholderDetails {
             ? oePlaceholderAtom.getPlaceholderSize()
             : OEPlaceholderAtom.PLACEHOLDER_HALFSIZE;
 
-        switch (size) {
-        case OEPlaceholderAtom.PLACEHOLDER_FULLSIZE:
-            return PlaceholderSize.full;
-        default:
-        case OEPlaceholderAtom.PLACEHOLDER_HALFSIZE:
-            return PlaceholderSize.half;
-        case OEPlaceholderAtom.PLACEHOLDER_QUARTSIZE:
-            return PlaceholderSize.quarter;
-        }
+        return switch (size) {
+            case OEPlaceholderAtom.PLACEHOLDER_FULLSIZE -> 
PlaceholderSize.full;
+            case OEPlaceholderAtom.PLACEHOLDER_QUARTSIZE -> 
PlaceholderSize.quarter;
+            default -> PlaceholderSize.half;
+        };
     }
 
     @Override
@@ -212,19 +203,11 @@ public class HSLFShapePlaceholderDetails extends 
HSLFPlaceholderDetails {
         }
         updatePlaceholderAtom(ph, true);
 
-        final byte ph_size;
-        switch (size) {
-        case full:
-            ph_size = OEPlaceholderAtom.PLACEHOLDER_FULLSIZE;
-            break;
-        default:
-        case half:
-            ph_size = OEPlaceholderAtom.PLACEHOLDER_HALFSIZE;
-            break;
-        case quarter:
-            ph_size = OEPlaceholderAtom.PLACEHOLDER_QUARTSIZE;
-            break;
-        }
+        final byte ph_size = switch (size) {
+            case full -> OEPlaceholderAtom.PLACEHOLDER_FULLSIZE;
+            case quarter -> OEPlaceholderAtom.PLACEHOLDER_QUARTSIZE;
+            default -> OEPlaceholderAtom.PLACEHOLDER_HALFSIZE;
+        };
         oePlaceholderAtom.setPlaceholderSize(ph_size);
     }
 
@@ -236,22 +219,12 @@ public class HSLFShapePlaceholderDetails extends 
HSLFPlaceholderDetails {
          * This occurs when the user has moved the placeholder from its 
original position.
          * In this case the placeholder ID is -1.
          */
-        final byte phId;
-        switch (source) {
-            default:
-            case slide:
-                phId = (byte)placeholder.nativeSlideId;
-                break;
-            case master:
-                phId = (byte)placeholder.nativeSlideMasterId;
-                break;
-            case notes:
-                phId = (byte)placeholder.nativeNotesId;
-                break;
-            case notesMaster:
-                phId = (byte)placeholder.nativeNotesMasterId;
-                break;
-        }
+        final byte phId = switch (source) {
+            case master -> (byte) placeholder.nativeSlideMasterId;
+            case notes -> (byte) placeholder.nativeNotesId;
+            case notesMaster -> (byte) placeholder.nativeNotesMasterId;
+            default -> (byte) placeholder.nativeSlideId;
+        };
 
         if (phId == -2) {
             throw new HSLFException("Placeholder "+placeholder.name()+" not 
supported for this sheet type ("+shape.getSheet().getClass()+")");
diff --git 
a/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFSimpleShape.java
 
b/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFSimpleShape.java
index aa85a65a92..360edc97d6 100644
--- 
a/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFSimpleShape.java
+++ 
b/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFSimpleShape.java
@@ -360,23 +360,13 @@ public abstract class HSLFSimpleShape extends HSLFShape 
implements SimpleShape<H
         // see 
https://social.msdn.microsoft.com/Forums/en-US/33e458e6-58df-48fe-9a10-e303ab08991d/preset-shapes-for-ppt?forum=os_binaryfile
 
         // usually we deal with length units and only very few degree units:
-        boolean isDegreeUnit = false;
-        switch (getShapeType()) {
-            case ARC:
-            case BLOCK_ARC:
-            case CHORD:
-            case PIE:
-                isDegreeUnit = (adjInt == 1 || adjInt == 2);
-                break;
-            case CIRCULAR_ARROW:
-            case LEFT_CIRCULAR_ARROW:
-            case LEFT_RIGHT_CIRCULAR_ARROW:
-                isDegreeUnit = (adjInt == 2 || adjInt == 3 || adjInt == 4);
-                break;
-            case MATH_NOT_EQUAL:
-                isDegreeUnit = (adjInt == 2);
-                break;
-        }
+        boolean isDegreeUnit = switch (getShapeType()) {
+            case ARC, BLOCK_ARC, CHORD, PIE -> (adjInt == 1 || adjInt == 2);
+            case CIRCULAR_ARROW, LEFT_CIRCULAR_ARROW, 
LEFT_RIGHT_CIRCULAR_ARROW ->
+                    (adjInt == 2 || adjInt == 3 || adjInt == 4);
+            case MATH_NOT_EQUAL -> (adjInt == 2);
+            default -> false;
+        };
 
         Guide gd = new Guide();
         gd.setName(name);
diff --git 
a/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFSlide.java 
b/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFSlide.java
index 00ec4b2f83..072fe0c119 100644
--- a/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFSlide.java
+++ b/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFSlide.java
@@ -488,16 +488,11 @@ public final class HSLFSlide extends HSLFSheet implements 
Slide<HSLFShape,HSLFTe
         final SlideLayoutType slt = 
getSlideRecord().getSlideAtom().getSSlideLayoutAtom().getGeometryType();
         final boolean isTitle =
             (slt == SlideLayoutType.TITLE_SLIDE || slt == 
SlideLayoutType.TITLE_ONLY || slt == SlideLayoutType.MASTER_TITLE);
-        switch (placeholder) {
-            case HEADER:
-                return hf.isHeaderVisible() && hf.getHeaderAtom() != null && 
!isTitle;
-            case FOOTER:
-                return hf.isFooterVisible() && hf.getFooterAtom() != null && 
!isTitle;
-            case DATETIME:
-            case SLIDE_NUMBER:
-            default:
-                return false;
-        }
+        return switch (placeholder) {
+            case HEADER -> hf.isHeaderVisible() && hf.getHeaderAtom() != null 
&& !isTitle;
+            case FOOTER -> hf.isFooterVisible() && hf.getFooterAtom() != null 
&& !isTitle;
+            default -> false;
+        };
     }
 
     @Override
diff --git 
a/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFSlideMaster.java
 
b/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFSlideMaster.java
index b0929d3bb7..ec1525fab2 100644
--- 
a/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFSlideMaster.java
+++ 
b/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFSlideMaster.java
@@ -93,18 +93,12 @@ public final class HSLFSlideMaster extends HSLFMasterSheet {
         }
 
         TextPlaceholder tp = TextPlaceholder.fromNativeId(txtype);
-        switch (tp == null ? TextPlaceholder.BODY : tp) {
-            case BODY:
-            case CENTER_BODY:
-            case HALF_BODY:
-            case QUARTER_BODY:
-                return getPropHelper(TextPlaceholder.BODY.nativeId, level, 
name, isCharacter);
-            case TITLE:
-            case CENTER_TITLE:
-                return getPropHelper(TextPlaceholder.TITLE.nativeId, level, 
name, isCharacter);
-            default:
-                return null;
-        }
+        return switch (tp == null ? TextPlaceholder.BODY : tp) {
+            case BODY, CENTER_BODY, HALF_BODY, QUARTER_BODY ->
+                    getPropHelper(TextPlaceholder.BODY.nativeId, level, name, 
isCharacter);
+            case TITLE, CENTER_TITLE -> 
getPropHelper(TextPlaceholder.TITLE.nativeId, level, name, isCharacter);
+            default -> null;
+        };
     }
 
     private TextPropCollection getPropHelper(final int txtype, final int 
level, final String name, final boolean isCharacter) {
diff --git 
a/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFTableCell.java 
b/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFTableCell.java
index b82b143295..c527833bc9 100644
--- 
a/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFTableCell.java
+++ 
b/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFTableCell.java
@@ -192,14 +192,13 @@ public final class HSLFTableCell extends HSLFTextBox 
implements TableCell<HSLFSh
 
 
     public Double getBorderWidth(BorderEdge edge) {
-        HSLFLine l;
-        switch (edge) {
-            case bottom: l = borderBottom; break;
-            case top: l = borderTop; break;
-            case right: l = borderRight; break;
-            case left: l = borderLeft; break;
-            default: throw new IllegalArgumentException();
-        }
+        HSLFLine l = switch (edge) {
+            case bottom -> borderBottom;
+            case top -> borderTop;
+            case right -> borderRight;
+            case left -> borderLeft;
+            default -> throw new IllegalArgumentException();
+        };
         return (l == null) ? null : l.getLineWidth();
     }
 
@@ -210,14 +209,13 @@ public final class HSLFTableCell extends HSLFTextBox 
implements TableCell<HSLFSh
     }
 
     public Color getBorderColor(BorderEdge edge) {
-        HSLFLine l;
-        switch (edge) {
-            case bottom: l = borderBottom; break;
-            case top: l = borderTop; break;
-            case right: l = borderRight; break;
-            case left: l = borderLeft; break;
-            default: throw new IllegalArgumentException();
-        }
+        HSLFLine l = switch (edge) {
+            case bottom -> borderBottom;
+            case top -> borderTop;
+            case right -> borderRight;
+            case left -> borderLeft;
+            default -> throw new IllegalArgumentException();
+        };
         return (l == null) ? null : l.getLineColor();
     }
 
@@ -232,14 +230,13 @@ public final class HSLFTableCell extends HSLFTextBox 
implements TableCell<HSLFSh
     }
 
     public LineDash getBorderDash(BorderEdge edge) {
-        HSLFLine l;
-        switch (edge) {
-            case bottom: l = borderBottom; break;
-            case top: l = borderTop; break;
-            case right: l = borderRight; break;
-            case left: l = borderLeft; break;
-            default: throw new IllegalArgumentException();
-        }
+        HSLFLine l = switch (edge) {
+            case bottom -> borderBottom;
+            case top -> borderTop;
+            case right -> borderRight;
+            case left -> borderLeft;
+            default -> throw new IllegalArgumentException();
+        };
         return (l == null) ? null : l.getLineDash();
     }
 
@@ -254,14 +251,13 @@ public final class HSLFTableCell extends HSLFTextBox 
implements TableCell<HSLFSh
     }
 
     public LineCompound getBorderCompound(BorderEdge edge) {
-        HSLFLine l;
-        switch (edge) {
-            case bottom: l = borderBottom; break;
-            case top: l = borderTop; break;
-            case right: l = borderRight; break;
-            case left: l = borderLeft; break;
-            default: throw new IllegalArgumentException();
-        }
+        HSLFLine l = switch (edge) {
+            case bottom -> borderBottom;
+            case top -> borderTop;
+            case right -> borderRight;
+            case left -> borderLeft;
+            default -> throw new IllegalArgumentException();
+        };
         return (l == null) ? null : l.getLineCompound();
     }
 
@@ -277,54 +273,53 @@ public final class HSLFTableCell extends HSLFTextBox 
implements TableCell<HSLFSh
 
 
     protected HSLFLine addLine(BorderEdge edge) {
-        switch (edge) {
-            case bottom: {
+        return switch (edge) {
+            case bottom -> {
                 if (borderBottom == null) {
                     borderBottom = createBorder(edge);
-                    HSLFTableCell c = getSiblingCell(1,0);
+                    HSLFTableCell c = getSiblingCell(1, 0);
                     if (c != null) {
-                        assert(c.borderTop == null);
+                        assert (c.borderTop == null);
                         c.borderTop = borderBottom;
                     }
                 }
-                return borderBottom;
+                yield borderBottom;
             }
-            case top: {
+            case top -> {
                 if (borderTop == null) {
                     borderTop = createBorder(edge);
-                    HSLFTableCell c = getSiblingCell(-1,0);
+                    HSLFTableCell c = getSiblingCell(-1, 0);
                     if (c != null) {
-                        assert(c.borderBottom == null);
+                        assert (c.borderBottom == null);
                         c.borderBottom = borderTop;
                     }
                 }
-                return borderTop;
+                yield borderTop;
             }
-            case right: {
+            case right -> {
                 if (borderRight == null) {
                     borderRight = createBorder(edge);
-                    HSLFTableCell c = getSiblingCell(0,1);
+                    HSLFTableCell c = getSiblingCell(0, 1);
                     if (c != null) {
-                        assert(c.borderLeft == null);
+                        assert (c.borderLeft == null);
                         c.borderLeft = borderRight;
                     }
                 }
-                return borderRight;
+                yield borderRight;
             }
-            case left: {
+            case left -> {
                 if (borderLeft == null) {
                     borderLeft = createBorder(edge);
-                    HSLFTableCell c = getSiblingCell(0,-1);
+                    HSLFTableCell c = getSiblingCell(0, -1);
                     if (c != null) {
-                        assert(c.borderRight == null);
+                        assert (c.borderRight == null);
                         c.borderRight = borderLeft;
                     }
                 }
-                return borderLeft;
+                yield borderLeft;
             }
-            default:
-                throw new IllegalArgumentException();
-        }
+            default -> throw new IllegalArgumentException();
+        };
     }
 
     @Override
diff --git 
a/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFTextParagraph.java
 
b/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFTextParagraph.java
index b0462ceafa..caf2703310 100644
--- 
a/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFTextParagraph.java
+++ 
b/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFTextParagraph.java
@@ -437,16 +437,15 @@ public final class HSLFTextParagraph implements 
TextParagraph<HSLFShape,HSLFText
     public void setTextAlign(TextAlign align) {
         Integer alignInt = null;
         if (align != null) {
-            switch (align) {
-                default:
-                case LEFT: alignInt = TextAlignmentProp.LEFT;break;
-                case CENTER: alignInt = TextAlignmentProp.CENTER; break;
-                case RIGHT: alignInt = TextAlignmentProp.RIGHT; break;
-                case DIST: alignInt = TextAlignmentProp.DISTRIBUTED; break;
-                case JUSTIFY: alignInt = TextAlignmentProp.JUSTIFY; break;
-                case JUSTIFY_LOW: alignInt = TextAlignmentProp.JUSTIFYLOW; 
break;
-                case THAI_DIST: alignInt = TextAlignmentProp.THAIDISTRIBUTED; 
break;
-            }
+            alignInt = switch (align) {
+                default -> TextAlignmentProp.LEFT;
+                case CENTER -> TextAlignmentProp.CENTER;
+                case RIGHT -> TextAlignmentProp.RIGHT;
+                case DIST -> TextAlignmentProp.DISTRIBUTED;
+                case JUSTIFY -> TextAlignmentProp.JUSTIFY;
+                case JUSTIFY_LOW -> TextAlignmentProp.JUSTIFYLOW;
+                case THAI_DIST -> TextAlignmentProp.THAIDISTRIBUTED;
+            };
         }
         setParagraphTextPropVal("alignment", alignInt);
     }
@@ -457,16 +456,15 @@ public final class HSLFTextParagraph implements 
TextParagraph<HSLFShape,HSLFText
         if (tp == null) {
             return null;
         }
-        switch (tp.getValue()) {
-            default:
-            case TextAlignmentProp.LEFT: return TextAlign.LEFT;
-            case TextAlignmentProp.CENTER: return TextAlign.CENTER;
-            case TextAlignmentProp.RIGHT: return TextAlign.RIGHT;
-            case TextAlignmentProp.JUSTIFY: return TextAlign.JUSTIFY;
-            case TextAlignmentProp.JUSTIFYLOW: return TextAlign.JUSTIFY_LOW;
-            case TextAlignmentProp.DISTRIBUTED: return TextAlign.DIST;
-            case TextAlignmentProp.THAIDISTRIBUTED: return TextAlign.THAI_DIST;
-        }
+        return switch (tp.getValue()) {
+            case TextAlignmentProp.CENTER -> TextAlign.CENTER;
+            case TextAlignmentProp.RIGHT -> TextAlign.RIGHT;
+            case TextAlignmentProp.JUSTIFY -> TextAlign.JUSTIFY;
+            case TextAlignmentProp.JUSTIFYLOW -> TextAlign.JUSTIFY_LOW;
+            case TextAlignmentProp.DISTRIBUTED -> TextAlign.DIST;
+            case TextAlignmentProp.THAIDISTRIBUTED -> TextAlign.THAI_DIST;
+            default -> TextAlign.LEFT;
+        };
     }
 
     @Override
@@ -476,13 +474,13 @@ public final class HSLFTextParagraph implements 
TextParagraph<HSLFShape,HSLFText
             return null;
         }
 
-        switch (tp.getValue()) {
-            case FontAlignmentProp.BASELINE: return FontAlign.BASELINE;
-            case FontAlignmentProp.TOP: return FontAlign.TOP;
-            case FontAlignmentProp.CENTER: return FontAlign.CENTER;
-            case FontAlignmentProp.BOTTOM: return FontAlign.BOTTOM;
-            default: return FontAlign.AUTO;
-        }
+        return switch (tp.getValue()) {
+            case FontAlignmentProp.BASELINE -> FontAlign.BASELINE;
+            case FontAlignmentProp.TOP -> FontAlign.TOP;
+            case FontAlignmentProp.CENTER -> FontAlign.CENTER;
+            case FontAlignmentProp.BOTTOM -> FontAlign.BOTTOM;
+            default -> FontAlign.AUTO;
+        };
     }
 
     public AutoNumberingScheme getAutoNumberingScheme() {
@@ -1738,14 +1736,9 @@ public final class HSLFTextParagraph implements 
TextParagraph<HSLFShape,HSLFText
         if (ph == null) {
             return false;
         }
-        switch (ph) {
-            case DATETIME:
-            case SLIDE_NUMBER:
-            case FOOTER:
-            case HEADER:
-                return true;
-            default:
-                return false;
-        }
+        return switch (ph) {
+            case DATETIME, SLIDE_NUMBER, FOOTER, HEADER -> true;
+            default -> false;
+        };
     }
 }
\ No newline at end of file
diff --git 
a/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFTextRun.java 
b/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFTextRun.java
index eb437bbdd2..f2b2d78588 100644
--- 
a/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFTextRun.java
+++ 
b/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFTextRun.java
@@ -330,21 +330,12 @@ public final class HSLFTextRun implements TextRun {
             return;
         }
 
-        String propName;
-        switch (fg) {
-        default:
-        case LATIN:
-            propName = "ansi.font.index";
-            break;
-        case COMPLEX_SCRIPT:
+        String propName = switch (fg) {
             // TODO: implement TextCFException10 structure
-        case EAST_ASIAN:
-            propName = "asian.font.index";
-            break;
-        case SYMBOL:
-            propName = "symbol.font.index";
-            break;
-        }
+            case COMPLEX_SCRIPT, EAST_ASIAN -> "asian.font.index";
+            case SYMBOL -> "symbol.font.index";
+            default -> "ansi.font.index";
+        };
 
 
         // Get the index for this font, if it is not to be removed (typeface 
== null)
@@ -380,20 +371,11 @@ public final class HSLFTextRun implements TextRun {
             return (cachedFontInfo != null) ? cachedFontInfo[fg.ordinal()] : 
null;
         }
 
-        String propName;
-        switch (fg) {
-        default:
-        case LATIN:
-            propName = "font.index,ansi.font.index";
-            break;
-        case COMPLEX_SCRIPT:
-        case EAST_ASIAN:
-            propName = "asian.font.index";
-            break;
-        case SYMBOL:
-            propName = "symbol.font.index";
-            break;
-        }
+        String propName = switch (fg) {
+            case COMPLEX_SCRIPT, EAST_ASIAN -> "asian.font.index";
+            case SYMBOL -> "symbol.font.index";
+            default -> "font.index,ansi.font.index";
+        };
 
         TextProp tp = getTextParagraph().getPropVal(characterStyle, propName);
         return (tp != null) ? slideShow.getFont(tp.getValue()) : null;
diff --git a/poi/src/main/java/org/apache/poi/hssf/model/RecordOrderer.java 
b/poi/src/main/java/org/apache/poi/hssf/model/RecordOrderer.java
index c627561b61..6dfb9208f0 100644
--- a/poi/src/main/java/org/apache/poi/hssf/model/RecordOrderer.java
+++ b/poi/src/main/java/org/apache/poi/hssf/model/RecordOrderer.java
@@ -320,35 +320,23 @@ final class RecordOrderer {
             return true;
         }
         short sid = ((org.apache.poi.hssf.record.Record)rb).getSid();
-        switch(sid) {
-            case WindowTwoRecord.sid:
-            case UnknownRecord.SCL_00A0:
-            case PaneRecord.sid:
-            case SelectionRecord.sid:
-            case UnknownRecord.STANDARDWIDTH_0099:
+        return switch (sid) {
             // MergedCellsTable
-            case UnknownRecord.LABELRANGES_015F:
-            case UnknownRecord.PHONETICPR_00EF:
             // ConditionalFormattingTable
-            case HyperlinkRecord.sid:
-            case UnknownRecord.QUICKTIP_0800:
             // name of a VBA module
-            case UnknownRecord.CODENAME_1BA:
-                return true;
-        }
-        return false;
+            case WindowTwoRecord.sid, UnknownRecord.SCL_00A0, PaneRecord.sid, 
SelectionRecord.sid,
+                 UnknownRecord.STANDARDWIDTH_0099, 
UnknownRecord.LABELRANGES_015F, UnknownRecord.PHONETICPR_00EF,
+                 HyperlinkRecord.sid, UnknownRecord.QUICKTIP_0800, 
UnknownRecord.CODENAME_1BA -> true;
+            default -> false;
+        };
     }
 
     private static boolean isDVTSubsequentRecord(short sid) {
-        switch(sid) {
-            case UnknownRecord.SHEETEXT_0862:
-            case UnknownRecord.SHEETPROTECTION_0867:
-            case UnknownRecord.PLV_MAC:
-            case FeatRecord.sid:
-            case EOFRecord.sid:
-                return true;
-        }
-        return false;
+        return switch (sid) {
+            case UnknownRecord.SHEETEXT_0862, 
UnknownRecord.SHEETPROTECTION_0867, UnknownRecord.PLV_MAC, FeatRecord.sid,
+                 EOFRecord.sid -> true;
+            default -> false;
+        };
     }
     /**
      * DIMENSIONS record is always present
@@ -409,27 +397,20 @@ final class RecordOrderer {
      * record
      */
     public static boolean isEndOfRowBlock(int sid) {
-        switch(sid) {
-            case ViewDefinitionRecord.sid:
-                // should have been prefixed with DrawingRecord (0x00EC), but 
bug 46280 seems to allow this
-            case DrawingRecord.sid:
-            case DrawingSelectionRecord.sid:
-            case ObjRecord.sid:
-            case TextObjectRecord.sid:
-            case ColumnInfoRecord.sid: // See Bugzilla 53984
-            case GutsRecord.sid:   // see Bugzilla 50426
-            case WindowOneRecord.sid:
-                // should really be part of workbook stream, but some apps 
seem to put this before WINDOW2
-            case WindowTwoRecord.sid:
-                return true;
-
-            case DVALRecord.sid:
-                return true;
-            case EOFRecord.sid:
-                // WINDOW2 should always be present, so shouldn't have got 
this far
-                throw new IllegalArgumentException("Found EOFRecord before 
WindowTwoRecord was encountered");
-        }
-        return PageSettingsBlock.isComponentRecord(sid);
+        // WINDOW2 should always be present, so shouldn't have got this far
+        return switch (sid) {
+            // should have been prefixed with DrawingRecord (0x00EC), but bug 
46280 seems to allow this
+            // See Bugzilla 53984
+            // see Bugzilla 50426
+            // should really be part of workbook stream, but some apps seem to 
put this before WINDOW2
+            case ViewDefinitionRecord.sid, DrawingRecord.sid, 
DrawingSelectionRecord.sid, ObjRecord.sid,
+                 TextObjectRecord.sid, ColumnInfoRecord.sid, GutsRecord.sid, 
WindowOneRecord.sid, WindowTwoRecord.sid ->
+                    true;
+            case DVALRecord.sid -> true;
+            case EOFRecord.sid ->
+                    throw new IllegalArgumentException("Found EOFRecord before 
WindowTwoRecord was encountered");
+            default -> PageSettingsBlock.isComponentRecord(sid);
+        };
     }
 
     /**
diff --git a/poi/src/main/java/org/apache/poi/hssf/record/BOFRecord.java 
b/poi/src/main/java/org/apache/poi/hssf/record/BOFRecord.java
index 5f081c1bac..5a8dbdb276 100644
--- a/poi/src/main/java/org/apache/poi/hssf/record/BOFRecord.java
+++ b/poi/src/main/java/org/apache/poi/hssf/record/BOFRecord.java
@@ -233,15 +233,15 @@ public final class BOFRecord extends StandardRecord {
     }
 
     private String getTypeName() {
-        switch(field_2_type) {
-            case TYPE_CHART: return "chart";
-            case TYPE_EXCEL_4_MACRO: return "excel 4 macro";
-            case TYPE_VB_MODULE: return "vb module";
-            case TYPE_WORKBOOK: return "workbook";
-            case TYPE_WORKSHEET: return "worksheet";
-            case TYPE_WORKSPACE_FILE: return "workspace file";
-        }
-        return "#error unknown type#";
+        return switch (field_2_type) {
+            case TYPE_CHART -> "chart";
+            case TYPE_EXCEL_4_MACRO -> "excel 4 macro";
+            case TYPE_VB_MODULE -> "vb module";
+            case TYPE_WORKBOOK -> "workbook";
+            case TYPE_WORKSHEET -> "worksheet";
+            case TYPE_WORKSPACE_FILE -> "workspace file";
+            default -> "#error unknown type#";
+        };
     }
 
     public void serialize(LittleEndianOutput out) {
diff --git 
a/poi/src/main/java/org/apache/poi/hssf/record/EmbeddedObjectRefSubRecord.java 
b/poi/src/main/java/org/apache/poi/hssf/record/EmbeddedObjectRefSubRecord.java
index 53930b3b8b..85fa336711 100644
--- 
a/poi/src/main/java/org/apache/poi/hssf/record/EmbeddedObjectRefSubRecord.java
+++ 
b/poi/src/main/java/org/apache/poi/hssf/record/EmbeddedObjectRefSubRecord.java
@@ -181,13 +181,13 @@ public final class EmbeddedObjectRefSubRecord extends 
SubRecord {
         try (LittleEndianInputStream in = new LittleEndianInputStream(
                 
UnsynchronizedByteArrayInputStream.builder().setByteArray(formulaRawBytes).get()))
 {
             byte ptgSid = in.readByte();
-            switch(ptgSid) {
-                case AreaPtg.sid:   return new AreaPtg(in);
-                case Area3DPtg.sid: return new Area3DPtg(in);
-                case RefPtg.sid:    return new RefPtg(in);
-                case Ref3DPtg.sid:  return new Ref3DPtg(in);
-            }
-            return null;
+            return switch (ptgSid) {
+                case AreaPtg.sid -> new AreaPtg(in);
+                case Area3DPtg.sid -> new Area3DPtg(in);
+                case RefPtg.sid -> new RefPtg(in);
+                case Ref3DPtg.sid -> new Ref3DPtg(in);
+                default -> null;
+            };
         } catch (IOException e) {
             throw new IllegalStateException("Unexpected exception in 
readRefPtg", e);
         }
diff --git a/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFCell.java 
b/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFCell.java
index 4e46848e0b..7f205de8a2 100644
--- a/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFCell.java
+++ b/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFCell.java
@@ -671,10 +671,10 @@ public class HSSFCell extends CellBase {
                 return 0.0;
             case NUMERIC:
                 return ((NumberRecord)_record).getValue();
-            default:
-                throw typeMismatch(CellType.NUMERIC, _cellType, false);
             case FORMULA:
                 break;
+            default:
+                throw typeMismatch(CellType.NUMERIC, _cellType, false);
         }
         FormulaRecord fr = 
((FormulaRecordAggregate)_record).getFormulaRecord();
         checkFormulaCachedValueType(CellType.NUMERIC, fr);
@@ -746,10 +746,10 @@ public class HSSFCell extends CellBase {
                 return new HSSFRichTextString("");
             case STRING:
                 return _stringValue;
-            default:
-                throw typeMismatch(CellType.STRING, _cellType, false);
             case FORMULA:
                 break;
+            default:
+                throw typeMismatch(CellType.STRING, _cellType, false);
         }
         FormulaRecordAggregate fra = ((FormulaRecordAggregate)_record);
         checkFormulaCachedValueType(CellType.STRING, fra.getFormulaRecord());
diff --git a/poi/src/main/java/org/apache/poi/ss/formula/FormulaShifter.java 
b/poi/src/main/java/org/apache/poi/ss/formula/FormulaShifter.java
index a2edfccaff..57750208da 100644
--- a/poi/src/main/java/org/apache/poi/ss/formula/FormulaShifter.java
+++ b/poi/src/main/java/org/apache/poi/ss/formula/FormulaShifter.java
@@ -164,23 +164,18 @@ public final class FormulaShifter {
     }
 
     private Ptg adjustPtg(Ptg ptg, int currentExternSheetIx) {
-        switch(_mode){
-            case RowMove:
-                return adjustPtgDueToRowMove(ptg, currentExternSheetIx);
-            case RowCopy:
+        return switch (_mode) {
+            case RowMove -> adjustPtgDueToRowMove(ptg, currentExternSheetIx);
+            case RowCopy ->
                 // Covered Scenarios:
                 // * row copy on same sheet
                 // * row copy between different sheets in the same workbook
-                return adjustPtgDueToRowCopy(ptg);
-            case ColumnMove:
-                return adjustPtgDueToColumnMove(ptg, currentExternSheetIx);
-            case ColumnCopy:
-                return adjustPtgDueToColumnCopy(ptg);
-            case SheetMove:
-                return adjustPtgDueToSheetMove(ptg);
-            default:
-                throw new IllegalStateException("Unsupported shift mode: " + 
_mode);
-        }
+                    adjustPtgDueToRowCopy(ptg);
+            case ColumnMove -> adjustPtgDueToColumnMove(ptg, 
currentExternSheetIx);
+            case ColumnCopy -> adjustPtgDueToColumnCopy(ptg);
+            case SheetMove -> adjustPtgDueToSheetMove(ptg);
+            default -> throw new IllegalStateException("Unsupported shift 
mode: " + _mode);
+        };
     }
 
     /**
diff --git 
a/poi/src/main/java/org/apache/poi/ss/formula/SheetNameFormatter.java 
b/poi/src/main/java/org/apache/poi/ss/formula/SheetNameFormatter.java
index 09a3d39e8e..4917cc227e 100644
--- a/poi/src/main/java/org/apache/poi/ss/formula/SheetNameFormatter.java
+++ b/poi/src/main/java/org/apache/poi/ss/formula/SheetNameFormatter.java
@@ -191,17 +191,13 @@ public final class SheetNameFormatter {
         if(Character.isLetterOrDigit(ch)) {
             return false;
         }
-        switch(ch) {
-            case '.': // dot is OK
-            case '_': // underscore is OK
-                return false;
-            case '\n':
-            case '\r':
-            case '\t':
-                throw new IllegalStateException("Illegal character (0x"
-                        + Integer.toHexString(ch) + ") found in sheet name");
-        }
-        return true;
+        return switch (ch) { // dot is OK
+            case '.', '_' -> // underscore is OK
+                    false;
+            case '\n', '\r', '\t' -> throw new IllegalStateException("Illegal 
character (0x"
+                    + Integer.toHexString(ch) + ") found in sheet name");
+            default -> true;
+        };
     }
 
 
diff --git 
a/poi/src/main/java/org/apache/poi/ss/formula/constant/ConstantValueParser.java 
b/poi/src/main/java/org/apache/poi/ss/formula/constant/ConstantValueParser.java
index 432eb3b897..1d22f574f3 100644
--- 
a/poi/src/main/java/org/apache/poi/ss/formula/constant/ConstantValueParser.java
+++ 
b/poi/src/main/java/org/apache/poi/ss/formula/constant/ConstantValueParser.java
@@ -80,14 +80,13 @@ public final class ConstantValueParser {
 
     private static Object readBoolean(LittleEndianInput in) {
         byte val = (byte)in.readLong(); // 7 bytes 'not used'
-        switch(val) {
-            case FALSE_ENCODING:
-                return Boolean.FALSE;
-            case TRUE_ENCODING:
-                return Boolean.TRUE;
-        }
-        // Don't tolerate unusual boolean encoded values (unless it becomes 
evident that they occur)
-        throw new IllegalArgumentException("unexpected boolean encoding (" + 
val + ")");
+        return switch (val) {
+            case FALSE_ENCODING -> Boolean.FALSE;
+            case TRUE_ENCODING -> Boolean.TRUE;
+            default ->
+                // Don't tolerate unusual boolean encoded values (unless it 
becomes evident that they occur)
+                    throw new IllegalArgumentException("unexpected boolean 
encoding (" + val + ")");
+        };
     }
 
     public static int getEncodedSize(Object[] values) {
diff --git 
a/poi/src/main/java/org/apache/poi/ss/formula/function/FunctionMetadataReader.java
 
b/poi/src/main/java/org/apache/poi/ss/formula/function/FunctionMetadataReader.java
index 6d5ab828ee..ad62636a6c 100644
--- 
a/poi/src/main/java/org/apache/poi/ss/formula/function/FunctionMetadataReader.java
+++ 
b/poi/src/main/java/org/apache/poi/ss/formula/function/FunctionMetadataReader.java
@@ -171,12 +171,13 @@ final class FunctionMetadataReader {
         if(code.length() != 1) {
             throw new IllegalStateException("Bad operand type code format '" + 
code  + "' expected single char");
         }
-        switch(code.charAt(0)) {
-            case 'V': return Ptg.CLASS_VALUE;
-            case 'R': return Ptg.CLASS_REF;
-            case 'A': return Ptg.CLASS_ARRAY;
-        }
-        throw new IllegalArgumentException("Unexpected operand type code '" + 
code + "' (" + (int)code.charAt(0) + ")");
+        return switch (code.charAt(0)) {
+            case 'V' -> Ptg.CLASS_VALUE;
+            case 'R' -> Ptg.CLASS_REF;
+            case 'A' -> Ptg.CLASS_ARRAY;
+            default ->
+                    throw new IllegalArgumentException("Unexpected operand 
type code '" + code + "' (" + (int) code.charAt(0) + ")");
+        };
     }
 
     /**
diff --git 
a/poi/src/main/java/org/apache/poi/ss/formula/functions/DStarRunner.java 
b/poi/src/main/java/org/apache/poi/ss/formula/functions/DStarRunner.java
index c5669a801e..53d6aaa7a8 100644
--- a/poi/src/main/java/org/apache/poi/ss/formula/functions/DStarRunner.java
+++ b/poi/src/main/java/org/apache/poi/ss/formula/functions/DStarRunner.java
@@ -405,21 +405,14 @@ public final class DStarRunner implements Function3Arg {
         }
 
         int result = NumberComparer.compare(value, conditionValue);
-        switch(op) {
-        case largerThan:
-            return result > 0;
-        case largerEqualThan:
-            return result >= 0;
-        case smallerThan:
-            return result < 0;
-        case smallerEqualThan:
-            return result <= 0;
-        case equal:
-            return result == 0;
-        case notEqual:
-            return result != 0;
-        }
-        return false; // Can not be reached.
+        return switch (op) {
+            case largerThan -> result > 0;
+            case largerEqualThan -> result >= 0;
+            case smallerThan -> result < 0;
+            case smallerEqualThan -> result <= 0;
+            case equal -> result == 0;
+            case notEqual -> result != 0;
+        };
     }
 
     /**
diff --git a/poi/src/main/java/org/apache/poi/ss/formula/ptg/ErrPtg.java 
b/poi/src/main/java/org/apache/poi/ss/formula/ptg/ErrPtg.java
index 43e0857a3b..1726e71264 100644
--- a/poi/src/main/java/org/apache/poi/ss/formula/ptg/ErrPtg.java
+++ b/poi/src/main/java/org/apache/poi/ss/formula/ptg/ErrPtg.java
@@ -83,17 +83,16 @@ public final class ErrPtg extends ScalarConstantPtg {
     }
 
     public static ErrPtg valueOf(int code) {
-        switch(FormulaError.forInt(code)) {
-            case DIV0: return DIV_ZERO;
-            case NA: return N_A;
-            case NAME: return NAME_INVALID;
-            case NULL: return NULL_INTERSECTION;
-            case NUM: return NUM_ERROR;
-            case REF: return REF_INVALID;
-            case VALUE: return VALUE_INVALID;
-            default:
-                throw new IllegalStateException("Unexpected error code (" + 
code + ")");
-        }
+        return switch (FormulaError.forInt(code)) {
+            case DIV0 -> DIV_ZERO;
+            case NA -> N_A;
+            case NAME -> NAME_INVALID;
+            case NULL -> NULL_INTERSECTION;
+            case NUM -> NUM_ERROR;
+            case REF -> REF_INVALID;
+            case VALUE -> VALUE_INVALID;
+            default -> throw new IllegalStateException("Unexpected error code 
(" + code + ")");
+        };
     }
 
     @Override
diff --git a/poi/src/main/java/org/apache/poi/ss/formula/ptg/Ptg.java 
b/poi/src/main/java/org/apache/poi/ss/formula/ptg/Ptg.java
index 5f53737c94..c1b9c86222 100644
--- a/poi/src/main/java/org/apache/poi/ss/formula/ptg/Ptg.java
+++ b/poi/src/main/java/org/apache/poi/ss/formula/ptg/Ptg.java
@@ -134,40 +134,40 @@ public abstract class Ptg implements Duplicatable, 
GenericRecord {
     }
 
     private static Ptg createBasePtg(byte id, LittleEndianInput in) {
-        switch(id) {
-            case 0x00:                return new UnknownPtg(id); // TODO - not 
a real Ptg
-            case ExpPtg.sid:          return new ExpPtg(in);          // 0x01
-            case TblPtg.sid:          return new TblPtg(in);          // 0x02
-            case AddPtg.sid:          return AddPtg.instance;         // 0x03
-            case SubtractPtg.sid:     return SubtractPtg.instance;    // 0x04
-            case MultiplyPtg.sid:     return MultiplyPtg.instance;    // 0x05
-            case DividePtg.sid:       return DividePtg.instance;      // 0x06
-            case PowerPtg.sid:        return PowerPtg.instance;       // 0x07
-            case ConcatPtg.sid:       return ConcatPtg.instance;      // 0x08
-            case LessThanPtg.sid:     return LessThanPtg.instance;    // 0x09
-            case LessEqualPtg.sid:    return LessEqualPtg.instance;   // 0x0a
-            case EqualPtg.sid:        return EqualPtg.instance;       // 0x0b
-            case GreaterEqualPtg.sid: return GreaterEqualPtg.instance;// 0x0c
-            case GreaterThanPtg.sid:  return GreaterThanPtg.instance; // 0x0d
-            case NotEqualPtg.sid:     return NotEqualPtg.instance;    // 0x0e
-            case IntersectionPtg.sid: return IntersectionPtg.instance;// 0x0f
-            case UnionPtg.sid:        return UnionPtg.instance;       // 0x10
-            case RangePtg.sid:        return RangePtg.instance;       // 0x11
-            case UnaryPlusPtg.sid:    return UnaryPlusPtg.instance;   // 0x12
-            case UnaryMinusPtg.sid:   return UnaryMinusPtg.instance;  // 0x13
-            case PercentPtg.sid:      return PercentPtg.instance;     // 0x14
-            case ParenthesisPtg.sid:  return ParenthesisPtg.instance; // 0x15
-            case MissingArgPtg.sid:   return MissingArgPtg.instance;  // 0x16
-
-            case StringPtg.sid:       return new StringPtg(in);       // 0x17
+        return switch (id) {
+            case 0x00 -> new UnknownPtg(id); // TODO - not a real Ptg
+            case ExpPtg.sid -> new ExpPtg(in);          // 0x01
+            case TblPtg.sid -> new TblPtg(in);          // 0x02
+            case AddPtg.sid -> AddPtg.instance;         // 0x03
+            case SubtractPtg.sid -> SubtractPtg.instance;    // 0x04
+            case MultiplyPtg.sid -> MultiplyPtg.instance;    // 0x05
+            case DividePtg.sid -> DividePtg.instance;      // 0x06
+            case PowerPtg.sid -> PowerPtg.instance;       // 0x07
+            case ConcatPtg.sid -> ConcatPtg.instance;      // 0x08
+            case LessThanPtg.sid -> LessThanPtg.instance;    // 0x09
+            case LessEqualPtg.sid -> LessEqualPtg.instance;   // 0x0a
+            case EqualPtg.sid -> EqualPtg.instance;       // 0x0b
+            case GreaterEqualPtg.sid -> GreaterEqualPtg.instance;// 0x0c
+            case GreaterThanPtg.sid -> GreaterThanPtg.instance; // 0x0d
+            case NotEqualPtg.sid -> NotEqualPtg.instance;    // 0x0e
+            case IntersectionPtg.sid -> IntersectionPtg.instance;// 0x0f
+            case UnionPtg.sid -> UnionPtg.instance;       // 0x10
+            case RangePtg.sid -> RangePtg.instance;       // 0x11
+            case UnaryPlusPtg.sid -> UnaryPlusPtg.instance;   // 0x12
+            case UnaryMinusPtg.sid -> UnaryMinusPtg.instance;  // 0x13
+            case PercentPtg.sid -> PercentPtg.instance;     // 0x14
+            case ParenthesisPtg.sid -> ParenthesisPtg.instance; // 0x15
+            case MissingArgPtg.sid -> MissingArgPtg.instance;  // 0x16
+
+            case StringPtg.sid -> new StringPtg(in);       // 0x17
             // not implemented yet: case SxNamePtg.sid:       return new 
SxNamePtg(in);       // 0x18
-            case AttrPtg.sid:         return new AttrPtg(in);         // 0x19
-            case ErrPtg.sid:          return ErrPtg.read(in);         // 0x1c
-            case BoolPtg.sid:         return BoolPtg.read(in);        // 0x1d
-            case IntPtg.sid:          return new IntPtg(in);          // 0x1e
-            case NumberPtg.sid:       return new NumberPtg(in);       // 0x1f
-        }
-        throw new IllegalArgumentException("Unexpected base token id (" + id + 
")");
+            case AttrPtg.sid -> new AttrPtg(in);         // 0x19
+            case ErrPtg.sid -> ErrPtg.read(in);         // 0x1c
+            case BoolPtg.sid -> BoolPtg.read(in);        // 0x1d
+            case IntPtg.sid -> new IntPtg(in);          // 0x1e
+            case NumberPtg.sid -> new NumberPtg(in);       // 0x1f
+            default -> throw new IllegalArgumentException("Unexpected base 
token id (" + id + ")");
+        };
     }
 
     private static Ptg[] toPtgArray(List<Ptg> l) {
diff --git a/poi/src/main/java/org/apache/poi/ss/usermodel/DateUtil.java 
b/poi/src/main/java/org/apache/poi/ss/usermodel/DateUtil.java
index 5977314576..ea7deab17e 100644
--- a/poi/src/main/java/org/apache/poi/ss/usermodel/DateUtil.java
+++ b/poi/src/main/java/org/apache/poi/ss/usermodel/DateUtil.java
@@ -727,27 +727,15 @@ public class DateUtil {
      * @see #isADateFormat(int, java.lang.String)
      */
     public static boolean isInternalDateFormat(int format) {
-        switch(format) {
+        return switch (format) {
             // Internal Date Formats as described on page 427 in
             // Microsoft Excel Dev's Kit...
             // see also javadoc in org.apache.poi.ss.usermodel.BuiltinFormats
-            case 0x0e:
-            case 0x0f:
-            case 0x10:
-            case 0x11:
             // the 0x12 to 0x15 formats are time (only) formats
-            case 0x12:
-            case 0x13:
-            case 0x14:
-            case 0x15:
-            case 0x16:
             // the 0x2d to 0x2f formats are time (only) formats
-            case 0x2d:
-            case 0x2e:
-            case 0x2f:
-                return true;
-        }
-        return false;
+            case 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x2d, 
0x2e, 0x2f -> true;
+            default -> false;
+        };
     }
 
     /**
diff --git a/poi/src/main/java/org/apache/poi/ss/util/CellRangeUtil.java 
b/poi/src/main/java/org/apache/poi/ss/util/CellRangeUtil.java
index 50bf7a4250..ca59084cb5 100644
--- a/poi/src/main/java/org/apache/poi/ss/util/CellRangeUtil.java
+++ b/poi/src/main/java/org/apache/poi/ss/util/CellRangeUtil.java
@@ -143,28 +143,29 @@ public final class CellRangeUtil {
      */
     private static CellRangeAddress[] mergeRanges(CellRangeAddress range1, 
CellRangeAddress range2) {
         int x = intersect(range1, range2);
-        switch(x)
-        {
-            case CellRangeUtil.NO_INTERSECTION:
+        return switch (x) {
+            case CellRangeUtil.NO_INTERSECTION -> {
                 // nothing in common: at most they could be adjacent to each 
other and thus form a single bigger area
-                if(hasExactSharedBorder(range1, range2)) {
-                    return new CellRangeAddress[] { 
createEnclosingCellRange(range1, range2), };
+                if (hasExactSharedBorder(range1, range2)) {
+                    yield new 
CellRangeAddress[]{createEnclosingCellRange(range1, range2),};
                 }
                 // else - No intersection and no shared border: do nothing
-                return null;
-            case CellRangeUtil.OVERLAP:
+                yield null;
+                // else - No intersection and no shared border: do nothing
+            }
+            case CellRangeUtil.OVERLAP ->
                 // commented out the cells overlap implementation, it caused 
endless loops, see Bug 55380
                 // disabled for now, the algorithm will not detect some border 
cases this way currently!
                 //return resolveRangeOverlap(range1, range2);
-                return null;
-            case CellRangeUtil.INSIDE:
+                    null;
+            case CellRangeUtil.INSIDE ->
                 // Remove range2, since it is completely inside of range1
-                return new CellRangeAddress[] { range1 };
-            case CellRangeUtil.ENCLOSES:
+                    new CellRangeAddress[]{range1};
+            case CellRangeUtil.ENCLOSES ->
                 // range2 encloses range1, so replace it with the enclosing one
-                return new CellRangeAddress[] { range2 };
-        }
-        throw new IllegalStateException("unexpected intersection result (" + x 
+ ")");
+                    new CellRangeAddress[]{range2};
+            default -> throw new IllegalStateException("unexpected 
intersection result (" + x + ")");
+        };
     }
 
     private static CellRangeAddress[] toArray(List<CellRangeAddress> temp) {


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to