Replace `s -> s` by `Function.identity()`
This commit is contained in:
parent
c103e40e72
commit
3f71c1d6a5
|
@ -35,6 +35,7 @@ import java.util.HashSet;
|
|||
import java.util.List;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.Function;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -45,11 +46,11 @@ public class NetworkService extends AbstractComponent {
|
|||
public static final String DEFAULT_NETWORK_HOST = "_local_";
|
||||
|
||||
public static final Setting<List<String>> GLOBAL_NETWORK_HOST_SETTING =
|
||||
Setting.listSetting("network.host", Arrays.asList(DEFAULT_NETWORK_HOST), s -> s, SettingsProperty.ClusterScope);
|
||||
Setting.listSetting("network.host", Arrays.asList(DEFAULT_NETWORK_HOST), Function.identity(), SettingsProperty.ClusterScope);
|
||||
public static final Setting<List<String>> GLOBAL_NETWORK_BINDHOST_SETTING =
|
||||
Setting.listSetting("network.bind_host", GLOBAL_NETWORK_HOST_SETTING, s -> s, SettingsProperty.ClusterScope);
|
||||
Setting.listSetting("network.bind_host", GLOBAL_NETWORK_HOST_SETTING, Function.identity(), SettingsProperty.ClusterScope);
|
||||
public static final Setting<List<String>> GLOBAL_NETWORK_PUBLISHHOST_SETTING =
|
||||
Setting.listSetting("network.publish_host", GLOBAL_NETWORK_HOST_SETTING, s -> s, SettingsProperty.ClusterScope);
|
||||
Setting.listSetting("network.publish_host", GLOBAL_NETWORK_HOST_SETTING, Function.identity(), SettingsProperty.ClusterScope);
|
||||
public static final Setting<Boolean> NETWORK_SERVER = Setting.boolSetting("network.server", true, SettingsProperty.ClusterScope);
|
||||
|
||||
public static final class TcpSettings {
|
||||
|
|
|
@ -26,6 +26,7 @@ import org.elasticsearch.common.unit.ByteSizeUnit;
|
|||
import org.elasticsearch.common.unit.ByteSizeValue;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
|
||||
import static java.util.Collections.emptyList;
|
||||
import static org.elasticsearch.common.settings.Setting.listSetting;
|
||||
|
@ -53,11 +54,11 @@ public final class HttpTransportSettings {
|
|||
public static final Setting<Integer> SETTING_HTTP_COMPRESSION_LEVEL =
|
||||
Setting.intSetting("http.compression_level", 6, SettingsProperty.ClusterScope);
|
||||
public static final Setting<List<String>> SETTING_HTTP_HOST =
|
||||
listSetting("http.host", emptyList(), s -> s, SettingsProperty.ClusterScope);
|
||||
listSetting("http.host", emptyList(), Function.identity(), SettingsProperty.ClusterScope);
|
||||
public static final Setting<List<String>> SETTING_HTTP_PUBLISH_HOST =
|
||||
listSetting("http.publish_host", SETTING_HTTP_HOST, s -> s, SettingsProperty.ClusterScope);
|
||||
listSetting("http.publish_host", SETTING_HTTP_HOST, Function.identity(), SettingsProperty.ClusterScope);
|
||||
public static final Setting<List<String>> SETTING_HTTP_BIND_HOST =
|
||||
listSetting("http.bind_host", SETTING_HTTP_HOST, s -> s, SettingsProperty.ClusterScope);
|
||||
listSetting("http.bind_host", SETTING_HTTP_HOST, Function.identity(), SettingsProperty.ClusterScope);
|
||||
|
||||
public static final Setting<PortsRange> SETTING_HTTP_PORT =
|
||||
new Setting<PortsRange>("http.port", "9200-9300", PortsRange::new, SettingsProperty.ClusterScope);
|
||||
|
|
|
@ -23,6 +23,7 @@ import org.elasticsearch.common.settings.Setting.SettingsProperty;
|
|||
import org.elasticsearch.common.settings.Settings;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
|
||||
import static java.util.Collections.emptyList;
|
||||
import static org.elasticsearch.common.settings.Setting.groupSetting;
|
||||
|
@ -36,13 +37,13 @@ import static org.elasticsearch.common.settings.Setting.listSetting;
|
|||
final public class TransportSettings {
|
||||
|
||||
public static final Setting<List<String>> HOST =
|
||||
listSetting("transport.host", emptyList(), s -> s, SettingsProperty.ClusterScope);
|
||||
listSetting("transport.host", emptyList(), Function.identity(), SettingsProperty.ClusterScope);
|
||||
public static final Setting<List<String>> PUBLISH_HOST =
|
||||
listSetting("transport.publish_host", HOST, s -> s, SettingsProperty.ClusterScope);
|
||||
listSetting("transport.publish_host", HOST, Function.identity(), SettingsProperty.ClusterScope);
|
||||
public static final Setting<List<String>> BIND_HOST =
|
||||
listSetting("transport.bind_host", HOST, s -> s, SettingsProperty.ClusterScope);
|
||||
listSetting("transport.bind_host", HOST, Function.identity(), SettingsProperty.ClusterScope);
|
||||
public static final Setting<String> PORT =
|
||||
new Setting<>("transport.tcp.port", "9300-9400", s -> s, SettingsProperty.ClusterScope);
|
||||
new Setting<>("transport.tcp.port", "9300-9400", Function.identity(), SettingsProperty.ClusterScope);
|
||||
public static final Setting<Integer> PUBLISH_PORT =
|
||||
intSetting("transport.publish_port", -1, -1, SettingsProperty.ClusterScope);
|
||||
public static final String DEFAULT_PROFILE = "default";
|
||||
|
|
|
@ -29,6 +29,7 @@ import java.util.Collections;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import java.util.function.Function;
|
||||
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
|
@ -122,11 +123,11 @@ public class SettingTests extends ESTestCase {
|
|||
assertEquals(defautlValue, setting.getDefault(Settings.EMPTY));
|
||||
|
||||
Setting<String> secondaryDefault =
|
||||
new Setting<>("foo.bar", (s) -> s.get("old.foo.bar", "some_default"), (s) -> s, SettingsProperty.ClusterScope);
|
||||
new Setting<>("foo.bar", (s) -> s.get("old.foo.bar", "some_default"), Function.identity(), SettingsProperty.ClusterScope);
|
||||
assertEquals("some_default", secondaryDefault.get(Settings.EMPTY));
|
||||
assertEquals("42", secondaryDefault.get(Settings.builder().put("old.foo.bar", 42).build()));
|
||||
Setting<String> secondaryDefaultViaSettings =
|
||||
new Setting<>("foo.bar", secondaryDefault, (s) -> s, SettingsProperty.ClusterScope);
|
||||
new Setting<>("foo.bar", secondaryDefault, Function.identity(), SettingsProperty.ClusterScope);
|
||||
assertEquals("some_default", secondaryDefaultViaSettings.get(Settings.EMPTY));
|
||||
assertEquals("42", secondaryDefaultViaSettings.get(Settings.builder().put("old.foo.bar", 42).build()));
|
||||
}
|
||||
|
@ -324,7 +325,7 @@ public class SettingTests extends ESTestCase {
|
|||
assertEquals(i, intValues.get(i).intValue());
|
||||
}
|
||||
|
||||
Setting<List<String>> settingWithFallback = Setting.listSetting("foo.baz", listSetting, s -> s,
|
||||
Setting<List<String>> settingWithFallback = Setting.listSetting("foo.baz", listSetting, Function.identity(),
|
||||
SettingsProperty.Dynamic, SettingsProperty.ClusterScope);
|
||||
value = settingWithFallback.get(Settings.EMPTY);
|
||||
assertEquals(1, value.size());
|
||||
|
|
|
@ -29,6 +29,7 @@ import java.io.IOException;
|
|||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
|
||||
public interface GceComputeService extends LifecycleComponent<GceComputeService> {
|
||||
|
||||
|
@ -48,7 +49,7 @@ public interface GceComputeService extends LifecycleComponent<GceComputeService>
|
|||
* cloud.gce.zone: Google Compute Engine zones
|
||||
*/
|
||||
Setting<List<String>> ZONE_SETTING =
|
||||
Setting.listSetting("cloud.gce.zone", Collections.emptyList(), s -> s, SettingsProperty.ClusterScope);
|
||||
Setting.listSetting("cloud.gce.zone", Collections.emptyList(), Function.identity(), SettingsProperty.ClusterScope);
|
||||
|
||||
/**
|
||||
* cloud.gce.refresh_interval: How long the list of hosts is cached to prevent further requests to the AWS API. 0 disables caching.
|
||||
|
|
Loading…
Reference in New Issue