Skip to content

Commit 12c7f3f

Browse files
oschwaldclaude
andcommitted
Convert switch statements to expressions
Converts the decodeBoolean method switch statement to use Java 17 switch expressions, making the code more concise and eliminating the need for break statements. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 36e7354 commit 12c7f3f

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

src/main/java/com/maxmind/db/Decoder.java

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -259,16 +259,13 @@ private float decodeFloat(int size) throws InvalidDatabaseException {
259259

260260
private static boolean decodeBoolean(int size)
261261
throws InvalidDatabaseException {
262-
switch (size) {
263-
case 0:
264-
return false;
265-
case 1:
266-
return true;
267-
default:
268-
throw new InvalidDatabaseException(
269-
"The MaxMind DB file's data section contains bad data: "
270-
+ "invalid size of boolean.");
271-
}
262+
return switch (size) {
263+
case 0 -> false;
264+
case 1 -> true;
265+
default -> throw new InvalidDatabaseException(
266+
"The MaxMind DB file's data section contains bad data: "
267+
+ "invalid size of boolean.");
268+
};
272269
}
273270

274271
private <T, V> List<V> decodeArray(

0 commit comments

Comments
 (0)