From c4395d6483a1fa5bd2da060ccd31418ba7906820 Mon Sep 17 00:00:00 2001 From: Guian Gumpac Date: Mon, 13 Mar 2023 11:26:01 -0700 Subject: [PATCH] Added constant for supported formats Signed-off-by: Guian Gumpac --- .../org/opensearch/sql/sql/domain/SQLQueryRequest.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/sql/src/main/java/org/opensearch/sql/sql/domain/SQLQueryRequest.java b/sql/src/main/java/org/opensearch/sql/sql/domain/SQLQueryRequest.java index 3e64e7a46b..7ef3901aa1 100644 --- a/sql/src/main/java/org/opensearch/sql/sql/domain/SQLQueryRequest.java +++ b/sql/src/main/java/org/opensearch/sql/sql/domain/SQLQueryRequest.java @@ -8,6 +8,7 @@ import com.google.common.base.Strings; import com.google.common.collect.ImmutableSet; +import java.util.Arrays; import java.util.Collections; import java.util.Locale; import java.util.Map; @@ -33,6 +34,7 @@ public class SQLQueryRequest { "query", "fetch_size", "parameters"); private static final String QUERY_PARAMS_FORMAT = "format"; private static final String QUERY_PARAMS_SANITIZE = "sanitize"; + private static final String[] SUPPORTED_FORMATS = {"jdbc", "csv", "raw", "json"}; /** * JSON payload in REST request. @@ -122,10 +124,7 @@ private boolean isFetchSizeZeroIfPresent() { private boolean isSupportedFormat() { return Strings.isNullOrEmpty(format) - || "jdbc".equalsIgnoreCase(format) - || "csv".equalsIgnoreCase(format) - || "raw".equalsIgnoreCase(format) - || "json".equalsIgnoreCase(format); + || Arrays.stream(SUPPORTED_FORMATS).anyMatch(format::equalsIgnoreCase); } private String getFormat(Map params) {