From 09f4339c57024b9b931afc07d12acf5545639826 Mon Sep 17 00:00:00 2001 From: Darshit Chanpura Date: Wed, 27 Sep 2023 17:24:08 -0400 Subject: [PATCH] Reverts changes made to Settings class Signed-off-by: Darshit Chanpura --- .../opensearch/common/settings/Settings.java | 59 +------------------ 1 file changed, 3 insertions(+), 56 deletions(-) diff --git a/server/src/main/java/org/opensearch/common/settings/Settings.java b/server/src/main/java/org/opensearch/common/settings/Settings.java index 230eb5499935c..e4dec71eba0a3 100644 --- a/server/src/main/java/org/opensearch/common/settings/Settings.java +++ b/server/src/main/java/org/opensearch/common/settings/Settings.java @@ -38,7 +38,6 @@ import org.opensearch.Version; import org.opensearch.common.Booleans; import org.opensearch.common.SetOnce; -import org.opensearch.common.annotation.PublicApi; import org.opensearch.common.logging.DeprecationLogger; import org.opensearch.common.logging.LogConfigurator; import org.opensearch.common.unit.MemorySizeValue; @@ -96,9 +95,8 @@ /** * An immutable settings implementation. * - * @opensearch.api + * @opensearch.internal */ -@PublicApi(since = "1.0.0") public final class Settings implements ToXContentFragment { public static final Settings EMPTY = new Builder().build(); @@ -270,21 +268,6 @@ public String get(String setting, String defaultValue) { return retVal == null ? defaultValue : retVal; } - /** - * Returns a setting value based on the setting key. - */ - public Settings getNestedSettings(String key) { - return (Settings) settings.get(key); - } - - /** - * Returns a setting value based on the setting key. - */ - public List getNestedListOfSettings(String key) { - return (List) settings.get(key); - } - - /** * Returns the setting value (as float) associated with the setting key. If it does not exists, * returns the default value provided. @@ -681,7 +664,6 @@ private static void fromXContent(XContentParser parser, StringBuilder keyBuilder fromXContent(parser, keyBuilder, builder, allowNullValues); } else if (parser.currentToken() == XContentParser.Token.START_ARRAY) { List list = new ArrayList<>(); - List listOfObjects = new ArrayList<>(); while (parser.nextToken() != XContentParser.Token.END_ARRAY) { if (parser.currentToken() == XContentParser.Token.VALUE_STRING) { list.add(parser.text()); @@ -690,19 +672,12 @@ private static void fromXContent(XContentParser parser, StringBuilder keyBuilder } else if (parser.currentToken() == XContentParser.Token.VALUE_BOOLEAN) { list.add(String.valueOf(parser.text())); } else { - listOfObjects.add(fromXContent(parser, true, false)); - //throw new IllegalStateException("only value lists are allowed in serialized settings"); + throw new IllegalStateException("only value lists are allowed in serialized settings"); } } String key = keyBuilder.toString(); validateValue(key, list, parser, allowNullValues); builder.putList(key, list); - if (!listOfObjects.isEmpty()) { - builder.putListOfObjects(key, listOfObjects); - } - if (!list.isEmpty() && !listOfObjects.isEmpty()) { - throw new IllegalStateException("list cannot contain both values and objects"); - } } else if (parser.currentToken() == XContentParser.Token.VALUE_NULL) { String key = keyBuilder.toString(); validateValue(key, null, parser, allowNullValues); @@ -775,9 +750,8 @@ public Set keySet() { * settings implementation. Use {@link Settings#builder()} in order to * construct it. * - * @opensearch.api + * @opensearch.internal */ - @PublicApi(since = "1.0.0") public static class Builder { public static final Settings EMPTY_SETTINGS = new Builder().build(); @@ -809,20 +783,6 @@ public String get(String key) { return Settings.toString(map.get(key)); } - /** - * Returns a setting value based on the setting key. - */ - public Settings getNestedSettings(String key) { - return (Settings) map.get(key); - } - - /** - * Returns a setting value based on the setting key. - */ - public List getNestedListOfSettings(String key) { - return (List) map.get(key); - } - /** Return the current secure settings, or {@code null} if none have been set. */ public SecureSettings getSecureSettings() { return secureSettings.get(); @@ -1060,19 +1020,6 @@ public Builder putList(String setting, List values) { return this; } - /** - * Sets the setting with the provided setting key and a list of values. - * - * @param setting The setting key - * @param values The values - * @return The builder - */ - public Builder putListOfObjects(String setting, List values) { - remove(setting); - map.put(setting, new ArrayList<>(values)); - return this; - } - /** * Sets all the provided settings including secure settings */