File tree Expand file tree Collapse file tree 1 file changed +9
-14
lines changed
libs/core/src/main/java/org/opensearch/core/xcontent Expand file tree Collapse file tree 1 file changed +9
-14
lines changed Original file line number Diff line number Diff line change @@ -206,20 +206,15 @@ public Number numberValue() throws IOException {
206
206
@ Override
207
207
public NumberType numberType () throws IOException {
208
208
Number number = numberValue ();
209
- if (number instanceof Integer ) {
210
- return NumberType .INT ;
211
- } else if (number instanceof BigInteger ) {
212
- return NumberType .BIG_INTEGER ;
213
- } else if (number instanceof Long ) {
214
- return NumberType .LONG ;
215
- } else if (number instanceof Float ) {
216
- return NumberType .FLOAT ;
217
- } else if (number instanceof Double ) {
218
- return NumberType .DOUBLE ;
219
- } else if (number instanceof BigDecimal ) {
220
- return NumberType .BIG_DECIMAL ;
221
- }
222
- throw new IllegalStateException ("No matching token for number_type [" + number .getClass () + "]" );
209
+ return switch (number ) {
210
+ case Integer ignored -> NumberType .INT ;
211
+ case BigInteger ignored -> NumberType .BIG_INTEGER ;
212
+ case Long ignored -> NumberType .LONG ;
213
+ case Float ignored -> NumberType .FLOAT ;
214
+ case Double ignored -> NumberType .DOUBLE ;
215
+ case BigDecimal ignored -> NumberType .BIG_DECIMAL ;
216
+ default -> throw new IllegalStateException ("No matching token for number_type [" + number .getClass () + "]" );
217
+ };
223
218
}
224
219
225
220
@ Override
You can’t perform that action at this time.
0 commit comments