From 029c3b5e1370706b850f772fb494171a7259e687 Mon Sep 17 00:00:00 2001 From: mrhbj <1825636423@qq.com> Date: Wed, 11 Sep 2024 15:46:48 +0800 Subject: [PATCH] Modernize switch statements in FST (#13756) --- .../java/org/apache/lucene/util/fst/FST.java | 20 +++++++------------ 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/lucene/core/src/java/org/apache/lucene/util/fst/FST.java b/lucene/core/src/java/org/apache/lucene/util/fst/FST.java index ead90dca24c..725ec7bcedd 100644 --- a/lucene/core/src/java/org/apache/lucene/util/fst/FST.java +++ b/lucene/core/src/java/org/apache/lucene/util/fst/FST.java @@ -481,19 +481,13 @@ public final class FST implements Accountable { } INPUT_TYPE inputType; final byte t = metaIn.readByte(); - switch (t) { - case 0: - inputType = INPUT_TYPE.BYTE1; - break; - case 1: - inputType = INPUT_TYPE.BYTE2; - break; - case 2: - inputType = INPUT_TYPE.BYTE4; - break; - default: - throw new CorruptIndexException("invalid input type " + t, metaIn); - } + inputType = + switch (t) { + case 0 -> INPUT_TYPE.BYTE1; + case 1 -> INPUT_TYPE.BYTE2; + case 2 -> INPUT_TYPE.BYTE4; + default -> throw new CorruptIndexException("invalid input type " + t, metaIn); + }; long startNode = metaIn.readVLong(); long numBytes = metaIn.readVLong(); return new FSTMetadata<>(inputType, outputs, emptyOutput, startNode, version, numBytes);