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 7bff84157f use java 17 code enhancements (#1139)
7bff84157f is described below

commit 7bff84157fa30f3e78c4e62021b8ea54f98a59d8
Author: PJ Fanning <[email protected]>
AuthorDate: Fri Jun 12 14:31:44 2026 +0100

    use java 17 code enhancements (#1139)
    
    * use java 17 code enhancements
    
    * Update SlideShowExtractor.java
    
    * Update SlideShowExtractor.java
---
 .../test/java/org/apache/poi/stress/StressMap.java | 21 ++---
 .../java/org/apache/poi/sl/draw/DrawPaint.java     | 17 ++--
 .../java/org/apache/poi/sl/draw/DrawShape.java     | 18 ++---
 .../org/apache/poi/sl/draw/DrawTableShape.java     | 22 ++---
 .../org/apache/poi/sl/draw/DrawTextParagraph.java  | 42 ++++------
 .../java/org/apache/poi/sl/draw/DrawTextShape.java |  8 +-
 .../org/apache/poi/sl/draw/DrawTexturePaint.java   | 71 ++++++++--------
 .../main/java/org/apache/poi/sl/draw/Drawable.java | 38 ++++-----
 .../poi/sl/extractor/SlideShowExtractor.java       | 10 ++-
 .../poi/sl/usermodel/AutoNumberingScheme.java      | 94 ++++++++++++----------
 .../apache/poi/ss/format/CellElapsedFormatter.java | 36 +++------
 .../apache/poi/ss/format/CellFormatCondition.java  | 25 +++---
 .../org/apache/poi/ss/format/CellFormatPart.java   | 25 ++----
 .../poi/ss/formula/BaseFormulaEvaluator.java       | 25 +++---
 .../poi/ss/formula/OperandClassTransformer.java    | 51 +++++-------
 .../apache/poi/ss/formula/WorkbookEvaluator.java   | 64 +++++----------
 .../formula/eval/forked/ForkedEvaluationCell.java  | 13 +--
 .../ss/formula/eval/forked/ForkedEvaluator.java    | 25 +++---
 .../org/apache/poi/ss/util/PaneInformation.java    | 19 ++---
 19 files changed, 253 insertions(+), 371 deletions(-)

diff --git a/poi-integration/src/test/java/org/apache/poi/stress/StressMap.java 
b/poi-integration/src/test/java/org/apache/poi/stress/StressMap.java
index 32f26e67f1..5f66449a33 100644
--- a/poi-integration/src/test/java/org/apache/poi/stress/StressMap.java
+++ b/poi-integration/src/test/java/org/apache/poi/stress/StressMap.java
@@ -155,21 +155,10 @@ public class StressMap {
     }
 
     private static String secondHandler(String handlerStr) {
-        switch (handlerStr) {
-            case "XSSF":
-            case "XWPF":
-            case "XSLF":
-            case "XDGF":
-                return "OPC";
-            case "HSSF":
-            case "HWPF":
-            case "HSLF":
-            case "HDGF":
-            case "HSMF":
-            case "HBPF":
-                return "HPSF";
-            default:
-                return "NULL";
-        }
+        return switch (handlerStr) {
+            case "XSSF", "XWPF", "XSLF", "XDGF" -> "OPC";
+            case "HSSF", "HWPF", "HSLF", "HDGF", "HSMF", "HBPF" -> "HPSF";
+            default -> "NULL";
+        };
     }
 }
diff --git a/poi/src/main/java/org/apache/poi/sl/draw/DrawPaint.java 
b/poi/src/main/java/org/apache/poi/sl/draw/DrawPaint.java
index 57fc3fca84..7197a5816d 100644
--- a/poi/src/main/java/org/apache/poi/sl/draw/DrawPaint.java
+++ b/poi/src/main/java/org/apache/poi/sl/draw/DrawPaint.java
@@ -241,18 +241,13 @@ public class DrawPaint {
 
     @SuppressWarnings("WeakerAccess")
     protected Paint getGradientPaint(GradientPaint fill, Graphics2D graphics) {
-        switch (fill.getGradientType()) {
-        case linear:
-            return createLinearGradientPaint(fill, graphics);
-        case rectangular:
+        return switch (fill.getGradientType()) {
+            case linear -> createLinearGradientPaint(fill, graphics);
             // TODO: implement rectangular gradient fill
-        case circular:
-            return createRadialGradientPaint(fill, graphics);
-        case shape:
-            return createPathGradientPaint(fill, graphics);
-        default:
-            throw new UnsupportedOperationException("gradient fill of type 
"+fill+" not supported.");
-        }
+            case rectangular, circular -> createRadialGradientPaint(fill, 
graphics);
+            case shape -> createPathGradientPaint(fill, graphics);
+            default -> throw new UnsupportedOperationException("gradient fill 
of type " + fill + " not supported.");
+        };
     }
 
     @SuppressWarnings("WeakerAccess")
diff --git a/poi/src/main/java/org/apache/poi/sl/draw/DrawShape.java 
b/poi/src/main/java/org/apache/poi/sl/draw/DrawShape.java
index 4e1cda8d5d..a4e92378af 100644
--- a/poi/src/main/java/org/apache/poi/sl/draw/DrawShape.java
+++ b/poi/src/main/java/org/apache/poi/sl/draw/DrawShape.java
@@ -228,19 +228,11 @@ public class DrawShape implements Drawable {
         if (lineCapE == null) {
             lineCapE = LineCap.FLAT;
         }
-        int lineCap;
-        switch (lineCapE) {
-            case ROUND:
-                lineCap = BasicStroke.CAP_ROUND;
-                break;
-            case SQUARE:
-                lineCap = BasicStroke.CAP_SQUARE;
-                break;
-            default:
-            case FLAT:
-                lineCap = BasicStroke.CAP_BUTT;
-                break;
-        }
+        int lineCap = switch (lineCapE) {
+            case ROUND -> BasicStroke.CAP_ROUND;
+            case SQUARE -> BasicStroke.CAP_SQUARE;
+            default -> BasicStroke.CAP_BUTT;
+        };
 
         int lineJoin = BasicStroke.JOIN_ROUND;
 
diff --git a/poi/src/main/java/org/apache/poi/sl/draw/DrawTableShape.java 
b/poi/src/main/java/org/apache/poi/sl/draw/DrawTableShape.java
index d8791b2d5b..76c5bd726e 100644
--- a/poi/src/main/java/org/apache/poi/sl/draw/DrawTableShape.java
+++ b/poi/src/main/java/org/apache/poi/sl/draw/DrawTableShape.java
@@ -97,22 +97,12 @@ public class DrawTableShape extends DrawShape {
                     graphics.setPaint(linePaint);
 
                     double x=cellAnc.getX(), y=cellAnc.getY(), 
w=cellAnc.getWidth(), h=cellAnc.getHeight();
-                    Line2D line;
-                    switch (edge) {
-                        default:
-                        case bottom:
-                            line = new Line2D.Double(x-borderSize, y+h, 
x+w+borderSize, y+h);
-                            break;
-                        case left:
-                            line = new Line2D.Double(x, y, x, y+h+borderSize);
-                            break;
-                        case right:
-                            line = new Line2D.Double(x+w, y, x+w, 
y+h+borderSize);
-                            break;
-                        case top:
-                            line = new Line2D.Double(x-borderSize, y, 
x+w+borderSize, y);
-                            break;
-                    }
+                    Line2D line = switch (edge) {
+                        case left -> new Line2D.Double(x, y, x, y + h + 
borderSize);
+                        case right -> new Line2D.Double(x + w, y, x + w, y + h 
+ borderSize);
+                        case top -> new Line2D.Double(x - borderSize, y, x + w 
+ borderSize, y);
+                        default -> new Line2D.Double(x - borderSize, y + h, x 
+ w + borderSize, y + h);
+                    };
 
                     graphics.draw(line);
                 }
diff --git a/poi/src/main/java/org/apache/poi/sl/draw/DrawTextParagraph.java 
b/poi/src/main/java/org/apache/poi/sl/draw/DrawTextParagraph.java
index ce47b45f66..ce23bc2b49 100644
--- a/poi/src/main/java/org/apache/poi/sl/draw/DrawTextParagraph.java
+++ b/poi/src/main/java/org/apache/poi/sl/draw/DrawTextParagraph.java
@@ -442,14 +442,11 @@ public class DrawTextParagraph implements Drawable {
         txtSpace = txtSpace.replace('\u000b', '\n');
         final Locale loc = LocaleUtil.getUserLocale();
 
-        switch (tr.getTextCap()) {
-            case ALL:
-                return txtSpace.toUpperCase(loc);
-            case SMALL:
-                return txtSpace.toLowerCase(loc);
-            default:
-                return txtSpace;
-        }
+        return switch (tr.getTextCap()) {
+            case ALL -> txtSpace.toUpperCase(loc);
+            case SMALL -> txtSpace.toLowerCase(loc);
+            default -> txtSpace;
+        };
     }
 
     /**
@@ -531,27 +528,16 @@ public class DrawTextParagraph implements Drawable {
         if (!ts.getWordWrap()) {
             Dimension pageDim = ts.getSheet().getSlideShow().getPageSize();
             // if wordWrap == false then we return the advance to the (right) 
border of the sheet
-            switch (textDir) {
-                default:
-                    width = pageDim.getWidth() - anchor.getX();
-                    break;
-                case VERTICAL:
-                    width = pageDim.getHeight() - anchor.getX();
-                    break;
-                case VERTICAL_270:
-                    width = anchor.getX();
-                    break;
-            }
+            width = switch (textDir) {
+                case VERTICAL -> pageDim.getHeight() - anchor.getX();
+                case VERTICAL_270 -> anchor.getX();
+                default -> pageDim.getWidth() - anchor.getX();
+            };
         } else {
-            switch (textDir) {
-                default:
-                    width = anchor.getWidth() - leftInset - rightInset - 
leftMargin - rightMargin;
-                    break;
-                case VERTICAL:
-                case VERTICAL_270:
-                    width = anchor.getHeight() - leftInset - rightInset - 
leftMargin - rightMargin;
-                    break;
-            }
+            width = switch (textDir) {
+                case VERTICAL, VERTICAL_270 -> anchor.getHeight() - leftInset 
- rightInset - leftMargin - rightMargin;
+                default -> anchor.getWidth() - leftInset - rightInset - 
leftMargin - rightMargin;
+            };
             if (firstLine && bullet == null) {
                 // indent is usually negative in XSLF
                 width += isHSLF() ? (leftMargin - indent) : -indent;
diff --git a/poi/src/main/java/org/apache/poi/sl/draw/DrawTextShape.java 
b/poi/src/main/java/org/apache/poi/sl/draw/DrawTextShape.java
index 6894895b0e..db639c43d5 100644
--- a/poi/src/main/java/org/apache/poi/sl/draw/DrawTextShape.java
+++ b/poi/src/main/java/org/apache/poi/sl/draw/DrawTextShape.java
@@ -91,10 +91,6 @@ public class DrawTextShape extends DrawSimpleShape {
         double textHeight;
 
         switch (s.getVerticalAlignment()){
-            default:
-            case TOP:
-                y += insets.top;
-                break;
             case BOTTOM:
                 textHeight = getTextHeight(graphics);
                 y += anchor.getHeight() - textHeight - insets.bottom;
@@ -104,6 +100,10 @@ public class DrawTextShape extends DrawSimpleShape {
                 double delta = anchor.getHeight() - textHeight - insets.top - 
insets.bottom;
                 y += insets.top + delta/2;
                 break;
+            case TOP:
+            default:
+                y += insets.top;
+                break;
         }
 
         TextDirection textDir = s.getTextDirection();
diff --git a/poi/src/main/java/org/apache/poi/sl/draw/DrawTexturePaint.java 
b/poi/src/main/java/org/apache/poi/sl/draw/DrawTexturePaint.java
index 66c76bf315..57e282b10d 100644
--- a/poi/src/main/java/org/apache/poi/sl/draw/DrawTexturePaint.java
+++ b/poi/src/main/java/org/apache/poi/sl/draw/DrawTexturePaint.java
@@ -191,45 +191,44 @@ public class DrawTexturePaint extends 
java.awt.TexturePaint {
         PaintStyle.TextureAlignment ta = fill.getAlignment();
         final double alg_x, alg_y;
         final double usr_w = usedBounds.getWidth(), usr_h = 
usedBounds.getHeight();
-        switch (ta == null ? PaintStyle.TextureAlignment.TOP_LEFT : ta) {
-            case BOTTOM:
-                alg_x = (usr_w-img_w)/2;
-                alg_y = usr_h-img_h;
-                break;
-            case BOTTOM_LEFT:
+        alg_y = switch (ta == null ? PaintStyle.TextureAlignment.TOP_LEFT : 
ta) {
+            case BOTTOM -> {
+                alg_x = (usr_w - img_w) / 2;
+                yield usr_h - img_h;
+            }
+            case BOTTOM_LEFT -> {
                 alg_x = 0;
-                alg_y = usr_h-img_h;
-                break;
-            case BOTTOM_RIGHT:
-                alg_x = usr_w-img_w;
-                alg_y = usr_h-img_h;
-                break;
-            case CENTER:
-                alg_x = (usr_w-img_w)/2;
-                alg_y = (usr_h-img_h)/2;
-                break;
-            case LEFT:
+                yield usr_h - img_h;
+            }
+            case BOTTOM_RIGHT -> {
+                alg_x = usr_w - img_w;
+                yield usr_h - img_h;
+            }
+            case CENTER -> {
+                alg_x = (usr_w - img_w) / 2;
+                yield (usr_h - img_h) / 2;
+            }
+            case LEFT -> {
                 alg_x = 0;
-                alg_y = (usr_h-img_h)/2;
-                break;
-            case RIGHT:
-                alg_x = usr_w-img_w;
-                alg_y = (usr_h-img_h)/2;
-                break;
-            case TOP:
-                alg_x = (usr_w-img_w)/2;
-                alg_y = 0;
-                break;
-            default:
-            case TOP_LEFT:
+                yield (usr_h - img_h) / 2;
+            }
+            case RIGHT -> {
+                alg_x = usr_w - img_w;
+                yield (usr_h - img_h) / 2;
+            }
+            case TOP -> {
+                alg_x = (usr_w - img_w) / 2;
+                yield 0;
+            }
+            default -> {
                 alg_x = 0;
-                alg_y = 0;
-                break;
-            case TOP_RIGHT:
-                alg_x = usr_w-img_w;
-                alg_y = 0;
-                break;
-        }
+                yield 0;
+            }
+            case TOP_RIGHT -> {
+                alg_x = usr_w - img_w;
+                yield 0;
+            }
+        };
         xform.translate(alg_x, alg_y);
 
         // Apply additional horizontal/vertical offset after alignment.
diff --git a/poi/src/main/java/org/apache/poi/sl/draw/Drawable.java 
b/poi/src/main/java/org/apache/poi/sl/draw/Drawable.java
index b11397ca4f..9717104983 100644
--- a/poi/src/main/java/org/apache/poi/sl/draw/Drawable.java
+++ b/poi/src/main/java/org/apache/poi/sl/draw/Drawable.java
@@ -34,25 +34,25 @@ public interface Drawable {
         }
 
         public String toString() {
-            switch (intKey()) {
-            case 1: return "DRAW_FACTORY";
-            case 2: return "GROUP_TRANSFORM";
-            case 3: return "IMAGE_RENDERER";
-            case 4: return "TEXT_RENDERING_MODE";
-            case 5: return "GRADIENT_SHAPE";
-            case 6: return "PRESET_GEOMETRY_CACHE";
-            case 7: return "FONT_HANDLER";
-            case 8: return "FONT_FALLBACK";
-            case 9: return "FONT_MAP";
-            case 10: return "GSAVE";
-            case 11: return "GRESTORE";
-            case 12: return "CURRENT_SLIDE";
-            case 13: return "BUFFERED_IMAGE";
-            case 14: return "DEFAULT_CHARSET";
-            case 15: return "EMF_FORCE_HEADER_BOUNDS";
-            case 16: return "CACHE_IMAGE_SOURCE";
-            default: return "UNKNOWN_ID "+intKey();
-            }
+            return switch (intKey()) {
+                case 1 -> "DRAW_FACTORY";
+                case 2 -> "GROUP_TRANSFORM";
+                case 3 -> "IMAGE_RENDERER";
+                case 4 -> "TEXT_RENDERING_MODE";
+                case 5 -> "GRADIENT_SHAPE";
+                case 6 -> "PRESET_GEOMETRY_CACHE";
+                case 7 -> "FONT_HANDLER";
+                case 8 -> "FONT_FALLBACK";
+                case 9 -> "FONT_MAP";
+                case 10 -> "GSAVE";
+                case 11 -> "GRESTORE";
+                case 12 -> "CURRENT_SLIDE";
+                case 13 -> "BUFFERED_IMAGE";
+                case 14 -> "DEFAULT_CHARSET";
+                case 15 -> "EMF_FORCE_HEADER_BOUNDS";
+                case 16 -> "CACHE_IMAGE_SOURCE";
+                default -> "UNKNOWN_ID " + intKey();
+            };
         }
     }
 
diff --git 
a/poi/src/main/java/org/apache/poi/sl/extractor/SlideShowExtractor.java 
b/poi/src/main/java/org/apache/poi/sl/extractor/SlideShowExtractor.java
index b3214a97b8..1ebc8ea89a 100644
--- a/poi/src/main/java/org/apache/poi/sl/extractor/SlideShowExtractor.java
+++ b/poi/src/main/java/org/apache/poi/sl/extractor/SlideShowExtractor.java
@@ -45,7 +45,8 @@ import org.apache.poi.sl.usermodel.TextRun;
 import org.apache.poi.sl.usermodel.TextShape;
 import org.apache.poi.util.Internal;
 import org.apache.poi.util.LocaleUtil;
-import org.apache.poi.util.StringUtil;
+
+import static org.apache.poi.util.StringUtil.equalsIgnoreCase;
 
 /**
  * Common SlideShow extractor
@@ -170,7 +171,7 @@ public class SlideShowExtractor<
             return;
         }
         for (final Shape<S,P> shape : master) {
-            if (shape instanceof TextShape<S,P> ts) {
+            if (shape instanceof TextShape<S, P> ts) {
                 final String text = ts.getText();
                 if (text == null || text.isEmpty() || "*".equals(text)) {
                     continue;
@@ -402,11 +403,12 @@ public class SlideShowExtractor<
     }
     private static boolean filterFonts(Object o, String typeface, Boolean 
italic, Boolean bold) {
         if (o instanceof TextRun tr) {
-            return StringUtil.equalsIgnoreCase(typeface, tr.getFontFamily()) &&
+            return equalsIgnoreCase(typeface, tr.getFontFamily()) &&
                     (italic == null || tr.isItalic() == italic) &&
                     (bold == null || tr.isBold() == bold);
+        } else {
+            return false;
         }
-        return false;
     }
 
     @Override
diff --git 
a/poi/src/main/java/org/apache/poi/sl/usermodel/AutoNumberingScheme.java 
b/poi/src/main/java/org/apache/poi/sl/usermodel/AutoNumberingScheme.java
index 3c4a55d878..f0e73e8b0d 100644
--- a/poi/src/main/java/org/apache/poi/sl/usermodel/AutoNumberingScheme.java
+++ b/poi/src/main/java/org/apache/poi/sl/usermodel/AutoNumberingScheme.java
@@ -125,50 +125,56 @@ public enum AutoNumberingScheme {
     }
 
     public String getDescription() {
-        switch (this) {
-        case alphaLcPeriod          : return "Lowercase Latin character 
followed by a period. Example: a., b., c., ...";
-        case alphaUcPeriod          : return "Uppercase Latin character 
followed by a period. Example: A., B., C., ...";
-        case arabicParenRight       : return "Arabic numeral followed by a 
closing parenthesis. Example: 1), 2), 3), ...";
-        case arabicPeriod           : return "Arabic numeral followed by a 
period. Example: 1., 2., 3., ...";
-        case romanLcParenBoth       : return "Lowercase Roman numeral enclosed 
in parentheses. Example: (i), (ii), (iii), ...";
-        case romanLcParenRight      : return "Lowercase Roman numeral followed 
by a closing parenthesis. Example: i), ii), iii), ...";
-        case romanLcPeriod          : return "Lowercase Roman numeral followed 
by a period. Example: i., ii., iii., ...";
-        case romanUcPeriod          : return "Uppercase Roman numeral followed 
by a period. Example: I., II., III., ...";
-        case alphaLcParenBoth       : return "Lowercase alphabetic character 
enclosed in parentheses. Example: (a), (b), (c), ...";
-        case alphaLcParenRight      : return "Lowercase alphabetic character 
followed by a closing parenthesis. Example: a), b), c), ...";
-        case alphaUcParenBoth       : return "Uppercase alphabetic character 
enclosed in parentheses. Example: (A), (B), (C), ...";
-        case alphaUcParenRight      : return "Uppercase alphabetic character 
followed by a closing parenthesis. Example: A), B), C), ...";
-        case arabicParenBoth        : return "Arabic numeral enclosed in 
parentheses. Example: (1), (2), (3), ...";
-        case arabicPlain            : return "Arabic numeral. Example: 1, 2, 
3, ...";
-        case romanUcParenBoth       : return "Uppercase Roman numeral enclosed 
in parentheses. Example: (I), (II), (III), ...";
-        case romanUcParenRight      : return "Uppercase Roman numeral followed 
by a closing parenthesis. Example: I), II), III), ...";
-        case ea1ChsPlain            : return "Simplified Chinese.";
-        case ea1ChsPeriod           : return "Simplified Chinese with 
single-byte period.";
-        case circleNumDbPlain       : return "Double byte circle numbers.";
-        case circleNumWdWhitePlain  : return "Wingdings white circle numbers.";
-        case circleNumWdBlackPlain  : return "Wingdings black circle numbers.";
-        case ea1ChtPlain            : return "Traditional Chinese.";
-        case ea1ChtPeriod           : return "Traditional Chinese with 
single-byte period.";
-        case arabic1Minus           : return "Bidi Arabic 1 (AraAlpha) with 
ANSI minus symbol.";
-        case arabic2Minus           : return "Bidi Arabic 2 (AraAbjad) with 
ANSI minus symbol.";
-        case hebrew2Minus           : return "Bidi Hebrew 2 with ANSI minus 
symbol.";
-        case ea1JpnKorPlain         : return "Japanese/Korean.";
-        case ea1JpnKorPeriod        : return "Japanese/Korean with single-byte 
period.";
-        case arabicDbPlain          : return "Double-byte Arabic numbers.";
-        case arabicDbPeriod         : return "Double-byte Arabic numbers with 
double-byte period.";
-        case thaiAlphaPeriod        : return "Thai alphabetic character 
followed by a period.";
-        case thaiAlphaParenRight    : return "Thai alphabetic character 
followed by a closing parenthesis.";
-        case thaiAlphaParenBoth     : return "Thai alphabetic character 
enclosed by parentheses.";
-        case thaiNumPeriod          : return "Thai numeral followed by a 
period.";
-        case thaiNumParenRight      : return "Thai numeral followed by a 
closing parenthesis.";
-        case thaiNumParenBoth       : return "Thai numeral enclosed in 
parentheses.";
-        case hindiAlphaPeriod       : return "Hindi alphabetic character 
followed by a period.";
-        case hindiNumPeriod         : return "Hindi numeric character followed 
by a period.";
-        case ea1JpnChsDbPeriod      : return "Japanese with double-byte 
period.";
-        case hindiNumParenRight     : return "Hindi numeric character followed 
by a closing parenthesis.";
-        case hindiAlpha1Period      : return "Hindi alphabetic character 
followed by a period.";
-        default                     : return "Unknown Numbered Scheme";
-        }
+        return switch (this) {
+            case alphaLcPeriod -> "Lowercase Latin character followed by a 
period. Example: a., b., c., ...";
+            case alphaUcPeriod -> "Uppercase Latin character followed by a 
period. Example: A., B., C., ...";
+            case arabicParenRight -> "Arabic numeral followed by a closing 
parenthesis. Example: 1), 2), 3), ...";
+            case arabicPeriod -> "Arabic numeral followed by a period. 
Example: 1., 2., 3., ...";
+            case romanLcParenBoth -> "Lowercase Roman numeral enclosed in 
parentheses. Example: (i), (ii), (iii), ...";
+            case romanLcParenRight ->
+                    "Lowercase Roman numeral followed by a closing 
parenthesis. Example: i), ii), iii), ...";
+            case romanLcPeriod -> "Lowercase Roman numeral followed by a 
period. Example: i., ii., iii., ...";
+            case romanUcPeriod -> "Uppercase Roman numeral followed by a 
period. Example: I., II., III., ...";
+            case alphaLcParenBoth ->
+                    "Lowercase alphabetic character enclosed in parentheses. 
Example: (a), (b), (c), ...";
+            case alphaLcParenRight ->
+                    "Lowercase alphabetic character followed by a closing 
parenthesis. Example: a), b), c), ...";
+            case alphaUcParenBoth ->
+                    "Uppercase alphabetic character enclosed in parentheses. 
Example: (A), (B), (C), ...";
+            case alphaUcParenRight ->
+                    "Uppercase alphabetic character followed by a closing 
parenthesis. Example: A), B), C), ...";
+            case arabicParenBoth -> "Arabic numeral enclosed in parentheses. 
Example: (1), (2), (3), ...";
+            case arabicPlain -> "Arabic numeral. Example: 1, 2, 3, ...";
+            case romanUcParenBoth -> "Uppercase Roman numeral enclosed in 
parentheses. Example: (I), (II), (III), ...";
+            case romanUcParenRight ->
+                    "Uppercase Roman numeral followed by a closing 
parenthesis. Example: I), II), III), ...";
+            case ea1ChsPlain -> "Simplified Chinese.";
+            case ea1ChsPeriod -> "Simplified Chinese with single-byte period.";
+            case circleNumDbPlain -> "Double byte circle numbers.";
+            case circleNumWdWhitePlain -> "Wingdings white circle numbers.";
+            case circleNumWdBlackPlain -> "Wingdings black circle numbers.";
+            case ea1ChtPlain -> "Traditional Chinese.";
+            case ea1ChtPeriod -> "Traditional Chinese with single-byte 
period.";
+            case arabic1Minus -> "Bidi Arabic 1 (AraAlpha) with ANSI minus 
symbol.";
+            case arabic2Minus -> "Bidi Arabic 2 (AraAbjad) with ANSI minus 
symbol.";
+            case hebrew2Minus -> "Bidi Hebrew 2 with ANSI minus symbol.";
+            case ea1JpnKorPlain -> "Japanese/Korean.";
+            case ea1JpnKorPeriod -> "Japanese/Korean with single-byte period.";
+            case arabicDbPlain -> "Double-byte Arabic numbers.";
+            case arabicDbPeriod -> "Double-byte Arabic numbers with 
double-byte period.";
+            case thaiAlphaPeriod -> "Thai alphabetic character followed by a 
period.";
+            case thaiAlphaParenRight -> "Thai alphabetic character followed by 
a closing parenthesis.";
+            case thaiAlphaParenBoth -> "Thai alphabetic character enclosed by 
parentheses.";
+            case thaiNumPeriod -> "Thai numeral followed by a period.";
+            case thaiNumParenRight -> "Thai numeral followed by a closing 
parenthesis.";
+            case thaiNumParenBoth -> "Thai numeral enclosed in parentheses.";
+            case hindiAlphaPeriod -> "Hindi alphabetic character followed by a 
period.";
+            case hindiNumPeriod -> "Hindi numeric character followed by a 
period.";
+            case ea1JpnChsDbPeriod -> "Japanese with double-byte period.";
+            case hindiNumParenRight -> "Hindi numeric character followed by a 
closing parenthesis.";
+            case hindiAlpha1Period -> "Hindi alphabetic character followed by 
a period.";
+            default -> "Unknown Numbered Scheme";
+        };
     }
 
     public String format(int value) {
diff --git 
a/poi/src/main/java/org/apache/poi/ss/format/CellElapsedFormatter.java 
b/poi/src/main/java/org/apache/poi/ss/format/CellElapsedFormatter.java
index 93fc537d12..a350231fc1 100644
--- a/poi/src/main/java/org/apache/poi/ss/format/CellElapsedFormatter.java
+++ b/poi/src/main/java/org/apache/poi/ss/format/CellElapsedFormatter.java
@@ -155,34 +155,24 @@ public class CellElapsedFormatter extends CellFormatter {
     }
 
     private static double factorFor(char type, int len) {
-        switch (type) {
-        case 'h':
-            return HOUR__FACTOR;
-        case 'm':
-            return MIN__FACTOR;
-        case 's':
-            return SEC__FACTOR;
-        case '0':
-            return SEC__FACTOR / Math.pow(10, len);
-        default:
-            throw new IllegalArgumentException(
+        return switch (type) {
+            case 'h' -> HOUR__FACTOR;
+            case 'm' -> MIN__FACTOR;
+            case 's' -> SEC__FACTOR;
+            case '0' -> SEC__FACTOR / Math.pow(10, len);
+            default -> throw new IllegalArgumentException(
                     "Unknown elapsed time spec: " + type);
-        }
+        };
     }
 
     private static double modFor(char type, int len) {
-        switch (type) {
-        case 'h':
-            return 24;
-        case 'm':
-        case 's':
-            return 60;
-        case '0':
-            return Math.pow(10, len);
-        default:
-            throw new IllegalArgumentException(
+        return switch (type) {
+            case 'h' -> 24;
+            case 'm', 's' -> 60;
+            case '0' -> Math.pow(10, len);
+            default -> throw new IllegalArgumentException(
                     "Unknown elapsed time spec: " + type);
-        }
+        };
     }
 
     @Override
diff --git 
a/poi/src/main/java/org/apache/poi/ss/format/CellFormatCondition.java 
b/poi/src/main/java/org/apache/poi/ss/format/CellFormatCondition.java
index b482d822d9..11db964521 100644
--- a/poi/src/main/java/org/apache/poi/ss/format/CellFormatCondition.java
+++ b/poi/src/main/java/org/apache/poi/ss/format/CellFormatCondition.java
@@ -64,54 +64,47 @@ public abstract class CellFormatCondition {
 
         final double c = Double.parseDouble(constStr);
 
-        switch (test) {
-        case LT:
-            return new CellFormatCondition() {
+        return switch (test) {
+            case LT -> new CellFormatCondition() {
                 @Override
                 public boolean pass(double value) {
                     return value < c;
                 }
             };
-        case LE:
-            return new CellFormatCondition() {
+            case LE -> new CellFormatCondition() {
                 @Override
                 public boolean pass(double value) {
                     return value <= c;
                 }
             };
-        case GT:
-            return new CellFormatCondition() {
+            case GT -> new CellFormatCondition() {
                 @Override
                 public boolean pass(double value) {
                     return value > c;
                 }
             };
-        case GE:
-            return new CellFormatCondition() {
+            case GE -> new CellFormatCondition() {
                 @Override
                 public boolean pass(double value) {
                     return value >= c;
                 }
             };
-        case EQ:
-            return new CellFormatCondition() {
+            case EQ -> new CellFormatCondition() {
                 @Override
                 public boolean pass(double value) {
                     return value == c;
                 }
             };
-        case NE:
-            return new CellFormatCondition() {
+            case NE -> new CellFormatCondition() {
                 @Override
                 public boolean pass(double value) {
                     return value != c;
                 }
             };
-        default:
-            throw new IllegalArgumentException(
+            default -> throw new IllegalArgumentException(
                     "Cannot create for test number " + test + "(\"" + opString 
+
                             "\")");
-        }
+        };
     }
 
     /**
diff --git a/poi/src/main/java/org/apache/poi/ss/format/CellFormatPart.java 
b/poi/src/main/java/org/apache/poi/ss/format/CellFormatPart.java
index 11e1b770b7..3b2bdc3537 100644
--- a/poi/src/main/java/org/apache/poi/ss/format/CellFormatPart.java
+++ b/poi/src/main/java/org/apache/poi/ss/format/CellFormatPart.java
@@ -573,24 +573,15 @@ public class CellFormatPart {
             if (!part.isEmpty()) {
                 String repl = partHandler.handlePart(m, part, type, fmt);
                 if (repl == null) {
-                    switch (part.charAt(0)) {
-                    case '\"':
-                        repl = quoteSpecial(part.substring(1,
+                    repl = switch (part.charAt(0)) {
+                        case '\"' -> quoteSpecial(part.substring(1,
                                 part.length() - 1), type);
-                        break;
-                    case '\\':
-                        repl = quoteSpecial(part.substring(1), type);
-                        break;
-                    case '_':
-                        repl = " ";
-                        break;
-                    case '*': //!! We don't do this for real, we just put in 3 
of them
-                        repl = expandChar(part);
-                        break;
-                    default:
-                        repl = part;
-                        break;
-                    }
+                        case '\\' -> quoteSpecial(part.substring(1), type);
+                        case '_' -> " ";
+                        case '*' -> //!! We don't do this for real, we just 
put in 3 of them
+                                expandChar(part);
+                        default -> part;
+                    };
                 }
                 m.appendReplacement(fmt, Matcher.quoteReplacement(repl));
             }
diff --git 
a/poi/src/main/java/org/apache/poi/ss/formula/BaseFormulaEvaluator.java 
b/poi/src/main/java/org/apache/poi/ss/formula/BaseFormulaEvaluator.java
index f7d6157c44..5f6560f40d 100644
--- a/poi/src/main/java/org/apache/poi/ss/formula/BaseFormulaEvaluator.java
+++ b/poi/src/main/java/org/apache/poi/ss/formula/BaseFormulaEvaluator.java
@@ -100,22 +100,15 @@ public abstract class BaseFormulaEvaluator implements 
FormulaEvaluator, Workbook
             return null;
         }
 
-        switch (cell.getCellType()) {
-            case BOOLEAN:
-                return CellValue.valueOf(cell.getBooleanCellValue());
-            case ERROR:
-                return CellValue.getError(cell.getErrorCellValue());
-            case FORMULA:
-                return evaluateFormulaCellValue(cell);
-            case NUMERIC:
-                return new CellValue(cell.getNumericCellValue());
-            case STRING:
-                return new 
CellValue(cell.getRichStringCellValue().getString());
-            case BLANK:
-                return null;
-            default:
-                throw new IllegalStateException("Bad cell type (" + 
cell.getCellType() + ")");
-        }
+        return switch (cell.getCellType()) {
+            case BOOLEAN -> CellValue.valueOf(cell.getBooleanCellValue());
+            case ERROR -> CellValue.getError(cell.getErrorCellValue());
+            case FORMULA -> evaluateFormulaCellValue(cell);
+            case NUMERIC -> new CellValue(cell.getNumericCellValue());
+            case STRING -> new 
CellValue(cell.getRichStringCellValue().getString());
+            case BLANK -> null;
+            default -> throw new IllegalStateException("Bad cell type (" + 
cell.getCellType() + ")");
+        };
     }
 
     /**
diff --git 
a/poi/src/main/java/org/apache/poi/ss/formula/OperandClassTransformer.java 
b/poi/src/main/java/org/apache/poi/ss/formula/OperandClassTransformer.java
index 786181c6cd..95b40f9523 100644
--- a/poi/src/main/java/org/apache/poi/ss/formula/OperandClassTransformer.java
+++ b/poi/src/main/java/org/apache/poi/ss/formula/OperandClassTransformer.java
@@ -66,23 +66,13 @@ final class OperandClassTransformer {
      * token to set its operand class.
      */
     public void transformFormula(ParseNode rootNode) {
-        byte rootNodeOperandClass;
-        switch (_formulaType) {
-            case CELL:
-                rootNodeOperandClass = Ptg.CLASS_VALUE;
-                break;
-            case ARRAY:
-                rootNodeOperandClass = Ptg.CLASS_ARRAY;
-                break;
-            case NAMEDRANGE:
-            case DATAVALIDATION_LIST:
-                rootNodeOperandClass = Ptg.CLASS_REF;
-                break;
-            default:
-                throw new IllegalStateException("Incomplete code - formula 
type ("
-                        + _formulaType + ") not supported yet");
-
-        }
+        byte rootNodeOperandClass = switch (_formulaType) {
+            case CELL -> Ptg.CLASS_VALUE;
+            case ARRAY -> Ptg.CLASS_ARRAY;
+            case NAMEDRANGE, DATAVALIDATION_LIST -> Ptg.CLASS_REF;
+            default -> throw new IllegalStateException("Incomplete code - 
formula type ("
+                    + _formulaType + ") not supported yet");
+        };
         transformNode(rootNode, rootNodeOperandClass, false);
     }
 
@@ -200,27 +190,26 @@ final class OperandClassTransformer {
         byte defaultReturnOperandClass = afp.getDefaultOperandClass();
 
         if (callerForceArrayFlag) {
-            switch (defaultReturnOperandClass) {
-                case Ptg.CLASS_REF:
+            localForceArrayFlag = switch (defaultReturnOperandClass) {
+                case Ptg.CLASS_REF -> {
                     if (desiredOperandClass == Ptg.CLASS_REF) {
                         afp.setClass(Ptg.CLASS_REF);
                     } else {
                         afp.setClass(Ptg.CLASS_ARRAY);
                     }
-                    localForceArrayFlag = false;
-                    break;
-                case Ptg.CLASS_ARRAY:
+                    yield false;
+                }
+                case Ptg.CLASS_ARRAY -> {
                     afp.setClass(Ptg.CLASS_ARRAY);
-                    localForceArrayFlag = false;
-                    break;
-                case Ptg.CLASS_VALUE:
+                    yield false;
+                }
+                case Ptg.CLASS_VALUE -> {
                     afp.setClass(Ptg.CLASS_ARRAY);
-                    localForceArrayFlag = true;
-                    break;
-                default:
-                    throw new IllegalStateException("Unexpected operand class 
("
-                            + defaultReturnOperandClass + ")");
-            }
+                    yield true;
+                }
+                default -> throw new IllegalStateException("Unexpected operand 
class ("
+                        + defaultReturnOperandClass + ")");
+            };
         } else {
             if (defaultReturnOperandClass == desiredOperandClass) {
                 localForceArrayFlag = false;
diff --git a/poi/src/main/java/org/apache/poi/ss/formula/WorkbookEvaluator.java 
b/poi/src/main/java/org/apache/poi/ss/formula/WorkbookEvaluator.java
index 29d45fff9d..2b081fadb9 100644
--- a/poi/src/main/java/org/apache/poi/ss/formula/WorkbookEvaluator.java
+++ b/poi/src/main/java/org/apache/poi/ss/formula/WorkbookEvaluator.java
@@ -274,26 +274,15 @@ public final class WorkbookEvaluator {
             } catch (RuntimeException re) {
                 if (re.getCause() instanceof WorkbookNotFoundException && 
_ignoreMissingWorkbooks) {
                     LOG.atInfo().log("{} - Continuing with cached value!", 
re.getCause().getMessage());
-                    switch (srcCell.getCachedFormulaResultType()) {
-                        case NUMERIC:
-                            result = new 
NumberEval(srcCell.getNumericCellValue());
-                            break;
-                        case STRING:
-                            result = new 
StringEval(srcCell.getStringCellValue());
-                            break;
-                        case BLANK:
-                            result = BlankEval.instance;
-                            break;
-                        case BOOLEAN:
-                            result = 
BoolEval.valueOf(srcCell.getBooleanCellValue());
-                            break;
-                        case ERROR:
-                            result = 
ErrorEval.valueOf(srcCell.getErrorCellValue());
-                            break;
-                        case FORMULA:
-                        default:
-                            throw new IllegalStateException("Unexpected cell 
type '" + srcCell.getCellType() + "' found!");
-                    }
+                    result = switch (srcCell.getCachedFormulaResultType()) {
+                        case NUMERIC -> new 
NumberEval(srcCell.getNumericCellValue());
+                        case STRING -> new 
StringEval(srcCell.getStringCellValue());
+                        case BLANK -> BlankEval.instance;
+                        case BOOLEAN -> 
BoolEval.valueOf(srcCell.getBooleanCellValue());
+                        case ERROR -> 
ErrorEval.valueOf(srcCell.getErrorCellValue());
+                        default ->
+                                throw new IllegalStateException("Unexpected 
cell type '" + srcCell.getCellType() + "' found!");
+                    };
                 } else {
                     throw re;
                 }
@@ -350,20 +339,14 @@ public final class WorkbookEvaluator {
             return BlankEval.instance;
         }
         CellType cellType = cell.getCellType();
-        switch (cellType) {
-            case NUMERIC:
-                return new NumberEval(cell.getNumericCellValue());
-            case STRING:
-                return new StringEval(cell.getStringCellValue());
-            case BOOLEAN:
-                return BoolEval.valueOf(cell.getBooleanCellValue());
-            case BLANK:
-                return BlankEval.instance;
-            case ERROR:
-                return ErrorEval.valueOf(cell.getErrorCellValue());
-            default:
-                throw new IllegalStateException("Unexpected cell type (" + 
cellType + ")");
-        }
+        return switch (cellType) {
+            case NUMERIC -> new NumberEval(cell.getNumericCellValue());
+            case STRING -> new StringEval(cell.getStringCellValue());
+            case BOOLEAN -> BoolEval.valueOf(cell.getBooleanCellValue());
+            case BLANK -> BlankEval.instance;
+            case ERROR -> ErrorEval.valueOf(cell.getErrorCellValue());
+            default -> throw new IllegalStateException("Unexpected cell type 
(" + cellType + ")");
+        };
 
     }
 
@@ -376,7 +359,6 @@ public final class WorkbookEvaluator {
         if (dbgEvaluationOutputForNextEval) {
             // first evaluation call when output is desired, so iit. this 
evaluator instance
             dbgEvaluationOutputIndent = 1;
-            dbgEvaluationOutputForNextEval = true;
         }
         if (dbgEvaluationOutputIndent > 0) {
             // init. indent string to needed spaces (create as substring from 
very long space-only string;
@@ -667,9 +649,8 @@ public final class WorkbookEvaluator {
     private ValueEval getEvalForPtg(Ptg ptg, OperationEvaluationContext ec) {
         //  consider converting all these (ptg instanceof XxxPtg) expressions 
to (ptg.getClass() == XxxPtg.class)
 
-        if (ptg instanceof NamePtg) {
+        if (ptg instanceof NamePtg namePtg) {
             // Named ranges, macro functions
-            NamePtg namePtg = (NamePtg) ptg;
             EvaluationName nameRecord = _workbook.getName(namePtg);
             return getEvalForNameRecord(nameRecord, ec);
         }
@@ -716,17 +697,14 @@ public final class WorkbookEvaluator {
         if (ptg instanceof Area3DPxg) {
             return ec.getArea3DEval((Area3DPxg) ptg);
         }
-        if (ptg instanceof RefPtg) {
-            RefPtg rptg = (RefPtg) ptg;
+        if (ptg instanceof RefPtg rptg) {
             return ec.getRefEval(rptg.getRow(), rptg.getColumn());
         }
-        if (ptg instanceof AreaPtg) {
-            AreaPtg aptg = (AreaPtg) ptg;
+        if (ptg instanceof AreaPtg aptg) {
             return ec.getAreaEval(aptg.getFirstRow(), aptg.getFirstColumn(), 
aptg.getLastRow(), aptg.getLastColumn());
         }
 
-        if (ptg instanceof ArrayPtg) {
-            ArrayPtg aptg = (ArrayPtg) ptg;
+        if (ptg instanceof ArrayPtg aptg) {
             return ec.getAreaValueEval(0, 0, aptg.getRowCount() - 1, 
aptg.getColumnCount() - 1, aptg.getTokenArrayValues());
         }
 
diff --git 
a/poi/src/main/java/org/apache/poi/ss/formula/eval/forked/ForkedEvaluationCell.java
 
b/poi/src/main/java/org/apache/poi/ss/formula/eval/forked/ForkedEvaluationCell.java
index cd3294f550..17de08b9d3 100644
--- 
a/poi/src/main/java/org/apache/poi/ss/formula/eval/forked/ForkedEvaluationCell.java
+++ 
b/poi/src/main/java/org/apache/poi/ss/formula/eval/forked/ForkedEvaluationCell.java
@@ -85,14 +85,15 @@ final class ForkedEvaluationCell implements EvaluationCell {
         }
         throw new IllegalArgumentException("Unexpected value class (" + 
cls.getName() + ")");
     }
+
     public void copyValue(Cell destCell) {
         switch (_cellType) {
-            case BLANK:   destCell.setBlank();                           
return;
-            case NUMERIC: destCell.setCellValue(_numberValue);           
return;
-            case BOOLEAN: destCell.setCellValue(_booleanValue);          
return;
-            case STRING:  destCell.setCellValue(_stringValue);           
return;
-            case ERROR:   destCell.setCellErrorValue((byte)_errorValue); 
return;
-            default: throw new IllegalStateException("Unexpected data type (" 
+ _cellType + ")");
+            case BLANK -> destCell.setBlank();
+            case NUMERIC -> destCell.setCellValue(_numberValue);
+            case BOOLEAN -> destCell.setCellValue(_booleanValue);
+            case STRING -> destCell.setCellValue(_stringValue);
+            case ERROR -> destCell.setCellErrorValue((byte)_errorValue);
+            default -> throw new IllegalStateException("Unexpected data type 
(" + _cellType + ")");
         }
     }
 
diff --git 
a/poi/src/main/java/org/apache/poi/ss/formula/eval/forked/ForkedEvaluator.java 
b/poi/src/main/java/org/apache/poi/ss/formula/eval/forked/ForkedEvaluator.java
index a78c636fa8..5c7fe367b0 100644
--- 
a/poi/src/main/java/org/apache/poi/ss/formula/eval/forked/ForkedEvaluator.java
+++ 
b/poi/src/main/java/org/apache/poi/ss/formula/eval/forked/ForkedEvaluator.java
@@ -95,22 +95,15 @@ public final class ForkedEvaluator {
     public ValueEval evaluate(String sheetName, int rowIndex, int columnIndex) 
{
         EvaluationCell cell = _sewb.getEvaluationCell(sheetName, rowIndex, 
columnIndex);
 
-        switch (cell.getCellType()) {
-            case BOOLEAN:
-                return BoolEval.valueOf(cell.getBooleanCellValue());
-            case ERROR:
-                return ErrorEval.valueOf(cell.getErrorCellValue());
-            case FORMULA:
-                return _evaluator.evaluate(cell);
-            case NUMERIC:
-                return new NumberEval(cell.getNumericCellValue());
-            case STRING:
-                return new StringEval(cell.getStringCellValue());
-            case BLANK:
-                return null;
-            default:
-                throw new IllegalStateException("Bad cell type (" + 
cell.getCellType() + ")");
-        }
+        return switch (cell.getCellType()) {
+            case BOOLEAN -> BoolEval.valueOf(cell.getBooleanCellValue());
+            case ERROR -> ErrorEval.valueOf(cell.getErrorCellValue());
+            case FORMULA -> _evaluator.evaluate(cell);
+            case NUMERIC -> new NumberEval(cell.getNumericCellValue());
+            case STRING -> new StringEval(cell.getStringCellValue());
+            case BLANK -> null;
+            default -> throw new IllegalStateException("Bad cell type (" + 
cell.getCellType() + ")");
+        };
     }
     /**
      * Coordinates several formula evaluators together so that formulas that 
involve external
diff --git a/poi/src/main/java/org/apache/poi/ss/util/PaneInformation.java 
b/poi/src/main/java/org/apache/poi/ss/util/PaneInformation.java
index 53520307e4..be11c903d7 100644
--- a/poi/src/main/java/org/apache/poi/ss/util/PaneInformation.java
+++ b/poi/src/main/java/org/apache/poi/ss/util/PaneInformation.java
@@ -105,18 +105,13 @@ public class PaneInformation
      * @since 5.2.3
      */
     public PaneType getActivePaneType() {
-        switch (activePane) {
-            case PANE_LOWER_RIGHT:
-                return PaneType.LOWER_RIGHT;
-            case PANE_UPPER_RIGHT:
-                return PaneType.UPPER_RIGHT;
-            case PANE_LOWER_LEFT:
-                return PaneType.LOWER_LEFT;
-            case PANE_UPPER_LEFT:
-                return PaneType.UPPER_LEFT;
-            default:
-                return null;
-        }
+        return switch (activePane) {
+            case PANE_LOWER_RIGHT -> PaneType.LOWER_RIGHT;
+            case PANE_UPPER_RIGHT -> PaneType.UPPER_RIGHT;
+            case PANE_LOWER_LEFT -> PaneType.LOWER_LEFT;
+            case PANE_UPPER_LEFT -> PaneType.UPPER_LEFT;
+            default -> null;
+        };
     }
 
     /** Returns true if this is a Freeze pane, false if it is a split pane.


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


Reply via email to