Skip to content

Commit c58d896

Browse files
Soy Authorscopybara-github
authored andcommitted
Refactoring to use switch expressions.
PiperOrigin-RevId: 807748585
1 parent a97c4dc commit c58d896

File tree

1 file changed

+13
-26
lines changed

1 file changed

+13
-26
lines changed

java/src/com/google/template/soy/types/SoyProtoType.java

Lines changed: 13 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -88,15 +88,11 @@ protected SoyType visitLongAsInt() {
8888
return SoyTypes.GBIGINT_OR_NUMBER_FOR_MIGRATION;
8989
}
9090

91-
switch (int64Mode) {
92-
case FORCE_STRING:
93-
return StringType.getInstance();
94-
case FORCE_GBIGINT:
95-
return GbigintType.getInstance();
96-
case FOLLOW_JS_TYPE:
97-
return IntType.getInstance();
98-
}
99-
throw new AssertionError();
91+
return switch (int64Mode) {
92+
case FORCE_STRING -> StringType.getInstance();
93+
case FORCE_GBIGINT -> GbigintType.getInstance();
94+
case FOLLOW_JS_TYPE -> IntType.getInstance();
95+
};
10096
}
10197

10298
@Override
@@ -110,14 +106,10 @@ protected SoyType visitUnsignedLongAsString() {
110106
return SoyTypes.GBIGINT_OR_STRING_FOR_MIGRATION;
111107
}
112108

113-
switch (int64Mode) {
114-
case FORCE_GBIGINT:
115-
return GbigintType.getInstance();
116-
case FORCE_STRING:
117-
case FOLLOW_JS_TYPE:
118-
return StringType.getInstance();
119-
}
120-
throw new AssertionError();
109+
return switch (int64Mode) {
110+
case FORCE_GBIGINT -> GbigintType.getInstance();
111+
case FORCE_STRING, FOLLOW_JS_TYPE -> StringType.getInstance();
112+
};
121113
}
122114

123115
@Override
@@ -126,15 +118,10 @@ protected SoyType visitLongAsString() {
126118
return SoyTypes.GBIGINT_OR_STRING_FOR_MIGRATION;
127119
}
128120

129-
switch (int64Mode) {
130-
case FORCE_GBIGINT:
131-
return GbigintType.getInstance();
132-
133-
case FORCE_STRING:
134-
case FOLLOW_JS_TYPE:
135-
return StringType.getInstance();
136-
}
137-
throw new AssertionError();
121+
return switch (int64Mode) {
122+
case FORCE_GBIGINT -> GbigintType.getInstance();
123+
case FORCE_STRING, FOLLOW_JS_TYPE -> StringType.getInstance();
124+
};
138125
}
139126

140127
@Override

0 commit comments

Comments
 (0)