Skip to content

Commit

Permalink
refactored method to use parseBoolean and parseFloat methods
Browse files Browse the repository at this point in the history
  • Loading branch information
martinpkr committed May 31, 2024
1 parent d953050 commit 2c0cc77
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.opensearch.client.Client;
import org.opensearch.common.Booleans;
import org.opensearch.common.io.Streams;
import org.opensearch.common.xcontent.LoggingDeprecationHandler;
import org.opensearch.common.xcontent.XContentHelper;
Expand Down Expand Up @@ -488,9 +489,9 @@ public static <T> T parseIfExists(Map<String, Object> inputs, String key, Class<

Object value = inputs.get(key);
if (type == Boolean.class) {
return type.cast(Boolean.valueOf(value.toString()));
return type.cast(Booleans.parseBoolean(value.toString()));
} else if (type == Float.class) {
return type.cast(Float.valueOf(value.toString()));
return type.cast(Float.parseFloat(value.toString()));
} else {
throw new IllegalArgumentException("Unsupported type: " + type);
}
Expand Down

0 comments on commit 2c0cc77

Please sign in to comment.