From 06f564bb1467ace3b386b5a360968ac48b5c524f Mon Sep 17 00:00:00 2001 From: Soy Authors Date: Tue, 16 Sep 2025 10:27:12 -0700 Subject: [PATCH] Refactoring to use switch expressions. PiperOrigin-RevId: 807748585 --- .../template/soy/types/SoyProtoType.java | 39 +++++++------------ 1 file changed, 13 insertions(+), 26 deletions(-) diff --git a/java/src/com/google/template/soy/types/SoyProtoType.java b/java/src/com/google/template/soy/types/SoyProtoType.java index 5aef8662bc..a24a228479 100644 --- a/java/src/com/google/template/soy/types/SoyProtoType.java +++ b/java/src/com/google/template/soy/types/SoyProtoType.java @@ -88,15 +88,11 @@ protected SoyType visitLongAsInt() { return SoyTypes.GBIGINT_OR_NUMBER_FOR_MIGRATION; } - switch (int64Mode) { - case FORCE_STRING: - return StringType.getInstance(); - case FORCE_GBIGINT: - return GbigintType.getInstance(); - case FOLLOW_JS_TYPE: - return IntType.getInstance(); - } - throw new AssertionError(); + return switch (int64Mode) { + case FORCE_STRING -> StringType.getInstance(); + case FORCE_GBIGINT -> GbigintType.getInstance(); + case FOLLOW_JS_TYPE -> IntType.getInstance(); + }; } @Override @@ -110,14 +106,10 @@ protected SoyType visitUnsignedLongAsString() { return SoyTypes.GBIGINT_OR_STRING_FOR_MIGRATION; } - switch (int64Mode) { - case FORCE_GBIGINT: - return GbigintType.getInstance(); - case FORCE_STRING: - case FOLLOW_JS_TYPE: - return StringType.getInstance(); - } - throw new AssertionError(); + return switch (int64Mode) { + case FORCE_GBIGINT -> GbigintType.getInstance(); + case FORCE_STRING, FOLLOW_JS_TYPE -> StringType.getInstance(); + }; } @Override @@ -126,15 +118,10 @@ protected SoyType visitLongAsString() { return SoyTypes.GBIGINT_OR_STRING_FOR_MIGRATION; } - switch (int64Mode) { - case FORCE_GBIGINT: - return GbigintType.getInstance(); - - case FORCE_STRING: - case FOLLOW_JS_TYPE: - return StringType.getInstance(); - } - throw new AssertionError(); + return switch (int64Mode) { + case FORCE_GBIGINT -> GbigintType.getInstance(); + case FORCE_STRING, FOLLOW_JS_TYPE -> StringType.getInstance(); + }; } @Override