From e2fe0840112b6aac563dd923b4a3abbc65d6b0ab Mon Sep 17 00:00:00 2001 From: jaymode Date: Wed, 12 Feb 2020 13:41:09 -0700 Subject: [PATCH] Use List convenience methods in rest actions This commit replaces usages of older collection utility methods with the JDK 9 convenience method `List.of()`. Relates #51950 --- .../noop/action/bulk/RestNoopBulkAction.java | 6 ++---- .../noop/action/search/RestNoopSearchAction.java | 6 ++---- .../ingest/common/GrokProcessorGetAction.java | 3 +-- .../mustache/RestMultiSearchTemplateAction.java | 5 ++--- .../mustache/RestRenderSearchTemplateAction.java | 6 ++---- .../script/mustache/RestSearchTemplateAction.java | 6 ++---- .../painless/action/PainlessContextAction.java | 3 +-- .../painless/action/PainlessExecuteAction.java | 6 ++---- .../index/rankeval/RestRankEvalAction.java | 6 ++---- .../index/reindex/RestDeleteByQueryAction.java | 3 +-- .../index/reindex/RestReindexAction.java | 3 +-- .../index/reindex/RestRethrottleAction.java | 6 ++---- .../index/reindex/RestUpdateByQueryAction.java | 3 +-- .../example/resthandler/ExampleCatAction.java | 6 ++---- .../elasticsearch/RestDieWithDignityAction.java | 3 +-- .../http/TestResponseHeaderRestAction.java | 3 +-- .../rest/action/RestFieldCapabilitiesAction.java | 6 ++---- .../elasticsearch/rest/action/RestMainAction.java | 6 ++---- .../RestAddVotingConfigExclusionAction.java | 3 +-- .../admin/cluster/RestCancelTasksAction.java | 6 ++---- .../admin/cluster/RestCleanupRepositoryAction.java | 3 +-- .../RestClearVotingConfigExclusionsAction.java | 3 +-- .../RestClusterAllocationExplainAction.java | 6 ++---- .../cluster/RestClusterGetSettingsAction.java | 3 +-- .../admin/cluster/RestClusterHealthAction.java | 6 ++---- .../admin/cluster/RestClusterRerouteAction.java | 3 +-- .../cluster/RestClusterSearchShardsAction.java | 6 ++---- .../admin/cluster/RestClusterStateAction.java | 6 ++---- .../admin/cluster/RestClusterStatsAction.java | 6 ++---- .../cluster/RestClusterUpdateSettingsAction.java | 3 +-- .../admin/cluster/RestCreateSnapshotAction.java | 6 ++---- .../admin/cluster/RestDeleteRepositoryAction.java | 3 +-- .../admin/cluster/RestDeleteSnapshotAction.java | 3 +-- .../cluster/RestDeleteStoredScriptAction.java | 3 +-- .../admin/cluster/RestGetRepositoriesAction.java | 6 ++---- .../admin/cluster/RestGetScriptContextAction.java | 3 +-- .../admin/cluster/RestGetScriptLanguageAction.java | 3 +-- .../admin/cluster/RestGetSnapshotsAction.java | 3 +-- .../admin/cluster/RestGetStoredScriptAction.java | 3 +-- .../action/admin/cluster/RestGetTaskAction.java | 3 +-- .../action/admin/cluster/RestListTasksAction.java | 3 +-- .../admin/cluster/RestNodesHotThreadsAction.java | 6 ++---- .../action/admin/cluster/RestNodesInfoAction.java | 6 ++---- .../action/admin/cluster/RestNodesStatsAction.java | 6 ++---- .../action/admin/cluster/RestNodesUsageAction.java | 6 ++---- .../cluster/RestPendingClusterTasksAction.java | 3 +-- .../admin/cluster/RestPutRepositoryAction.java | 6 ++---- .../admin/cluster/RestPutStoredScriptAction.java | 6 ++---- .../cluster/RestReloadSecureSettingsAction.java | 6 ++---- .../admin/cluster/RestRemoteClusterInfoAction.java | 3 +-- .../admin/cluster/RestRestoreSnapshotAction.java | 3 +-- .../admin/cluster/RestSnapshotsStatusAction.java | 6 ++---- .../admin/cluster/RestVerifyRepositoryAction.java | 3 +-- .../action/admin/indices/RestAnalyzeAction.java | 6 ++---- .../admin/indices/RestClearIndicesCacheAction.java | 6 ++---- .../action/admin/indices/RestCloseIndexAction.java | 6 ++---- .../admin/indices/RestCreateIndexAction.java | 3 +-- .../admin/indices/RestDeleteIndexAction.java | 6 ++---- .../indices/RestDeleteIndexTemplateAction.java | 3 +-- .../rest/action/admin/indices/RestFlushAction.java | 6 ++---- .../action/admin/indices/RestForceMergeAction.java | 6 ++---- .../action/admin/indices/RestGetAliasesAction.java | 6 ++---- .../admin/indices/RestGetFieldMappingAction.java | 6 ++---- .../admin/indices/RestGetIndexTemplateAction.java | 6 ++---- .../action/admin/indices/RestGetIndicesAction.java | 6 ++---- .../action/admin/indices/RestGetMappingAction.java | 6 ++---- .../admin/indices/RestGetSettingsAction.java | 6 ++---- .../indices/RestIndexDeleteAliasesAction.java | 6 ++---- .../admin/indices/RestIndexPutAliasAction.java | 6 ++---- .../admin/indices/RestIndicesAliasesAction.java | 3 +-- .../admin/indices/RestIndicesSegmentsAction.java | 6 ++---- .../indices/RestIndicesShardStoresAction.java | 6 ++---- .../admin/indices/RestIndicesStatsAction.java | 6 ++---- .../action/admin/indices/RestOpenIndexAction.java | 6 ++---- .../admin/indices/RestPutIndexTemplateAction.java | 5 ++--- .../action/admin/indices/RestPutMappingAction.java | 6 ++---- .../action/admin/indices/RestRecoveryAction.java | 6 ++---- .../action/admin/indices/RestRefreshAction.java | 6 ++---- .../action/admin/indices/RestResizeHandler.java | 14 ++++++-------- .../admin/indices/RestRolloverIndexAction.java | 6 ++---- .../admin/indices/RestSyncedFlushAction.java | 6 ++---- .../admin/indices/RestUpdateSettingsAction.java | 6 ++---- .../admin/indices/RestUpgradeActionDeprecated.java | 6 ++---- .../indices/RestUpgradeStatusActionDeprecated.java | 6 ++---- .../admin/indices/RestValidateQueryAction.java | 6 ++---- .../rest/action/cat/RestAliasAction.java | 6 ++---- .../rest/action/cat/RestAllocationAction.java | 6 ++---- .../rest/action/cat/RestCatAction.java | 3 +-- .../rest/action/cat/RestCatRecoveryAction.java | 6 ++---- .../rest/action/cat/RestCountAction.java | 6 ++---- .../rest/action/cat/RestFielddataAction.java | 6 ++---- .../rest/action/cat/RestHealthAction.java | 3 +-- .../rest/action/cat/RestIndicesAction.java | 5 ++--- .../rest/action/cat/RestMasterAction.java | 3 +-- .../rest/action/cat/RestNodeAttrsAction.java | 3 +-- .../rest/action/cat/RestNodesAction.java | 3 +-- .../action/cat/RestPendingClusterTasksAction.java | 3 +-- .../rest/action/cat/RestPluginsAction.java | 3 +-- .../rest/action/cat/RestRepositoriesAction.java | 3 +-- .../rest/action/cat/RestSegmentsAction.java | 6 ++---- .../rest/action/cat/RestShardsAction.java | 6 ++---- .../rest/action/cat/RestSnapshotAction.java | 6 ++---- .../rest/action/cat/RestTasksAction.java | 3 +-- .../rest/action/cat/RestTemplatesAction.java | 6 ++---- .../rest/action/cat/RestThreadPoolAction.java | 6 ++---- .../rest/action/document/RestBulkAction.java | 6 ++---- .../rest/action/document/RestDeleteAction.java | 3 +-- .../rest/action/document/RestGetAction.java | 6 ++---- .../rest/action/document/RestGetSourceAction.java | 6 ++---- .../rest/action/document/RestIndexAction.java | 13 +++++-------- .../rest/action/document/RestMultiGetAction.java | 6 ++---- .../document/RestMultiTermVectorsAction.java | 6 ++---- .../action/document/RestTermVectorsAction.java | 6 ++---- .../rest/action/document/RestUpdateAction.java | 3 +-- .../action/ingest/RestDeletePipelineAction.java | 3 +-- .../rest/action/ingest/RestGetPipelineAction.java | 6 ++---- .../rest/action/ingest/RestPutPipelineAction.java | 3 +-- .../action/ingest/RestSimulatePipelineAction.java | 6 ++---- .../rest/action/search/RestClearScrollAction.java | 5 ++--- .../rest/action/search/RestCountAction.java | 6 ++---- .../rest/action/search/RestExplainAction.java | 6 ++---- .../rest/action/search/RestMultiSearchAction.java | 6 ++---- .../rest/action/search/RestSearchAction.java | 6 ++---- .../rest/action/search/RestSearchScrollAction.java | 6 ++---- .../elasticsearch/action/ActionModuleTests.java | 6 +++--- .../xpack/ccr/rest/RestCcrStatsAction.java | 3 +-- .../rest/RestDeleteAutoFollowPatternAction.java | 3 +-- .../xpack/ccr/rest/RestFollowInfoAction.java | 3 +-- .../xpack/ccr/rest/RestFollowStatsAction.java | 3 +-- .../xpack/ccr/rest/RestForgetFollowerAction.java | 3 +-- .../ccr/rest/RestGetAutoFollowPatternAction.java | 6 ++---- .../ccr/rest/RestPauseAutoFollowPatternAction.java | 3 +-- .../xpack/ccr/rest/RestPauseFollowAction.java | 3 +-- .../ccr/rest/RestPutAutoFollowPatternAction.java | 3 +-- .../xpack/ccr/rest/RestPutFollowAction.java | 3 +-- .../rest/RestResumeAutoFollowPatternAction.java | 3 +-- .../xpack/ccr/rest/RestResumeFollowAction.java | 3 +-- .../xpack/ccr/rest/RestUnfollowAction.java | 3 +-- .../license/RestDeleteLicenseAction.java | 3 +-- .../elasticsearch/license/RestGetBasicStatus.java | 3 +-- .../license/RestGetLicenseAction.java | 3 +-- .../elasticsearch/license/RestGetTrialStatus.java | 3 +-- .../license/RestPostStartBasicLicense.java | 3 +-- .../license/RestPostStartTrialLicense.java | 3 +-- .../license/RestPutLicenseAction.java | 6 ++---- .../rest/action/RestReloadAnalyzersAction.java | 6 ++---- .../core/rest/action/RestXPackInfoAction.java | 6 ++---- .../core/rest/action/RestXPackUsageAction.java | 3 +-- .../ssl/rest/RestGetCertificateInfoAction.java | 3 +-- .../deprecation/RestDeprecationInfoAction.java | 6 ++---- .../enrich/rest/RestDeleteEnrichPolicyAction.java | 3 +-- .../xpack/enrich/rest/RestEnrichStatsAction.java | 3 +-- .../enrich/rest/RestExecuteEnrichPolicyAction.java | 6 +----- .../enrich/rest/RestGetEnrichPolicyAction.java | 4 +--- .../enrich/rest/RestPutEnrichPolicyAction.java | 3 +-- .../xpack/eql/plugin/RestEqlSearchAction.java | 6 ++---- .../xpack/eql/plugin/RestEqlStatsAction.java | 3 +-- .../frozen/rest/action/RestFreezeIndexAction.java | 6 ++---- .../xpack/graph/rest/action/RestGraphAction.java | 6 ++---- .../ilm/action/RestDeleteLifecycleAction.java | 3 +-- .../ilm/action/RestExplainLifecycleAction.java | 3 +-- .../xpack/ilm/action/RestGetLifecycleAction.java | 6 ++---- .../xpack/ilm/action/RestGetStatusAction.java | 3 +-- .../xpack/ilm/action/RestMoveToStepAction.java | 3 +-- .../xpack/ilm/action/RestPutLifecycleAction.java | 3 +-- .../RestRemoveIndexLifecyclePolicyAction.java | 3 +-- .../xpack/ilm/action/RestRetryAction.java | 3 +-- .../xpack/ilm/action/RestStartILMAction.java | 3 +-- .../xpack/ilm/action/RestStopAction.java | 3 +-- .../action/RestDeleteSnapshotLifecycleAction.java | 3 +-- .../action/RestExecuteSnapshotLifecycleAction.java | 6 ++---- .../action/RestExecuteSnapshotRetentionAction.java | 3 +-- .../xpack/slm/action/RestGetSLMStatusAction.java | 3 +-- .../slm/action/RestGetSnapshotLifecycleAction.java | 6 ++---- .../RestGetSnapshotLifecycleStatsAction.java | 3 +-- .../slm/action/RestPutSnapshotLifecycleAction.java | 3 +-- .../xpack/slm/action/RestStartSLMAction.java | 3 +-- .../xpack/slm/action/RestStopSLMAction.java | 3 +-- .../xpack/ml/integration/ClassificationIT.java | 9 ++++----- .../xpack/ml/integration/RegressionIT.java | 8 +++----- .../elasticsearch/xpack/ml/MachineLearning.java | 4 ++-- .../ml/rest/calendar/RestGetCalendarsAction.java | 5 ++--- .../xpack/ml/rest/cat/RestCatDatafeedsAction.java | 6 ++---- .../xpack/ml/rest/cat/RestCatJobsAction.java | 6 ++---- .../ml/rest/cat/RestCatTrainedModelsAction.java | 6 ++---- .../rest/datafeeds/RestGetDatafeedStatsAction.java | 5 ++--- .../ml/rest/datafeeds/RestGetDatafeedsAction.java | 5 ++--- .../dataframe/RestEvaluateDataFrameAction.java | 3 +-- .../RestExplainDataFrameAnalyticsAction.java | 6 ++---- .../dataframe/RestGetDataFrameAnalyticsAction.java | 6 ++---- .../RestGetDataFrameAnalyticsStatsAction.java | 6 ++---- .../xpack/ml/rest/filter/RestGetFiltersAction.java | 5 ++--- .../rest/inference/RestGetTrainedModelsAction.java | 5 ++--- .../inference/RestGetTrainedModelsStatsAction.java | 6 ++---- .../xpack/ml/rest/job/RestGetJobStatsAction.java | 5 ++--- .../xpack/ml/rest/job/RestGetJobsAction.java | 5 ++--- .../RestGetModelSnapshotsAction.java | 5 ++--- .../ml/rest/results/RestGetBucketsAction.java | 5 ++--- .../ml/rest/results/RestGetCategoriesAction.java | 5 ++--- .../ml/rest/results/RestGetInfluencersAction.java | 5 ++--- .../rest/results/RestGetOverallBucketsAction.java | 5 ++--- .../ml/rest/results/RestGetRecordsAction.java | 5 ++--- .../rest/action/RestMonitoringBulkAction.java | 5 ++--- .../rollup/rest/RestDeleteRollupJobAction.java | 3 +-- .../xpack/rollup/rest/RestGetRollupCapsAction.java | 3 +-- .../rollup/rest/RestGetRollupIndexCapsAction.java | 3 +-- .../xpack/rollup/rest/RestGetRollupJobsAction.java | 3 +-- .../xpack/rollup/rest/RestPutRollupJobAction.java | 3 +-- .../xpack/rollup/rest/RestRollupSearchAction.java | 6 ++---- .../rollup/rest/RestStartRollupJobAction.java | 3 +-- .../xpack/rollup/rest/RestStopRollupJobAction.java | 3 +-- .../org/elasticsearch/xpack/security/Security.java | 4 ++-- .../RestDelegatePkiAuthenticationAction.java | 3 +-- .../rest/action/apikey/RestCreateApiKeyAction.java | 6 ++---- .../rest/action/apikey/RestGetApiKeyAction.java | 3 +-- .../action/apikey/RestInvalidateApiKeyAction.java | 3 +-- .../oidc/RestOpenIdConnectAuthenticateAction.java | 3 +-- .../action/oidc/RestOpenIdConnectLogoutAction.java | 3 +-- ...stOpenIdConnectPrepareAuthenticationAction.java | 3 +-- .../privilege/RestGetBuiltinPrivilegesAction.java | 3 +-- .../action/privilege/RestGetPrivilegesAction.java | 4 ++-- .../action/privilege/RestPutPrivilegesAction.java | 5 ++--- .../rest/action/role/RestGetRolesAction.java | 5 ++--- .../rest/action/role/RestPutRoleAction.java | 5 ++--- .../rolemapping/RestGetRoleMappingsAction.java | 5 ++--- .../rolemapping/RestPutRoleMappingAction.java | 5 ++--- .../rest/action/user/RestChangePasswordAction.java | 5 ++--- .../rest/action/user/RestGetUsersAction.java | 5 ++--- .../rest/action/user/RestHasPrivilegesAction.java | 5 ++--- .../rest/action/user/RestPutUserAction.java | 5 ++--- .../rest/action/user/RestSetEnabledAction.java | 5 ++--- .../xpack/sql/plugin/RestSqlClearCursorAction.java | 3 +-- .../xpack/sql/plugin/RestSqlQueryAction.java | 6 ++---- .../xpack/sql/plugin/RestSqlStatsAction.java | 3 +-- .../xpack/sql/plugin/RestSqlTranslateAction.java | 6 ++---- .../rest/action/RestDeleteTransformAction.java | 3 +-- .../rest/action/RestGetTransformAction.java | 6 ++---- .../rest/action/RestGetTransformStatsAction.java | 6 ++---- .../rest/action/RestPreviewTransformAction.java | 3 +-- .../rest/action/RestPutTransformAction.java | 3 +-- .../rest/action/RestStartTransformAction.java | 3 +-- .../rest/action/RestStopTransformAction.java | 3 +-- .../rest/action/RestUpdateTransformAction.java | 3 +-- .../compat/RestGetTransformActionDeprecated.java | 6 ++---- .../RestGetTransformStatsActionDeprecated.java | 6 ++---- .../org/elasticsearch/xpack/watcher/Watcher.java | 4 ++-- .../watcher/rest/action/RestAckWatchAction.java | 6 ++---- .../rest/action/RestActivateWatchAction.java | 10 ++++------ .../watcher/rest/action/RestDeleteWatchAction.java | 3 +-- .../rest/action/RestExecuteWatchAction.java | 5 ++--- .../watcher/rest/action/RestGetWatchAction.java | 3 +-- .../watcher/rest/action/RestPutWatchAction.java | 6 ++---- .../rest/action/RestWatchServiceAction.java | 5 ++--- .../rest/action/RestWatcherStatsAction.java | 6 ++---- 254 files changed, 412 insertions(+), 775 deletions(-) diff --git a/client/client-benchmark-noop-api-plugin/src/main/java/org/elasticsearch/plugin/noop/action/bulk/RestNoopBulkAction.java b/client/client-benchmark-noop-api-plugin/src/main/java/org/elasticsearch/plugin/noop/action/bulk/RestNoopBulkAction.java index 389656ed07754..a61237eea2ac6 100644 --- a/client/client-benchmark-noop-api-plugin/src/main/java/org/elasticsearch/plugin/noop/action/bulk/RestNoopBulkAction.java +++ b/client/client-benchmark-noop-api-plugin/src/main/java/org/elasticsearch/plugin/noop/action/bulk/RestNoopBulkAction.java @@ -39,8 +39,6 @@ import java.io.IOException; import java.util.List; -import static java.util.Arrays.asList; -import static java.util.Collections.unmodifiableList; import static org.elasticsearch.rest.RestRequest.Method.POST; import static org.elasticsearch.rest.RestRequest.Method.PUT; import static org.elasticsearch.rest.RestStatus.OK; @@ -49,11 +47,11 @@ public class RestNoopBulkAction extends BaseRestHandler { @Override public List routes() { - return unmodifiableList(asList( + return List.of( new Route(POST, "/_noop_bulk"), new Route(PUT, "/_noop_bulk"), new Route(POST, "/{index}/_noop_bulk"), - new Route(PUT, "/{index}/_noop_bulk"))); + new Route(PUT, "/{index}/_noop_bulk")); } @Override diff --git a/client/client-benchmark-noop-api-plugin/src/main/java/org/elasticsearch/plugin/noop/action/search/RestNoopSearchAction.java b/client/client-benchmark-noop-api-plugin/src/main/java/org/elasticsearch/plugin/noop/action/search/RestNoopSearchAction.java index cfc58b3aac946..da423d936d30b 100644 --- a/client/client-benchmark-noop-api-plugin/src/main/java/org/elasticsearch/plugin/noop/action/search/RestNoopSearchAction.java +++ b/client/client-benchmark-noop-api-plugin/src/main/java/org/elasticsearch/plugin/noop/action/search/RestNoopSearchAction.java @@ -26,8 +26,6 @@ import java.util.List; -import static java.util.Arrays.asList; -import static java.util.Collections.unmodifiableList; import static org.elasticsearch.rest.RestRequest.Method.GET; import static org.elasticsearch.rest.RestRequest.Method.POST; @@ -35,11 +33,11 @@ public class RestNoopSearchAction extends BaseRestHandler { @Override public List routes() { - return unmodifiableList(asList( + return List.of( new Route(GET, "/_noop_search"), new Route(POST, "/_noop_search"), new Route(GET, "/{index}/_noop_search"), - new Route(POST, "/{index}/_noop_search"))); + new Route(POST, "/{index}/_noop_search")); } @Override diff --git a/modules/ingest-common/src/main/java/org/elasticsearch/ingest/common/GrokProcessorGetAction.java b/modules/ingest-common/src/main/java/org/elasticsearch/ingest/common/GrokProcessorGetAction.java index 25ae529a2b2bd..35e939cce2d94 100644 --- a/modules/ingest-common/src/main/java/org/elasticsearch/ingest/common/GrokProcessorGetAction.java +++ b/modules/ingest-common/src/main/java/org/elasticsearch/ingest/common/GrokProcessorGetAction.java @@ -41,7 +41,6 @@ import java.util.List; import java.util.Map; -import static java.util.Collections.singletonList; import static org.elasticsearch.ingest.common.IngestCommonPlugin.GROK_PATTERNS; import static org.elasticsearch.rest.RestRequest.Method.GET; @@ -120,7 +119,7 @@ public static class RestAction extends BaseRestHandler { @Override public List routes() { - return singletonList(new Route(GET, "/_ingest/processor/grok")); + return List.of(new Route(GET, "/_ingest/processor/grok")); } @Override diff --git a/modules/lang-mustache/src/main/java/org/elasticsearch/script/mustache/RestMultiSearchTemplateAction.java b/modules/lang-mustache/src/main/java/org/elasticsearch/script/mustache/RestMultiSearchTemplateAction.java index 70e41f8596d05..52052d5ad67ac 100644 --- a/modules/lang-mustache/src/main/java/org/elasticsearch/script/mustache/RestMultiSearchTemplateAction.java +++ b/modules/lang-mustache/src/main/java/org/elasticsearch/script/mustache/RestMultiSearchTemplateAction.java @@ -34,7 +34,6 @@ import java.util.Set; import static java.util.Arrays.asList; -import static java.util.Collections.unmodifiableList; import static org.elasticsearch.rest.RestRequest.Method.GET; import static org.elasticsearch.rest.RestRequest.Method.POST; @@ -58,11 +57,11 @@ public RestMultiSearchTemplateAction(Settings settings) { @Override public List routes() { - return unmodifiableList(asList( + return List.of( new Route(GET, "/_msearch/template"), new Route(POST, "/_msearch/template"), new Route(GET, "/{index}/_msearch/template"), - new Route(POST, "/{index}/_msearch/template"))); + new Route(POST, "/{index}/_msearch/template")); } @Override diff --git a/modules/lang-mustache/src/main/java/org/elasticsearch/script/mustache/RestRenderSearchTemplateAction.java b/modules/lang-mustache/src/main/java/org/elasticsearch/script/mustache/RestRenderSearchTemplateAction.java index 320c6c582c8fb..1b6f2fe8f9aaf 100644 --- a/modules/lang-mustache/src/main/java/org/elasticsearch/script/mustache/RestRenderSearchTemplateAction.java +++ b/modules/lang-mustache/src/main/java/org/elasticsearch/script/mustache/RestRenderSearchTemplateAction.java @@ -29,8 +29,6 @@ import java.io.IOException; import java.util.List; -import static java.util.Arrays.asList; -import static java.util.Collections.unmodifiableList; import static org.elasticsearch.rest.RestRequest.Method.GET; import static org.elasticsearch.rest.RestRequest.Method.POST; @@ -38,11 +36,11 @@ public class RestRenderSearchTemplateAction extends BaseRestHandler { @Override public List routes() { - return unmodifiableList(asList( + return List.of( new Route(GET, "/_render/template"), new Route(POST, "/_render/template"), new Route(GET, "/_render/template/{id}"), - new Route(POST, "/_render/template/{id}"))); + new Route(POST, "/_render/template/{id}")); } @Override diff --git a/modules/lang-mustache/src/main/java/org/elasticsearch/script/mustache/RestSearchTemplateAction.java b/modules/lang-mustache/src/main/java/org/elasticsearch/script/mustache/RestSearchTemplateAction.java index 70a87f3d20c27..fe8e13d7ee239 100644 --- a/modules/lang-mustache/src/main/java/org/elasticsearch/script/mustache/RestSearchTemplateAction.java +++ b/modules/lang-mustache/src/main/java/org/elasticsearch/script/mustache/RestSearchTemplateAction.java @@ -34,8 +34,6 @@ import java.util.List; import java.util.Set; -import static java.util.Arrays.asList; -import static java.util.Collections.unmodifiableList; import static org.elasticsearch.rest.RestRequest.Method.GET; import static org.elasticsearch.rest.RestRequest.Method.POST; @@ -50,11 +48,11 @@ public class RestSearchTemplateAction extends BaseRestHandler { @Override public List routes() { - return unmodifiableList(asList( + return List.of( new Route(GET, "/_search/template"), new Route(POST, "/_search/template"), new Route(GET, "/{index}/_search/template"), - new Route(POST, "/{index}/_search/template"))); + new Route(POST, "/{index}/_search/template")); } @Override diff --git a/modules/lang-painless/src/main/java/org/elasticsearch/painless/action/PainlessContextAction.java b/modules/lang-painless/src/main/java/org/elasticsearch/painless/action/PainlessContextAction.java index d670d9e35aaab..12d676cfbba41 100644 --- a/modules/lang-painless/src/main/java/org/elasticsearch/painless/action/PainlessContextAction.java +++ b/modules/lang-painless/src/main/java/org/elasticsearch/painless/action/PainlessContextAction.java @@ -51,7 +51,6 @@ import java.util.Objects; import java.util.stream.Collectors; -import static java.util.Collections.singletonList; import static org.elasticsearch.rest.RestRequest.Method.GET; /** @@ -196,7 +195,7 @@ public static class RestAction extends BaseRestHandler { @Override public List routes() { - return singletonList(new Route(GET, "/_scripts/painless/_context")); + return List.of(new Route(GET, "/_scripts/painless/_context")); } @Override diff --git a/modules/lang-painless/src/main/java/org/elasticsearch/painless/action/PainlessExecuteAction.java b/modules/lang-painless/src/main/java/org/elasticsearch/painless/action/PainlessExecuteAction.java index 73847385d5eff..1e2e562787c82 100644 --- a/modules/lang-painless/src/main/java/org/elasticsearch/painless/action/PainlessExecuteAction.java +++ b/modules/lang-painless/src/main/java/org/elasticsearch/painless/action/PainlessExecuteAction.java @@ -84,8 +84,6 @@ import java.util.Map; import java.util.Objects; -import static java.util.Arrays.asList; -import static java.util.Collections.unmodifiableList; import static org.elasticsearch.action.ValidateActions.addValidationError; import static org.elasticsearch.rest.RestRequest.Method.GET; import static org.elasticsearch.rest.RestRequest.Method.POST; @@ -568,9 +566,9 @@ public static class RestAction extends BaseRestHandler { @Override public List routes() { - return unmodifiableList(asList( + return List.of( new Route(GET, "/_scripts/painless/_execute"), - new Route(POST, "/_scripts/painless/_execute"))); + new Route(POST, "/_scripts/painless/_execute")); } @Override diff --git a/modules/rank-eval/src/main/java/org/elasticsearch/index/rankeval/RestRankEvalAction.java b/modules/rank-eval/src/main/java/org/elasticsearch/index/rankeval/RestRankEvalAction.java index fc1f9f9f53cdb..d42b63ab370ed 100644 --- a/modules/rank-eval/src/main/java/org/elasticsearch/index/rankeval/RestRankEvalAction.java +++ b/modules/rank-eval/src/main/java/org/elasticsearch/index/rankeval/RestRankEvalAction.java @@ -31,8 +31,6 @@ import java.io.IOException; import java.util.List; -import static java.util.Arrays.asList; -import static java.util.Collections.unmodifiableList; import static org.elasticsearch.rest.RestRequest.Method.GET; import static org.elasticsearch.rest.RestRequest.Method.POST; @@ -94,11 +92,11 @@ public class RestRankEvalAction extends BaseRestHandler { @Override public List routes() { - return unmodifiableList(asList( + return List.of( new Route(GET, "/" + ENDPOINT), new Route(POST, "/" + ENDPOINT), new Route(GET, "/{index}/" + ENDPOINT), - new Route(POST, "/{index}/" + ENDPOINT))); + new Route(POST, "/{index}/" + ENDPOINT)); } @Override diff --git a/modules/reindex/src/main/java/org/elasticsearch/index/reindex/RestDeleteByQueryAction.java b/modules/reindex/src/main/java/org/elasticsearch/index/reindex/RestDeleteByQueryAction.java index 94d6fc0b3937a..2208af8aa11cd 100644 --- a/modules/reindex/src/main/java/org/elasticsearch/index/reindex/RestDeleteByQueryAction.java +++ b/modules/reindex/src/main/java/org/elasticsearch/index/reindex/RestDeleteByQueryAction.java @@ -28,7 +28,6 @@ import java.util.Map; import java.util.function.Consumer; -import static java.util.Collections.singletonList; import static org.elasticsearch.rest.RestRequest.Method.POST; public class RestDeleteByQueryAction extends AbstractBulkByQueryRestHandler { @@ -39,7 +38,7 @@ public RestDeleteByQueryAction() { @Override public List routes() { - return singletonList(new Route(POST, "/{index}/_delete_by_query")); + return List.of(new Route(POST, "/{index}/_delete_by_query")); } @Override diff --git a/modules/reindex/src/main/java/org/elasticsearch/index/reindex/RestReindexAction.java b/modules/reindex/src/main/java/org/elasticsearch/index/reindex/RestReindexAction.java index 1677fbd7c6127..63a67b904efaa 100644 --- a/modules/reindex/src/main/java/org/elasticsearch/index/reindex/RestReindexAction.java +++ b/modules/reindex/src/main/java/org/elasticsearch/index/reindex/RestReindexAction.java @@ -26,7 +26,6 @@ import java.io.IOException; import java.util.List; -import static java.util.Collections.singletonList; import static org.elasticsearch.common.unit.TimeValue.parseTimeValue; import static org.elasticsearch.rest.RestRequest.Method.POST; @@ -41,7 +40,7 @@ public RestReindexAction() { @Override public List routes() { - return singletonList(new Route(POST, "/_reindex")); + return List.of(new Route(POST, "/_reindex")); } @Override diff --git a/modules/reindex/src/main/java/org/elasticsearch/index/reindex/RestRethrottleAction.java b/modules/reindex/src/main/java/org/elasticsearch/index/reindex/RestRethrottleAction.java index a89546efc27de..729cad246f61e 100644 --- a/modules/reindex/src/main/java/org/elasticsearch/index/reindex/RestRethrottleAction.java +++ b/modules/reindex/src/main/java/org/elasticsearch/index/reindex/RestRethrottleAction.java @@ -28,8 +28,6 @@ import java.util.List; import java.util.function.Supplier; -import static java.util.Arrays.asList; -import static java.util.Collections.unmodifiableList; import static org.elasticsearch.rest.RestRequest.Method.POST; import static org.elasticsearch.rest.action.admin.cluster.RestListTasksAction.listTasksResponseListener; @@ -42,10 +40,10 @@ public RestRethrottleAction(Supplier nodesInCluster) { @Override public List routes() { - return unmodifiableList(asList( + return List.of( new Route(POST, "/_update_by_query/{taskId}/_rethrottle"), new Route(POST, "/_delete_by_query/{taskId}/_rethrottle"), - new Route(POST, "/_reindex/{taskId}/_rethrottle"))); + new Route(POST, "/_reindex/{taskId}/_rethrottle")); } @Override diff --git a/modules/reindex/src/main/java/org/elasticsearch/index/reindex/RestUpdateByQueryAction.java b/modules/reindex/src/main/java/org/elasticsearch/index/reindex/RestUpdateByQueryAction.java index 0af069997d597..e82df722bcdf1 100644 --- a/modules/reindex/src/main/java/org/elasticsearch/index/reindex/RestUpdateByQueryAction.java +++ b/modules/reindex/src/main/java/org/elasticsearch/index/reindex/RestUpdateByQueryAction.java @@ -34,7 +34,6 @@ import java.util.Map; import java.util.function.Consumer; -import static java.util.Collections.singletonList; import static org.elasticsearch.rest.RestRequest.Method.POST; import static org.elasticsearch.script.Script.DEFAULT_SCRIPT_LANG; @@ -46,7 +45,7 @@ public RestUpdateByQueryAction() { @Override public List routes() { - return singletonList(new Route(POST, "/{index}/_update_by_query")); + return List.of(new Route(POST, "/{index}/_update_by_query")); } @Override diff --git a/plugins/examples/rest-handler/src/main/java/org/elasticsearch/example/resthandler/ExampleCatAction.java b/plugins/examples/rest-handler/src/main/java/org/elasticsearch/example/resthandler/ExampleCatAction.java index 1a8e2485529f0..8e2b40bf3c386 100644 --- a/plugins/examples/rest-handler/src/main/java/org/elasticsearch/example/resthandler/ExampleCatAction.java +++ b/plugins/examples/rest-handler/src/main/java/org/elasticsearch/example/resthandler/ExampleCatAction.java @@ -27,8 +27,6 @@ import java.util.List; -import static java.util.Arrays.asList; -import static java.util.Collections.unmodifiableList; import static org.elasticsearch.rest.RestRequest.Method.GET; import static org.elasticsearch.rest.RestRequest.Method.POST; @@ -39,9 +37,9 @@ public class ExampleCatAction extends AbstractCatAction { @Override public List routes() { - return unmodifiableList(asList( + return List.of( new Route(GET, "/_cat/example"), - new Route(POST, "/_cat/example"))); + new Route(POST, "/_cat/example")); } @Override diff --git a/qa/die-with-dignity/src/main/java/org/elasticsearch/RestDieWithDignityAction.java b/qa/die-with-dignity/src/main/java/org/elasticsearch/RestDieWithDignityAction.java index 190a6929b1c31..1b075e6b3bde0 100644 --- a/qa/die-with-dignity/src/main/java/org/elasticsearch/RestDieWithDignityAction.java +++ b/qa/die-with-dignity/src/main/java/org/elasticsearch/RestDieWithDignityAction.java @@ -25,7 +25,6 @@ import java.util.List; -import static java.util.Collections.singletonList; import static org.elasticsearch.rest.RestRequest.Method.GET; public class RestDieWithDignityAction extends BaseRestHandler { @@ -34,7 +33,7 @@ public class RestDieWithDignityAction extends BaseRestHandler { @Override public List routes() { - return singletonList(new Route(GET, "/_die_with_dignity")); + return List.of(new Route(GET, "/_die_with_dignity")); } @Override diff --git a/qa/smoke-test-http/src/test/java/org/elasticsearch/http/TestResponseHeaderRestAction.java b/qa/smoke-test-http/src/test/java/org/elasticsearch/http/TestResponseHeaderRestAction.java index d69beb337438b..079388337ba67 100644 --- a/qa/smoke-test-http/src/test/java/org/elasticsearch/http/TestResponseHeaderRestAction.java +++ b/qa/smoke-test-http/src/test/java/org/elasticsearch/http/TestResponseHeaderRestAction.java @@ -27,14 +27,13 @@ import java.util.List; -import static java.util.Collections.singletonList; import static org.elasticsearch.rest.RestRequest.Method.GET; public class TestResponseHeaderRestAction extends BaseRestHandler { @Override public List routes() { - return singletonList(new Route(GET, "/_protected")); + return List.of(new Route(GET, "/_protected")); } @Override diff --git a/server/src/main/java/org/elasticsearch/rest/action/RestFieldCapabilitiesAction.java b/server/src/main/java/org/elasticsearch/rest/action/RestFieldCapabilitiesAction.java index 6d868dd0d1bce..9cd7342b7774a 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/RestFieldCapabilitiesAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/RestFieldCapabilitiesAction.java @@ -29,8 +29,6 @@ import java.io.IOException; import java.util.List; -import static java.util.Arrays.asList; -import static java.util.Collections.unmodifiableList; import static org.elasticsearch.rest.RestRequest.Method.GET; import static org.elasticsearch.rest.RestRequest.Method.POST; @@ -38,11 +36,11 @@ public class RestFieldCapabilitiesAction extends BaseRestHandler { @Override public List routes() { - return unmodifiableList(asList( + return List.of( new Route(GET, "/_field_caps"), new Route(POST, "/_field_caps"), new Route(GET, "/{index}/_field_caps"), - new Route(POST, "/{index}/_field_caps"))); + new Route(POST, "/{index}/_field_caps")); } @Override diff --git a/server/src/main/java/org/elasticsearch/rest/action/RestMainAction.java b/server/src/main/java/org/elasticsearch/rest/action/RestMainAction.java index f5a433cd57e73..5031bb380aa1a 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/RestMainAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/RestMainAction.java @@ -33,8 +33,6 @@ import java.io.IOException; import java.util.List; -import static java.util.Arrays.asList; -import static java.util.Collections.unmodifiableList; import static org.elasticsearch.rest.RestRequest.Method.GET; import static org.elasticsearch.rest.RestRequest.Method.HEAD; @@ -42,9 +40,9 @@ public class RestMainAction extends BaseRestHandler { @Override public List routes() { - return unmodifiableList(asList( + return List.of( new Route(GET, "/"), - new Route(HEAD, "/"))); + new Route(HEAD, "/")); } @Override diff --git a/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestAddVotingConfigExclusionAction.java b/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestAddVotingConfigExclusionAction.java index 4384d0d9dadff..f158898bbee65 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestAddVotingConfigExclusionAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestAddVotingConfigExclusionAction.java @@ -31,7 +31,6 @@ import java.io.IOException; import java.util.List; -import static java.util.Collections.singletonList; import static org.elasticsearch.rest.RestRequest.Method.POST; public class RestAddVotingConfigExclusionAction extends BaseRestHandler { @@ -45,7 +44,7 @@ public String getName() { @Override public List routes() { - return singletonList(new Route(POST, "/_cluster/voting_config_exclusions/{node_name}")); + return List.of(new Route(POST, "/_cluster/voting_config_exclusions/{node_name}")); } @Override diff --git a/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestCancelTasksAction.java b/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestCancelTasksAction.java index 99321627cf7fb..3b55929f58a0a 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestCancelTasksAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestCancelTasksAction.java @@ -31,8 +31,6 @@ import java.util.List; import java.util.function.Supplier; -import static java.util.Arrays.asList; -import static java.util.Collections.unmodifiableList; import static org.elasticsearch.rest.RestRequest.Method.POST; import static org.elasticsearch.rest.action.admin.cluster.RestListTasksAction.listTasksResponseListener; @@ -51,8 +49,8 @@ public String getName() { @Override public List routes() { - return unmodifiableList(asList(new Route(POST, "/_tasks/_cancel"), - new Route(POST, "/_tasks/{task_id}/_cancel"))); + return List.of(new Route(POST, "/_tasks/_cancel"), + new Route(POST, "/_tasks/{task_id}/_cancel")); } @Override diff --git a/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestCleanupRepositoryAction.java b/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestCleanupRepositoryAction.java index 3e9d8e46022a2..c3ed027875f58 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestCleanupRepositoryAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestCleanupRepositoryAction.java @@ -28,7 +28,6 @@ import java.io.IOException; import java.util.List; -import static java.util.Collections.singletonList; import static org.elasticsearch.client.Requests.cleanupRepositoryRequest; import static org.elasticsearch.rest.RestRequest.Method.POST; @@ -39,7 +38,7 @@ public class RestCleanupRepositoryAction extends BaseRestHandler { @Override public List routes() { - return singletonList(new Route(POST, "/_snapshot/{repository}/_cleanup")); + return List.of(new Route(POST, "/_snapshot/{repository}/_cleanup")); } @Override diff --git a/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestClearVotingConfigExclusionsAction.java b/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestClearVotingConfigExclusionsAction.java index 67c6a4e5d988c..dea2fa39e7dd1 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestClearVotingConfigExclusionsAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestClearVotingConfigExclusionsAction.java @@ -29,14 +29,13 @@ import java.io.IOException; import java.util.List; -import static java.util.Collections.singletonList; import static org.elasticsearch.rest.RestRequest.Method.DELETE; public class RestClearVotingConfigExclusionsAction extends BaseRestHandler { @Override public List routes() { - return singletonList(new Route(DELETE, "/_cluster/voting_config_exclusions")); + return List.of(new Route(DELETE, "/_cluster/voting_config_exclusions")); } @Override diff --git a/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestClusterAllocationExplainAction.java b/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestClusterAllocationExplainAction.java index d8a3b81d8c2fe..a156270d0d7ce 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestClusterAllocationExplainAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestClusterAllocationExplainAction.java @@ -35,8 +35,6 @@ import java.io.IOException; import java.util.List; -import static java.util.Arrays.asList; -import static java.util.Collections.unmodifiableList; import static org.elasticsearch.rest.RestRequest.Method.GET; import static org.elasticsearch.rest.RestRequest.Method.POST; @@ -47,9 +45,9 @@ public class RestClusterAllocationExplainAction extends BaseRestHandler { @Override public List routes() { - return unmodifiableList(asList( + return List.of( new Route(GET, "/_cluster/allocation/explain"), - new Route(POST, "/_cluster/allocation/explain"))); + new Route(POST, "/_cluster/allocation/explain")); } @Override diff --git a/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestClusterGetSettingsAction.java b/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestClusterGetSettingsAction.java index 03064337b3930..53f6828797895 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestClusterGetSettingsAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestClusterGetSettingsAction.java @@ -41,7 +41,6 @@ import java.util.List; import java.util.Set; -import static java.util.Collections.singletonList; import static org.elasticsearch.rest.RestRequest.Method.GET; public class RestClusterGetSettingsAction extends BaseRestHandler { @@ -58,7 +57,7 @@ public RestClusterGetSettingsAction(Settings settings, ClusterSettings clusterSe @Override public List routes() { - return singletonList(new Route(GET, "/_cluster/settings")); + return List.of(new Route(GET, "/_cluster/settings")); } @Override public String getName() { diff --git a/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestClusterHealthAction.java b/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestClusterHealthAction.java index 99ac7d440815c..d333b36b19e69 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestClusterHealthAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestClusterHealthAction.java @@ -36,8 +36,6 @@ import java.util.Locale; import java.util.Set; -import static java.util.Arrays.asList; -import static java.util.Collections.unmodifiableList; import static org.elasticsearch.client.Requests.clusterHealthRequest; import static org.elasticsearch.rest.RestRequest.Method.GET; @@ -45,8 +43,8 @@ public class RestClusterHealthAction extends BaseRestHandler { @Override public List routes() { - return unmodifiableList(asList(new Route(GET, "/_cluster/health"), - new Route(GET, "/_cluster/health/{index}"))); + return List.of(new Route(GET, "/_cluster/health"), + new Route(GET, "/_cluster/health/{index}")); } @Override diff --git a/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestClusterRerouteAction.java b/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestClusterRerouteAction.java index c5a60cf7b6b55..e5b749c56ad40 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestClusterRerouteAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestClusterRerouteAction.java @@ -41,7 +41,6 @@ import java.util.List; import java.util.Set; -import static java.util.Collections.singletonList; import static org.elasticsearch.rest.RestRequest.Method.POST; public class RestClusterRerouteAction extends BaseRestHandler { @@ -63,7 +62,7 @@ public RestClusterRerouteAction(SettingsFilter settingsFilter) { @Override public List routes() { - return singletonList(new Route(POST, "/_cluster/reroute")); + return List.of(new Route(POST, "/_cluster/reroute")); } @Override diff --git a/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestClusterSearchShardsAction.java b/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestClusterSearchShardsAction.java index 3660450457cb8..3228f0a7c2719 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestClusterSearchShardsAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestClusterSearchShardsAction.java @@ -31,8 +31,6 @@ import java.io.IOException; import java.util.List; -import static java.util.Arrays.asList; -import static java.util.Collections.unmodifiableList; import static org.elasticsearch.rest.RestRequest.Method.GET; import static org.elasticsearch.rest.RestRequest.Method.POST; @@ -40,11 +38,11 @@ public class RestClusterSearchShardsAction extends BaseRestHandler { @Override public List routes() { - return unmodifiableList(asList( + return List.of( new Route(GET, "/_search_shards"), new Route(POST, "/_search_shards"), new Route(GET, "/{index}/_search_shards"), - new Route(POST, "/{index}/_search_shards"))); + new Route(POST, "/{index}/_search_shards")); } @Override diff --git a/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestClusterStateAction.java b/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestClusterStateAction.java index 1c68d2d5147d3..4cb6077a30bf4 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestClusterStateAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestClusterStateAction.java @@ -43,8 +43,6 @@ import java.util.List; import java.util.Set; -import static java.util.Arrays.asList; -import static java.util.Collections.unmodifiableList; import static org.elasticsearch.rest.RestRequest.Method.GET; public class RestClusterStateAction extends BaseRestHandler { @@ -62,10 +60,10 @@ public String getName() { @Override public List routes() { - return unmodifiableList(asList( + return List.of( new Route(GET, "/_cluster/state"), new Route(GET, "/_cluster/state/{metric}"), - new Route(GET, "/_cluster/state/{metric}/{indices}"))); + new Route(GET, "/_cluster/state/{metric}/{indices}")); } @Override diff --git a/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestClusterStatsAction.java b/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestClusterStatsAction.java index 9edaa4b2f1be1..55924cb67ecf8 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestClusterStatsAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestClusterStatsAction.java @@ -28,17 +28,15 @@ import java.io.IOException; import java.util.List; -import static java.util.Arrays.asList; -import static java.util.Collections.unmodifiableList; import static org.elasticsearch.rest.RestRequest.Method.GET; public class RestClusterStatsAction extends BaseRestHandler { @Override public List routes() { - return unmodifiableList(asList( + return List.of( new Route(GET, "/_cluster/stats"), - new Route(GET, "/_cluster/stats/nodes/{nodeId}"))); + new Route(GET, "/_cluster/stats/nodes/{nodeId}")); } @Override diff --git a/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestClusterUpdateSettingsAction.java b/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestClusterUpdateSettingsAction.java index 3558da8ee0819..e1c8d565052ed 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestClusterUpdateSettingsAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestClusterUpdateSettingsAction.java @@ -33,7 +33,6 @@ import java.util.Map; import java.util.Set; -import static java.util.Collections.singletonList; import static org.elasticsearch.rest.RestRequest.Method.PUT; public class RestClusterUpdateSettingsAction extends BaseRestHandler { @@ -43,7 +42,7 @@ public class RestClusterUpdateSettingsAction extends BaseRestHandler { @Override public List routes() { - return singletonList(new Route(PUT, "/_cluster/settings")); + return List.of(new Route(PUT, "/_cluster/settings")); } @Override diff --git a/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestCreateSnapshotAction.java b/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestCreateSnapshotAction.java index 2f56b0b10e2ec..67eb024cf6b16 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestCreateSnapshotAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestCreateSnapshotAction.java @@ -28,8 +28,6 @@ import java.io.IOException; import java.util.List; -import static java.util.Arrays.asList; -import static java.util.Collections.unmodifiableList; import static org.elasticsearch.client.Requests.createSnapshotRequest; import static org.elasticsearch.rest.RestRequest.Method.POST; import static org.elasticsearch.rest.RestRequest.Method.PUT; @@ -41,9 +39,9 @@ public class RestCreateSnapshotAction extends BaseRestHandler { @Override public List routes() { - return unmodifiableList(asList( + return List.of( new Route(PUT, "/_snapshot/{repository}/{snapshot}"), - new Route(POST, "/_snapshot/{repository}/{snapshot}"))); + new Route(POST, "/_snapshot/{repository}/{snapshot}")); } @Override diff --git a/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestDeleteRepositoryAction.java b/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestDeleteRepositoryAction.java index 95f635d1728a2..4671022696892 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestDeleteRepositoryAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestDeleteRepositoryAction.java @@ -28,7 +28,6 @@ import java.io.IOException; import java.util.List; -import static java.util.Collections.singletonList; import static org.elasticsearch.client.Requests.deleteRepositoryRequest; import static org.elasticsearch.rest.RestRequest.Method.DELETE; @@ -39,7 +38,7 @@ public class RestDeleteRepositoryAction extends BaseRestHandler { @Override public List routes() { - return singletonList(new Route(DELETE, "/_snapshot/{repository}")); + return List.of(new Route(DELETE, "/_snapshot/{repository}")); } @Override diff --git a/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestDeleteSnapshotAction.java b/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestDeleteSnapshotAction.java index f74fc73c1f326..ffe34aae59dac 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestDeleteSnapshotAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestDeleteSnapshotAction.java @@ -28,7 +28,6 @@ import java.io.IOException; import java.util.List; -import static java.util.Collections.singletonList; import static org.elasticsearch.client.Requests.deleteSnapshotRequest; import static org.elasticsearch.rest.RestRequest.Method.DELETE; @@ -39,7 +38,7 @@ public class RestDeleteSnapshotAction extends BaseRestHandler { @Override public List routes() { - return singletonList(new Route(DELETE, "/_snapshot/{repository}/{snapshot}")); + return List.of(new Route(DELETE, "/_snapshot/{repository}/{snapshot}")); } @Override diff --git a/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestDeleteStoredScriptAction.java b/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestDeleteStoredScriptAction.java index efd18f6415530..ce817eca07545 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestDeleteStoredScriptAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestDeleteStoredScriptAction.java @@ -27,14 +27,13 @@ import java.io.IOException; import java.util.List; -import static java.util.Collections.singletonList; import static org.elasticsearch.rest.RestRequest.Method.DELETE; public class RestDeleteStoredScriptAction extends BaseRestHandler { @Override public List routes() { - return singletonList(new Route(DELETE, "/_scripts/{id}")); + return List.of(new Route(DELETE, "/_scripts/{id}")); } @Override diff --git a/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestGetRepositoriesAction.java b/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestGetRepositoriesAction.java index 572cb96cc0960..10bd13e5b6f67 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestGetRepositoriesAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestGetRepositoriesAction.java @@ -32,8 +32,6 @@ import java.util.List; import java.util.Set; -import static java.util.Arrays.asList; -import static java.util.Collections.unmodifiableList; import static org.elasticsearch.client.Requests.getRepositoryRequest; import static org.elasticsearch.rest.RestRequest.Method.GET; @@ -55,9 +53,9 @@ public String getName() { @Override public List routes() { - return unmodifiableList(asList( + return List.of( new Route(GET, "/_snapshot"), - new Route(GET, "/_snapshot/{repository}"))); + new Route(GET, "/_snapshot/{repository}")); } @Override diff --git a/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestGetScriptContextAction.java b/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestGetScriptContextAction.java index e7c0b65e3b587..2703cb5daf1b9 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestGetScriptContextAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestGetScriptContextAction.java @@ -29,14 +29,13 @@ import java.io.IOException; import java.util.List; -import static java.util.Collections.singletonList; import static org.elasticsearch.rest.RestRequest.Method.GET; public class RestGetScriptContextAction extends BaseRestHandler { @Override public List routes() { - return singletonList(new Route(GET, "/_script_context")); + return List.of(new Route(GET, "/_script_context")); } @Override public String getName() { diff --git a/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestGetScriptLanguageAction.java b/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestGetScriptLanguageAction.java index d40bbeb0b8df7..c613d4d27f524 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestGetScriptLanguageAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestGetScriptLanguageAction.java @@ -29,14 +29,13 @@ import java.io.IOException; import java.util.List; -import static java.util.Collections.singletonList; import static org.elasticsearch.rest.RestRequest.Method.GET; public class RestGetScriptLanguageAction extends BaseRestHandler { @Override public List routes() { - return singletonList(new Route(GET, "/_script_language")); + return List.of(new Route(GET, "/_script_language")); } @Override public String getName() { diff --git a/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestGetSnapshotsAction.java b/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestGetSnapshotsAction.java index 1c90bb79f32fd..655a0dbbafd72 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestGetSnapshotsAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestGetSnapshotsAction.java @@ -29,7 +29,6 @@ import java.io.IOException; import java.util.List; -import static java.util.Collections.singletonList; import static org.elasticsearch.client.Requests.getSnapshotsRequest; import static org.elasticsearch.rest.RestRequest.Method.GET; @@ -40,7 +39,7 @@ public class RestGetSnapshotsAction extends BaseRestHandler { @Override public List routes() { - return singletonList(new Route(GET, "/_snapshot/{repository}/{snapshot}")); + return List.of(new Route(GET, "/_snapshot/{repository}/{snapshot}")); } @Override diff --git a/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestGetStoredScriptAction.java b/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestGetStoredScriptAction.java index 48407c7b5d534..873910d8d683d 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestGetStoredScriptAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestGetStoredScriptAction.java @@ -27,14 +27,13 @@ import java.io.IOException; import java.util.List; -import static java.util.Collections.singletonList; import static org.elasticsearch.rest.RestRequest.Method.GET; public class RestGetStoredScriptAction extends BaseRestHandler { @Override public List routes() { - return singletonList(new Route(GET, "/_scripts/{id}")); + return List.of(new Route(GET, "/_scripts/{id}")); } @Override diff --git a/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestGetTaskAction.java b/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestGetTaskAction.java index 6eded15a253bf..fda74c5b65c07 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestGetTaskAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestGetTaskAction.java @@ -30,14 +30,13 @@ import java.io.IOException; import java.util.List; -import static java.util.Collections.singletonList; import static org.elasticsearch.rest.RestRequest.Method.GET; public class RestGetTaskAction extends BaseRestHandler { @Override public List routes() { - return singletonList(new Route(GET, "/_tasks/{task_id}")); + return List.of(new Route(GET, "/_tasks/{task_id}")); } @Override diff --git a/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestListTasksAction.java b/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestListTasksAction.java index b6c9fad9fdef2..6ac9deb542625 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestListTasksAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestListTasksAction.java @@ -41,7 +41,6 @@ import java.util.List; import java.util.function.Supplier; -import static java.util.Collections.singletonList; import static org.elasticsearch.rest.RestRequest.Method.GET; @@ -55,7 +54,7 @@ public RestListTasksAction(Supplier nodesInCluster) { @Override public List routes() { - return singletonList(new Route(GET, "/_tasks")); + return List.of(new Route(GET, "/_tasks")); } @Override diff --git a/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestNodesHotThreadsAction.java b/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestNodesHotThreadsAction.java index 5aeefa934d02e..0b3d8b698cf58 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestNodesHotThreadsAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestNodesHotThreadsAction.java @@ -35,8 +35,6 @@ import java.io.IOException; import java.util.List; -import static java.util.Arrays.asList; -import static java.util.Collections.unmodifiableList; import static org.elasticsearch.rest.RestRequest.Method.GET; @@ -44,7 +42,7 @@ public class RestNodesHotThreadsAction extends BaseRestHandler { @Override public List routes() { - return unmodifiableList(asList( + return List.of( new Route(GET, "/_cluster/nodes/hotthreads"), new Route(GET, "/_cluster/nodes/hot_threads"), new Route(GET, "/_cluster/nodes/{nodeId}/hotthreads"), @@ -52,7 +50,7 @@ public List routes() { new Route(GET, "/_nodes/hotthreads"), new Route(GET, "/_nodes/hot_threads"), new Route(GET, "/_nodes/{nodeId}/hotthreads"), - new Route(GET, "/_nodes/{nodeId}/hot_threads"))); + new Route(GET, "/_nodes/{nodeId}/hot_threads")); } @Override diff --git a/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestNodesInfoAction.java b/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestNodesInfoAction.java index 4b42516ef06b9..12920599fbd19 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestNodesInfoAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestNodesInfoAction.java @@ -33,8 +33,6 @@ import java.util.List; import java.util.Set; -import static java.util.Arrays.asList; -import static java.util.Collections.unmodifiableList; import static org.elasticsearch.rest.RestRequest.Method.GET; public class RestNodesInfoAction extends BaseRestHandler { @@ -58,13 +56,13 @@ public RestNodesInfoAction(SettingsFilter settingsFilter) { @Override public List routes() { - return unmodifiableList(asList( + return List.of( new Route(GET, "/_nodes"), // this endpoint is used for metrics, not for node IDs, like /_nodes/fs new Route(GET, "/_nodes/{nodeId}"), new Route(GET, "/_nodes/{nodeId}/{metrics}"), // added this endpoint to be aligned with stats - new Route(GET, "/_nodes/{nodeId}/info/{metrics}"))); + new Route(GET, "/_nodes/{nodeId}/info/{metrics}")); } @Override diff --git a/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestNodesStatsAction.java b/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestNodesStatsAction.java index 6eb834c3234cb..507c73a21f040 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestNodesStatsAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestNodesStatsAction.java @@ -38,8 +38,6 @@ import java.util.TreeSet; import java.util.function.Consumer; -import static java.util.Arrays.asList; -import static java.util.Collections.unmodifiableList; import static java.util.Map.entry; import static org.elasticsearch.rest.RestRequest.Method.GET; @@ -47,13 +45,13 @@ public class RestNodesStatsAction extends BaseRestHandler { @Override public List routes() { - return unmodifiableList(asList( + return List.of( new Route(GET, "/_nodes/stats"), new Route(GET, "/_nodes/{nodeId}/stats"), new Route(GET, "/_nodes/stats/{metric}"), new Route(GET, "/_nodes/{nodeId}/stats/{metric}"), new Route(GET, "/_nodes/stats/{metric}/{index_metric}"), - new Route(GET, "/_nodes/{nodeId}/stats/{metric}/{index_metric}"))); + new Route(GET, "/_nodes/{nodeId}/stats/{metric}/{index_metric}")); } static final Map> METRICS = Map.ofEntries( diff --git a/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestNodesUsageAction.java b/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestNodesUsageAction.java index 0e8b6370f9a12..6c38883b8663f 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestNodesUsageAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestNodesUsageAction.java @@ -37,19 +37,17 @@ import java.util.Locale; import java.util.Set; -import static java.util.Arrays.asList; -import static java.util.Collections.unmodifiableList; import static org.elasticsearch.rest.RestRequest.Method.GET; public class RestNodesUsageAction extends BaseRestHandler { @Override public List routes() { - return unmodifiableList(asList( + return List.of( new Route(GET, "/_nodes/usage"), new Route(GET, "/_nodes/{nodeId}/usage"), new Route(GET, "/_nodes/usage/{metric}"), - new Route(GET, "/_nodes/{nodeId}/usage/{metric}"))); + new Route(GET, "/_nodes/{nodeId}/usage/{metric}")); } @Override diff --git a/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestPendingClusterTasksAction.java b/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestPendingClusterTasksAction.java index 05265f77f85a9..864e8027e94d8 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestPendingClusterTasksAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestPendingClusterTasksAction.java @@ -28,14 +28,13 @@ import java.io.IOException; import java.util.List; -import static java.util.Collections.singletonList; import static org.elasticsearch.rest.RestRequest.Method.GET; public class RestPendingClusterTasksAction extends BaseRestHandler { @Override public List routes() { - return singletonList(new Route(GET, "/_cluster/pending_tasks")); + return List.of(new Route(GET, "/_cluster/pending_tasks")); } @Override diff --git a/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestPutRepositoryAction.java b/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestPutRepositoryAction.java index f76d97e0296bb..a1b1b102ef5b0 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestPutRepositoryAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestPutRepositoryAction.java @@ -29,8 +29,6 @@ import java.io.IOException; import java.util.List; -import static java.util.Arrays.asList; -import static java.util.Collections.unmodifiableList; import static org.elasticsearch.client.Requests.putRepositoryRequest; import static org.elasticsearch.rest.RestRequest.Method.POST; import static org.elasticsearch.rest.RestRequest.Method.PUT; @@ -42,9 +40,9 @@ public class RestPutRepositoryAction extends BaseRestHandler { @Override public List routes() { - return unmodifiableList(asList( + return List.of( new Route(POST, "/_snapshot/{repository}"), - new Route(PUT, "/_snapshot/{repository}"))); + new Route(PUT, "/_snapshot/{repository}")); } @Override diff --git a/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestPutStoredScriptAction.java b/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestPutStoredScriptAction.java index 499fd1b91f290..38a2227784222 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestPutStoredScriptAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestPutStoredScriptAction.java @@ -30,8 +30,6 @@ import java.io.IOException; import java.util.List; -import static java.util.Arrays.asList; -import static java.util.Collections.unmodifiableList; import static org.elasticsearch.rest.RestRequest.Method.POST; import static org.elasticsearch.rest.RestRequest.Method.PUT; @@ -39,11 +37,11 @@ public class RestPutStoredScriptAction extends BaseRestHandler { @Override public List routes() { - return unmodifiableList(asList( + return List.of( new Route(POST, "/_scripts/{id}"), new Route(PUT, "/_scripts/{id}"), new Route(POST, "/_scripts/{id}/{context}"), - new Route(PUT, "/_scripts/{id}/{context}"))); + new Route(PUT, "/_scripts/{id}/{context}")); } @Override diff --git a/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestReloadSecureSettingsAction.java b/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestReloadSecureSettingsAction.java index 209e0ef7d3357..10d073f41c270 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestReloadSecureSettingsAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestReloadSecureSettingsAction.java @@ -39,8 +39,6 @@ import java.io.IOException; import java.util.List; -import static java.util.Arrays.asList; -import static java.util.Collections.unmodifiableList; import static org.elasticsearch.rest.RestRequest.Method.POST; public final class RestReloadSecureSettingsAction extends BaseRestHandler { @@ -60,9 +58,9 @@ public String getName() { @Override public List routes() { - return unmodifiableList(asList( + return List.of( new Route(POST, "/_nodes/reload_secure_settings"), - new Route(POST, "/_nodes/{nodeId}/reload_secure_settings"))); + new Route(POST, "/_nodes/{nodeId}/reload_secure_settings")); } @Override diff --git a/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestRemoteClusterInfoAction.java b/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestRemoteClusterInfoAction.java index e12d930c5bf28..0b3fcc4c0e43c 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestRemoteClusterInfoAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestRemoteClusterInfoAction.java @@ -28,14 +28,13 @@ import java.util.List; -import static java.util.Collections.singletonList; import static org.elasticsearch.rest.RestRequest.Method.GET; public final class RestRemoteClusterInfoAction extends BaseRestHandler { @Override public List routes() { - return singletonList(new Route(GET, "_remote/info")); + return List.of(new Route(GET, "_remote/info")); } @Override diff --git a/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestRestoreSnapshotAction.java b/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestRestoreSnapshotAction.java index d94c2e0285cd7..2e1fb8f4cbbf0 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestRestoreSnapshotAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestRestoreSnapshotAction.java @@ -28,7 +28,6 @@ import java.io.IOException; import java.util.List; -import static java.util.Collections.singletonList; import static org.elasticsearch.client.Requests.restoreSnapshotRequest; import static org.elasticsearch.rest.RestRequest.Method.POST; @@ -39,7 +38,7 @@ public class RestRestoreSnapshotAction extends BaseRestHandler { @Override public List routes() { - return singletonList(new Route(POST, "/_snapshot/{repository}/{snapshot}/_restore")); + return List.of(new Route(POST, "/_snapshot/{repository}/{snapshot}/_restore")); } @Override diff --git a/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestSnapshotsStatusAction.java b/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestSnapshotsStatusAction.java index 19328f2eff2c0..1a58e6b03f94d 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestSnapshotsStatusAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestSnapshotsStatusAction.java @@ -29,8 +29,6 @@ import java.io.IOException; import java.util.List; -import static java.util.Arrays.asList; -import static java.util.Collections.unmodifiableList; import static org.elasticsearch.client.Requests.snapshotsStatusRequest; import static org.elasticsearch.rest.RestRequest.Method.GET; @@ -41,10 +39,10 @@ public class RestSnapshotsStatusAction extends BaseRestHandler { @Override public List routes() { - return unmodifiableList(asList( + return List.of( new Route(GET, "/_snapshot/{repository}/{snapshot}/_status"), new Route(GET, "/_snapshot/{repository}/_status"), - new Route(GET, "/_snapshot/_status"))); + new Route(GET, "/_snapshot/_status")); } @Override diff --git a/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestVerifyRepositoryAction.java b/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestVerifyRepositoryAction.java index ad796897c8a87..230d0d6f81196 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestVerifyRepositoryAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestVerifyRepositoryAction.java @@ -28,7 +28,6 @@ import java.io.IOException; import java.util.List; -import static java.util.Collections.singletonList; import static org.elasticsearch.client.Requests.verifyRepositoryRequest; import static org.elasticsearch.rest.RestRequest.Method.POST; @@ -36,7 +35,7 @@ public class RestVerifyRepositoryAction extends BaseRestHandler { @Override public List routes() { - return singletonList(new Route(POST, "/_snapshot/{repository}/_verify")); + return List.of(new Route(POST, "/_snapshot/{repository}/_verify")); } @Override diff --git a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestAnalyzeAction.java b/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestAnalyzeAction.java index 15d34a91d9d17..882ecdcb58659 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestAnalyzeAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestAnalyzeAction.java @@ -29,8 +29,6 @@ import java.io.IOException; import java.util.List; -import static java.util.Arrays.asList; -import static java.util.Collections.unmodifiableList; import static org.elasticsearch.rest.RestRequest.Method.GET; import static org.elasticsearch.rest.RestRequest.Method.POST; @@ -50,11 +48,11 @@ public static class Fields { @Override public List routes() { - return unmodifiableList(asList( + return List.of( new Route(GET, "/_analyze"), new Route(POST, "/_analyze"), new Route(GET, "/{index}/_analyze"), - new Route(POST, "/{index}/_analyze"))); + new Route(POST, "/{index}/_analyze")); } @Override diff --git a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestClearIndicesCacheAction.java b/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestClearIndicesCacheAction.java index fd6979c92e29c..bdf182ff98517 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestClearIndicesCacheAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestClearIndicesCacheAction.java @@ -30,17 +30,15 @@ import java.io.IOException; import java.util.List; -import static java.util.Arrays.asList; -import static java.util.Collections.unmodifiableList; import static org.elasticsearch.rest.RestRequest.Method.POST; public class RestClearIndicesCacheAction extends BaseRestHandler { @Override public List routes() { - return unmodifiableList(asList( + return List.of( new Route(POST, "/_cache/clear"), - new Route(POST, "/{index}/_cache/clear"))); + new Route(POST, "/{index}/_cache/clear")); } @Override diff --git a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestCloseIndexAction.java b/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestCloseIndexAction.java index 5d3a186b8cb4b..1c831b6ee3b6d 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestCloseIndexAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestCloseIndexAction.java @@ -31,17 +31,15 @@ import java.io.IOException; import java.util.List; -import static java.util.Arrays.asList; -import static java.util.Collections.unmodifiableList; import static org.elasticsearch.rest.RestRequest.Method.POST; public class RestCloseIndexAction extends BaseRestHandler { @Override public List routes() { - return unmodifiableList(asList( + return List.of( new Route(POST, "/_close"), - new Route(POST, "/{index}/_close"))); + new Route(POST, "/{index}/_close")); } @Override diff --git a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestCreateIndexAction.java b/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestCreateIndexAction.java index 59156c70502ef..3519fe48f6a8a 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestCreateIndexAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestCreateIndexAction.java @@ -34,7 +34,6 @@ import java.util.List; import java.util.Map; -import static java.util.Collections.singletonList; import static java.util.Collections.singletonMap; import static org.elasticsearch.rest.RestRequest.Method.PUT; @@ -42,7 +41,7 @@ public class RestCreateIndexAction extends BaseRestHandler { @Override public List routes() { - return singletonList(new Route(PUT, "/{index}")); + return List.of(new Route(PUT, "/{index}")); } @Override diff --git a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestDeleteIndexAction.java b/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestDeleteIndexAction.java index a82370e89af82..c33637c3c73cf 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestDeleteIndexAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestDeleteIndexAction.java @@ -30,17 +30,15 @@ import java.io.IOException; import java.util.List; -import static java.util.Arrays.asList; -import static java.util.Collections.unmodifiableList; import static org.elasticsearch.rest.RestRequest.Method.DELETE; public class RestDeleteIndexAction extends BaseRestHandler { @Override public List routes() { - return unmodifiableList(asList( + return List.of( new Route(DELETE, "/"), - new Route(DELETE, "/{index}"))); + new Route(DELETE, "/{index}")); } @Override diff --git a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestDeleteIndexTemplateAction.java b/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestDeleteIndexTemplateAction.java index a92bee023452a..e64fc6efca00b 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestDeleteIndexTemplateAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestDeleteIndexTemplateAction.java @@ -27,14 +27,13 @@ import java.io.IOException; import java.util.List; -import static java.util.Collections.singletonList; import static org.elasticsearch.rest.RestRequest.Method.DELETE; public class RestDeleteIndexTemplateAction extends BaseRestHandler { @Override public List routes() { - return singletonList(new Route(DELETE, "/_template/{name}")); + return List.of(new Route(DELETE, "/_template/{name}")); } @Override diff --git a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestFlushAction.java b/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestFlushAction.java index d22dcb91d1a94..dd131826058c9 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestFlushAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestFlushAction.java @@ -30,8 +30,6 @@ import java.io.IOException; import java.util.List; -import static java.util.Arrays.asList; -import static java.util.Collections.unmodifiableList; import static org.elasticsearch.rest.RestRequest.Method.GET; import static org.elasticsearch.rest.RestRequest.Method.POST; @@ -39,11 +37,11 @@ public class RestFlushAction extends BaseRestHandler { @Override public List routes() { - return unmodifiableList(asList( + return List.of( new Route(GET, "/_flush"), new Route(POST, "/_flush"), new Route(GET, "/{index}/_flush"), - new Route(POST, "/{index}/_flush"))); + new Route(POST, "/{index}/_flush")); } @Override diff --git a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestForceMergeAction.java b/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestForceMergeAction.java index 9cba54ed77245..d55b98e9025e3 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestForceMergeAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestForceMergeAction.java @@ -30,17 +30,15 @@ import java.io.IOException; import java.util.List; -import static java.util.Arrays.asList; -import static java.util.Collections.unmodifiableList; import static org.elasticsearch.rest.RestRequest.Method.POST; public class RestForceMergeAction extends BaseRestHandler { @Override public List routes() { - return unmodifiableList(asList( + return List.of( new Route(POST, "/_forcemerge"), - new Route(POST, "/{index}/_forcemerge"))); + new Route(POST, "/{index}/_forcemerge")); } @Override diff --git a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestGetAliasesAction.java b/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestGetAliasesAction.java index f05554322aa7c..1b38b75425296 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestGetAliasesAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestGetAliasesAction.java @@ -46,8 +46,6 @@ import java.util.SortedSet; import java.util.TreeSet; -import static java.util.Arrays.asList; -import static java.util.Collections.unmodifiableList; import static org.elasticsearch.rest.RestRequest.Method.GET; import static org.elasticsearch.rest.RestRequest.Method.HEAD; @@ -58,7 +56,7 @@ public class RestGetAliasesAction extends BaseRestHandler { @Override public List routes() { - return unmodifiableList(asList( + return List.of( new Route(GET, "/_alias"), new Route(GET, "/_aliases"), new Route(GET, "/_alias/{name}"), @@ -66,7 +64,7 @@ public List routes() { new Route(GET, "/{index}/_alias"), new Route(HEAD, "/{index}/_alias"), new Route(GET, "/{index}/_alias/{name}"), - new Route(HEAD, "/{index}/_alias/{name}"))); + new Route(HEAD, "/{index}/_alias/{name}")); } @Override diff --git a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestGetFieldMappingAction.java b/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestGetFieldMappingAction.java index 807ff220ff8e1..6043936d4167b 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestGetFieldMappingAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestGetFieldMappingAction.java @@ -37,8 +37,6 @@ import java.util.List; import java.util.Map; -import static java.util.Arrays.asList; -import static java.util.Collections.unmodifiableList; import static org.elasticsearch.rest.RestRequest.Method.GET; import static org.elasticsearch.rest.RestStatus.NOT_FOUND; import static org.elasticsearch.rest.RestStatus.OK; @@ -47,9 +45,9 @@ public class RestGetFieldMappingAction extends BaseRestHandler { @Override public List routes() { - return unmodifiableList(asList( + return List.of( new Route(GET, "/_mapping/field/{fields}"), - new Route(GET, "/{index}/_mapping/field/{fields}"))); + new Route(GET, "/{index}/_mapping/field/{fields}")); } @Override diff --git a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestGetIndexTemplateAction.java b/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestGetIndexTemplateAction.java index 767c5fa3e923d..4f8b21c19887a 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestGetIndexTemplateAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestGetIndexTemplateAction.java @@ -33,8 +33,6 @@ import java.util.List; import java.util.Set; -import static java.util.Arrays.asList; -import static java.util.Collections.unmodifiableList; import static org.elasticsearch.rest.RestRequest.Method.GET; import static org.elasticsearch.rest.RestRequest.Method.HEAD; import static org.elasticsearch.rest.RestStatus.NOT_FOUND; @@ -47,10 +45,10 @@ public class RestGetIndexTemplateAction extends BaseRestHandler { @Override public List routes() { - return unmodifiableList(asList( + return List.of( new Route(GET, "/_template"), new Route(GET, "/_template/{name}"), - new Route(HEAD, "/_template/{name}"))); + new Route(HEAD, "/_template/{name}")); } @Override diff --git a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestGetIndicesAction.java b/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestGetIndicesAction.java index fff606e8b9229..face6c11b323c 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestGetIndicesAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestGetIndicesAction.java @@ -33,8 +33,6 @@ import java.util.List; import java.util.Set; -import static java.util.Arrays.asList; -import static java.util.Collections.unmodifiableList; import static org.elasticsearch.rest.RestRequest.Method.GET; import static org.elasticsearch.rest.RestRequest.Method.HEAD; @@ -45,9 +43,9 @@ public class RestGetIndicesAction extends BaseRestHandler { @Override public List routes() { - return unmodifiableList(asList( + return List.of( new Route(GET, "/{index}"), - new Route(HEAD, "/{index}"))); + new Route(HEAD, "/{index}")); } @Override diff --git a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestGetMappingAction.java b/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestGetMappingAction.java index 55b255ca7b633..ca553c1310e39 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestGetMappingAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestGetMappingAction.java @@ -35,19 +35,17 @@ import java.io.IOException; import java.util.List; -import static java.util.Arrays.asList; -import static java.util.Collections.unmodifiableList; import static org.elasticsearch.rest.RestRequest.Method.GET; public class RestGetMappingAction extends BaseRestHandler { @Override public List routes() { - return unmodifiableList(asList( + return List.of( new Route(GET, "/_mapping"), new Route(GET, "/_mappings"), new Route(GET, "/{index}/_mapping"), - new Route(GET, "/{index}/_mappings"))); + new Route(GET, "/{index}/_mappings")); } @Override diff --git a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestGetSettingsAction.java b/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestGetSettingsAction.java index 20058c812b94e..8611656544cf2 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestGetSettingsAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestGetSettingsAction.java @@ -30,20 +30,18 @@ import java.io.IOException; import java.util.List; -import static java.util.Arrays.asList; -import static java.util.Collections.unmodifiableList; import static org.elasticsearch.rest.RestRequest.Method.GET; public class RestGetSettingsAction extends BaseRestHandler { @Override public List routes() { - return unmodifiableList(asList( + return List.of( new Route(GET, "/_settings"), new Route(GET, "/_settings/{name}"), new Route(GET, "/{index}/_settings"), new Route(GET, "/{index}/_settings/{name}"), - new Route(GET, "/{index}/_setting/{name}"))); + new Route(GET, "/{index}/_setting/{name}")); } @Override diff --git a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestIndexDeleteAliasesAction.java b/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestIndexDeleteAliasesAction.java index ff454ee5354cd..81bce34ccda0f 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestIndexDeleteAliasesAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestIndexDeleteAliasesAction.java @@ -29,17 +29,15 @@ import java.io.IOException; import java.util.List; -import static java.util.Arrays.asList; -import static java.util.Collections.unmodifiableList; import static org.elasticsearch.rest.RestRequest.Method.DELETE; public class RestIndexDeleteAliasesAction extends BaseRestHandler { @Override public List routes() { - return unmodifiableList(asList( + return List.of( new Route(DELETE, "/{index}/_alias/{name}"), - new Route(DELETE, "/{index}/_aliases/{name}"))); + new Route(DELETE, "/{index}/_aliases/{name}")); } @Override diff --git a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestIndexPutAliasAction.java b/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestIndexPutAliasAction.java index fb6bede4e0ae3..a68bfb83829f5 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestIndexPutAliasAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestIndexPutAliasAction.java @@ -31,8 +31,6 @@ import java.util.List; import java.util.Map; -import static java.util.Arrays.asList; -import static java.util.Collections.unmodifiableList; import static org.elasticsearch.rest.RestRequest.Method.POST; import static org.elasticsearch.rest.RestRequest.Method.PUT; @@ -40,7 +38,7 @@ public class RestIndexPutAliasAction extends BaseRestHandler { @Override public List routes() { - return unmodifiableList(asList( + return List.of( new Route(POST, "/{index}/_alias/{name}"), new Route(PUT, "/{index}/_alias/{name}"), new Route(POST, "/_alias/{name}"), @@ -51,7 +49,7 @@ public List routes() { new Route(PUT, "/_aliases/{name}"), new Route(PUT, "/{index}/_alias"), new Route(PUT, "/{index}/_aliases"), - new Route(PUT, "/_alias"))); + new Route(PUT, "/_alias")); } @Override diff --git a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestIndicesAliasesAction.java b/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestIndicesAliasesAction.java index e492857747955..260e29c41b100 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestIndicesAliasesAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestIndicesAliasesAction.java @@ -29,7 +29,6 @@ import java.io.IOException; import java.util.List; -import static java.util.Collections.singletonList; import static org.elasticsearch.rest.RestRequest.Method.POST; public class RestIndicesAliasesAction extends BaseRestHandler { @@ -41,7 +40,7 @@ public String getName() { @Override public List routes() { - return singletonList(new Route(POST, "/_aliases")); + return List.of(new Route(POST, "/_aliases")); } @Override diff --git a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestIndicesSegmentsAction.java b/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestIndicesSegmentsAction.java index e14a83bd3084c..4d4dec96064dd 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestIndicesSegmentsAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestIndicesSegmentsAction.java @@ -30,17 +30,15 @@ import java.io.IOException; import java.util.List; -import static java.util.Arrays.asList; -import static java.util.Collections.unmodifiableList; import static org.elasticsearch.rest.RestRequest.Method.GET; public class RestIndicesSegmentsAction extends BaseRestHandler { @Override public List routes() { - return unmodifiableList(asList( + return List.of( new Route(GET, "/_segments"), - new Route(GET, "/{index}/_segments"))); + new Route(GET, "/{index}/_segments")); } @Override diff --git a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestIndicesShardStoresAction.java b/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestIndicesShardStoresAction.java index 39ff18cade947..b26299f19767b 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestIndicesShardStoresAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestIndicesShardStoresAction.java @@ -35,8 +35,6 @@ import java.io.IOException; import java.util.List; -import static java.util.Arrays.asList; -import static java.util.Collections.unmodifiableList; import static org.elasticsearch.rest.RestRequest.Method.GET; import static org.elasticsearch.rest.RestStatus.OK; @@ -47,9 +45,9 @@ public class RestIndicesShardStoresAction extends BaseRestHandler { @Override public List routes() { - return unmodifiableList(asList( + return List.of( new Route(GET, "/_shard_stores"), - new Route(GET, "/{index}/_shard_stores"))); + new Route(GET, "/{index}/_shard_stores")); } @Override diff --git a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestIndicesStatsAction.java b/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestIndicesStatsAction.java index 0b2cacc0f53a1..2f63b7b5b47ab 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestIndicesStatsAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestIndicesStatsAction.java @@ -39,19 +39,17 @@ import java.util.TreeSet; import java.util.function.Consumer; -import static java.util.Arrays.asList; -import static java.util.Collections.unmodifiableList; import static org.elasticsearch.rest.RestRequest.Method.GET; public class RestIndicesStatsAction extends BaseRestHandler { @Override public List routes() { - return unmodifiableList(asList( + return List.of( new Route(GET, "/_stats"), new Route(GET, "/_stats/{metric}"), new Route(GET, "/{index}/_stats"), - new Route(GET, "/{index}/_stats/{metric}"))); + new Route(GET, "/{index}/_stats/{metric}")); } @Override diff --git a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestOpenIndexAction.java b/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestOpenIndexAction.java index 5ffc29e26e11b..dd61df3547e34 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestOpenIndexAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestOpenIndexAction.java @@ -31,17 +31,15 @@ import java.io.IOException; import java.util.List; -import static java.util.Arrays.asList; -import static java.util.Collections.unmodifiableList; import static org.elasticsearch.rest.RestRequest.Method.POST; public class RestOpenIndexAction extends BaseRestHandler { @Override public List routes() { - return unmodifiableList(asList( + return List.of( new Route(POST, "/_open"), - new Route(POST, "/{index}/_open"))); + new Route(POST, "/{index}/_open")); } @Override diff --git a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestPutIndexTemplateAction.java b/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestPutIndexTemplateAction.java index 974602a9fcca6..825f5b1e270da 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestPutIndexTemplateAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestPutIndexTemplateAction.java @@ -32,7 +32,6 @@ import java.util.Map; import static java.util.Arrays.asList; -import static java.util.Collections.unmodifiableList; import static org.elasticsearch.rest.RestRequest.Method.POST; import static org.elasticsearch.rest.RestRequest.Method.PUT; @@ -40,9 +39,9 @@ public class RestPutIndexTemplateAction extends BaseRestHandler { @Override public List routes() { - return unmodifiableList(asList( + return List.of( new Route(POST, "/_template/{name}"), - new Route(PUT, "/_template/{name}"))); + new Route(PUT, "/_template/{name}")); } @Override diff --git a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestPutMappingAction.java b/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestPutMappingAction.java index c8f42975640a3..5baf9b8e9ffeb 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestPutMappingAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestPutMappingAction.java @@ -33,8 +33,6 @@ import java.util.List; import java.util.Map; -import static java.util.Arrays.asList; -import static java.util.Collections.unmodifiableList; import static org.elasticsearch.client.Requests.putMappingRequest; import static org.elasticsearch.rest.RestRequest.Method.POST; import static org.elasticsearch.rest.RestRequest.Method.PUT; @@ -43,11 +41,11 @@ public class RestPutMappingAction extends BaseRestHandler { @Override public List routes() { - return unmodifiableList(asList( + return List.of( new Route(POST, "/{index}/_mapping/"), new Route(PUT, "/{index}/_mapping/"), new Route(POST, "/{index}/_mappings/"), - new Route(PUT, "/{index}/_mappings/"))); + new Route(PUT, "/{index}/_mappings/")); } @Override diff --git a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestRecoveryAction.java b/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestRecoveryAction.java index ac8744f39c70e..5f8a9424773e4 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestRecoveryAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestRecoveryAction.java @@ -30,8 +30,6 @@ import java.io.IOException; import java.util.List; -import static java.util.Arrays.asList; -import static java.util.Collections.unmodifiableList; import static org.elasticsearch.rest.RestRequest.Method.GET; /** @@ -41,9 +39,9 @@ public class RestRecoveryAction extends BaseRestHandler { @Override public List routes() { - return unmodifiableList(asList( + return List.of( new Route(GET, "/_recovery"), - new Route(GET, "/{index}/_recovery"))); + new Route(GET, "/{index}/_recovery")); } @Override diff --git a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestRefreshAction.java b/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestRefreshAction.java index cae120e50bb46..3d9cbd903bb70 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestRefreshAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestRefreshAction.java @@ -32,8 +32,6 @@ import java.io.IOException; import java.util.List; -import static java.util.Arrays.asList; -import static java.util.Collections.unmodifiableList; import static org.elasticsearch.rest.RestRequest.Method.GET; import static org.elasticsearch.rest.RestRequest.Method.POST; @@ -41,11 +39,11 @@ public class RestRefreshAction extends BaseRestHandler { @Override public List routes() { - return unmodifiableList(asList( + return List.of( new Route(GET, "/_refresh"), new Route(POST, "/_refresh"), new Route(GET, "/{index}/_refresh"), - new Route(POST, "/{index}/_refresh"))); + new Route(POST, "/{index}/_refresh")); } @Override diff --git a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestResizeHandler.java b/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestResizeHandler.java index f26f2cab7989b..8295efb38554e 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestResizeHandler.java +++ b/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestResizeHandler.java @@ -30,8 +30,6 @@ import java.io.IOException; import java.util.List; -import static java.util.Arrays.asList; -import static java.util.Collections.unmodifiableList; import static org.elasticsearch.rest.RestRequest.Method.POST; import static org.elasticsearch.rest.RestRequest.Method.PUT; @@ -60,9 +58,9 @@ public static class RestShrinkIndexAction extends RestResizeHandler { @Override public List routes() { - return unmodifiableList(asList( + return List.of( new Route(POST, "/{index}/_shrink/{target}"), - new Route(PUT, "/{index}/_shrink/{target}"))); + new Route(PUT, "/{index}/_shrink/{target}")); } @Override @@ -81,9 +79,9 @@ public static class RestSplitIndexAction extends RestResizeHandler { @Override public List routes() { - return unmodifiableList(asList( + return List.of( new Route(POST, "/{index}/_split/{target}"), - new Route(PUT, "/{index}/_split/{target}"))); + new Route(PUT, "/{index}/_split/{target}")); } @Override @@ -102,9 +100,9 @@ public static class RestCloneIndexAction extends RestResizeHandler { @Override public List routes() { - return unmodifiableList(asList( + return List.of( new Route(POST, "/{index}/_clone/{target}"), - new Route(PUT, "/{index}/_clone/{target}"))); + new Route(PUT, "/{index}/_clone/{target}")); } @Override diff --git a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestRolloverIndexAction.java b/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestRolloverIndexAction.java index 580daa864c39e..ad41baaf99c6a 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestRolloverIndexAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestRolloverIndexAction.java @@ -29,17 +29,15 @@ import java.io.IOException; import java.util.List; -import static java.util.Arrays.asList; -import static java.util.Collections.unmodifiableList; import static org.elasticsearch.rest.RestRequest.Method.POST; public class RestRolloverIndexAction extends BaseRestHandler { @Override public List routes() { - return unmodifiableList(asList( + return List.of( new Route(POST, "/{index}/_rollover"), - new Route(POST, "/{index}/_rollover/{new_index}"))); + new Route(POST, "/{index}/_rollover/{new_index}")); } @Override diff --git a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestSyncedFlushAction.java b/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestSyncedFlushAction.java index 638db99538cec..02d3bc3649728 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestSyncedFlushAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestSyncedFlushAction.java @@ -39,8 +39,6 @@ import java.io.IOException; import java.util.List; -import static java.util.Arrays.asList; -import static java.util.Collections.unmodifiableList; import static org.elasticsearch.rest.RestRequest.Method.GET; import static org.elasticsearch.rest.RestRequest.Method.POST; @@ -51,11 +49,11 @@ public class RestSyncedFlushAction extends BaseRestHandler { @Override public List routes() { - return unmodifiableList(asList( + return List.of( new Route(GET, "/_flush/synced"), new Route(POST, "/_flush/synced"), new Route(GET, "/{index}/_flush/synced"), - new Route(POST, "/{index}/_flush/synced"))); + new Route(POST, "/{index}/_flush/synced")); } @Override diff --git a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestUpdateSettingsAction.java b/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestUpdateSettingsAction.java index 4db7539850567..bda02c448b462 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestUpdateSettingsAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestUpdateSettingsAction.java @@ -32,8 +32,6 @@ import java.util.List; import java.util.Set; -import static java.util.Arrays.asList; -import static java.util.Collections.unmodifiableList; import static org.elasticsearch.client.Requests.updateSettingsRequest; import static org.elasticsearch.rest.RestRequest.Method.PUT; @@ -41,9 +39,9 @@ public class RestUpdateSettingsAction extends BaseRestHandler { @Override public List routes() { - return unmodifiableList(asList( + return List.of( new Route(PUT, "/{index}/_settings"), - new Route(PUT, "/_settings"))); + new Route(PUT, "/_settings")); } @Override diff --git a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestUpgradeActionDeprecated.java b/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestUpgradeActionDeprecated.java index c44bd3bfe4bf6..1f166e858f80b 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestUpgradeActionDeprecated.java +++ b/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestUpgradeActionDeprecated.java @@ -33,8 +33,6 @@ import java.util.Collections; import java.util.List; -import static java.util.Arrays.asList; -import static java.util.Collections.unmodifiableList; import static org.elasticsearch.rest.RestRequest.Method.POST; public class RestUpgradeActionDeprecated extends BaseRestHandler { @@ -47,9 +45,9 @@ public class RestUpgradeActionDeprecated extends BaseRestHandler { @Override public List deprecatedRoutes() { - return unmodifiableList(asList( + return List.of( new DeprecatedRoute(POST, "/_upgrade", UPGRADE_API_DEPRECATION_MESSAGE), - new DeprecatedRoute(POST, "/{index}/_upgrade", UPGRADE_API_DEPRECATION_MESSAGE))); + new DeprecatedRoute(POST, "/{index}/_upgrade", UPGRADE_API_DEPRECATION_MESSAGE)); } @Override diff --git a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestUpgradeStatusActionDeprecated.java b/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestUpgradeStatusActionDeprecated.java index 06af4a08f0c30..8fec4e232060d 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestUpgradeStatusActionDeprecated.java +++ b/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestUpgradeStatusActionDeprecated.java @@ -33,8 +33,6 @@ import java.util.Collections; import java.util.List; -import static java.util.Arrays.asList; -import static java.util.Collections.unmodifiableList; import static org.elasticsearch.rest.RestRequest.Method.GET; import static org.elasticsearch.rest.action.admin.indices.RestUpgradeActionDeprecated.UPGRADE_API_DEPRECATION_MESSAGE; @@ -45,9 +43,9 @@ public class RestUpgradeStatusActionDeprecated extends BaseRestHandler { @Override public List deprecatedRoutes() { - return unmodifiableList(asList( + return List.of( new DeprecatedRoute(GET, "/_upgrade", UPGRADE_API_DEPRECATION_MESSAGE), - new DeprecatedRoute(GET, "/{index}/_upgrade", UPGRADE_API_DEPRECATION_MESSAGE))); + new DeprecatedRoute(GET, "/{index}/_upgrade", UPGRADE_API_DEPRECATION_MESSAGE)); } @Override diff --git a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestValidateQueryAction.java b/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestValidateQueryAction.java index 68be9cba956d1..e733f08f6decc 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestValidateQueryAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestValidateQueryAction.java @@ -37,8 +37,6 @@ import java.io.IOException; import java.util.List; -import static java.util.Arrays.asList; -import static java.util.Collections.unmodifiableList; import static org.elasticsearch.rest.RestRequest.Method.GET; import static org.elasticsearch.rest.RestRequest.Method.POST; import static org.elasticsearch.rest.RestStatus.OK; @@ -47,11 +45,11 @@ public class RestValidateQueryAction extends BaseRestHandler { @Override public List routes() { - return unmodifiableList(asList( + return List.of( new Route(GET, "/_validate/query"), new Route(POST, "/_validate/query"), new Route(GET, "/{index}/_validate/query"), - new Route(POST, "/{index}/_validate/query"))); + new Route(POST, "/{index}/_validate/query")); } @Override diff --git a/server/src/main/java/org/elasticsearch/rest/action/cat/RestAliasAction.java b/server/src/main/java/org/elasticsearch/rest/action/cat/RestAliasAction.java index cc96487fd45dc..e03b0c98e0e98 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/cat/RestAliasAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/cat/RestAliasAction.java @@ -31,17 +31,15 @@ import java.util.List; -import static java.util.Arrays.asList; -import static java.util.Collections.unmodifiableList; import static org.elasticsearch.rest.RestRequest.Method.GET; public class RestAliasAction extends AbstractCatAction { @Override public List routes() { - return unmodifiableList(asList( + return List.of( new Route(GET, "/_cat/aliases"), - new Route(GET, "/_cat/aliases/{alias}"))); + new Route(GET, "/_cat/aliases/{alias}")); } @Override diff --git a/server/src/main/java/org/elasticsearch/rest/action/cat/RestAllocationAction.java b/server/src/main/java/org/elasticsearch/rest/action/cat/RestAllocationAction.java index 1c81d24c21e21..27d23a5197758 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/cat/RestAllocationAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/cat/RestAllocationAction.java @@ -39,8 +39,6 @@ import java.util.List; -import static java.util.Arrays.asList; -import static java.util.Collections.unmodifiableList; import static org.elasticsearch.rest.RestRequest.Method.GET; @@ -48,9 +46,9 @@ public class RestAllocationAction extends AbstractCatAction { @Override public List routes() { - return unmodifiableList(asList( + return List.of( new Route(GET, "/_cat/allocation"), - new Route(GET, "/_cat/allocation/{nodes}"))); + new Route(GET, "/_cat/allocation/{nodes}")); } @Override diff --git a/server/src/main/java/org/elasticsearch/rest/action/cat/RestCatAction.java b/server/src/main/java/org/elasticsearch/rest/action/cat/RestCatAction.java index c545a1bd2f384..250ee60288611 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/cat/RestCatAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/cat/RestCatAction.java @@ -28,7 +28,6 @@ import java.io.IOException; import java.util.List; -import static java.util.Collections.singletonList; import static org.elasticsearch.rest.RestRequest.Method.GET; public class RestCatAction extends BaseRestHandler { @@ -48,7 +47,7 @@ public RestCatAction(List catActions) { @Override public List routes() { - return singletonList(new Route(GET, "/_cat")); + return List.of(new Route(GET, "/_cat")); } @Override diff --git a/server/src/main/java/org/elasticsearch/rest/action/cat/RestCatRecoveryAction.java b/server/src/main/java/org/elasticsearch/rest/action/cat/RestCatRecoveryAction.java index 9e29b17070ccf..a7e0131f53b2a 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/cat/RestCatRecoveryAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/cat/RestCatRecoveryAction.java @@ -40,8 +40,6 @@ import java.util.List; import java.util.Locale; -import static java.util.Arrays.asList; -import static java.util.Collections.unmodifiableList; import static org.elasticsearch.rest.RestRequest.Method.GET; /** @@ -53,9 +51,9 @@ public class RestCatRecoveryAction extends AbstractCatAction { @Override public List routes() { - return unmodifiableList(asList( + return List.of( new Route(GET, "/_cat/recovery"), - new Route(GET, "/_cat/recovery/{index}"))); + new Route(GET, "/_cat/recovery/{index}")); } @Override diff --git a/server/src/main/java/org/elasticsearch/rest/action/cat/RestCountAction.java b/server/src/main/java/org/elasticsearch/rest/action/cat/RestCountAction.java index fada1e5d35645..3b95646575407 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/cat/RestCountAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/cat/RestCountAction.java @@ -36,17 +36,15 @@ import java.io.IOException; import java.util.List; -import static java.util.Arrays.asList; -import static java.util.Collections.unmodifiableList; import static org.elasticsearch.rest.RestRequest.Method.GET; public class RestCountAction extends AbstractCatAction { @Override public List routes() { - return unmodifiableList(asList( + return List.of( new Route(GET, "/_cat/count"), - new Route(GET, "/_cat/count/{index}"))); + new Route(GET, "/_cat/count/{index}")); } @Override diff --git a/server/src/main/java/org/elasticsearch/rest/action/cat/RestFielddataAction.java b/server/src/main/java/org/elasticsearch/rest/action/cat/RestFielddataAction.java index cc7e16b2ea39f..e05568cf8a37c 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/cat/RestFielddataAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/cat/RestFielddataAction.java @@ -32,8 +32,6 @@ import java.util.List; -import static java.util.Arrays.asList; -import static java.util.Collections.unmodifiableList; import static org.elasticsearch.rest.RestRequest.Method.GET; /** @@ -43,9 +41,9 @@ public class RestFielddataAction extends AbstractCatAction { @Override public List routes() { - return unmodifiableList(asList( + return List.of( new Route(GET, "/_cat/fielddata"), - new Route(GET, "/_cat/fielddata/{fields}"))); + new Route(GET, "/_cat/fielddata/{fields}")); } @Override diff --git a/server/src/main/java/org/elasticsearch/rest/action/cat/RestHealthAction.java b/server/src/main/java/org/elasticsearch/rest/action/cat/RestHealthAction.java index 7e859ac0f21a1..45ea2a90ef4e4 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/cat/RestHealthAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/cat/RestHealthAction.java @@ -30,14 +30,13 @@ import java.util.List; import java.util.Locale; -import static java.util.Collections.singletonList; import static org.elasticsearch.rest.RestRequest.Method.GET; public class RestHealthAction extends AbstractCatAction { @Override public List routes() { - return singletonList(new Route(GET, "/_cat/health")); + return List.of(new Route(GET, "/_cat/health")); } @Override diff --git a/server/src/main/java/org/elasticsearch/rest/action/cat/RestIndicesAction.java b/server/src/main/java/org/elasticsearch/rest/action/cat/RestIndicesAction.java index d122bc7bd2690..a70fcec89b0c8 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/cat/RestIndicesAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/cat/RestIndicesAction.java @@ -62,7 +62,6 @@ import java.util.stream.StreamSupport; import static java.util.Arrays.asList; -import static java.util.Collections.unmodifiableList; import static org.elasticsearch.action.support.master.MasterNodeRequest.DEFAULT_MASTER_NODE_TIMEOUT; import static org.elasticsearch.rest.RestRequest.Method.GET; @@ -72,9 +71,9 @@ public class RestIndicesAction extends AbstractCatAction { @Override public List routes() { - return unmodifiableList(asList( + return List.of( new Route(GET, "/_cat/indices"), - new Route(GET, "/_cat/indices/{index}"))); + new Route(GET, "/_cat/indices/{index}")); } @Override diff --git a/server/src/main/java/org/elasticsearch/rest/action/cat/RestMasterAction.java b/server/src/main/java/org/elasticsearch/rest/action/cat/RestMasterAction.java index 18dea4625b6fe..2cc379f306258 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/cat/RestMasterAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/cat/RestMasterAction.java @@ -31,14 +31,13 @@ import java.util.List; -import static java.util.Collections.singletonList; import static org.elasticsearch.rest.RestRequest.Method.GET; public class RestMasterAction extends AbstractCatAction { @Override public List routes() { - return singletonList(new Route(GET, "/_cat/master")); + return List.of(new Route(GET, "/_cat/master")); } @Override diff --git a/server/src/main/java/org/elasticsearch/rest/action/cat/RestNodeAttrsAction.java b/server/src/main/java/org/elasticsearch/rest/action/cat/RestNodeAttrsAction.java index dcb75b22e647f..13c2a5c581eb3 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/cat/RestNodeAttrsAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/cat/RestNodeAttrsAction.java @@ -37,14 +37,13 @@ import java.util.List; import java.util.Map; -import static java.util.Collections.singletonList; import static org.elasticsearch.rest.RestRequest.Method.GET; public class RestNodeAttrsAction extends AbstractCatAction { @Override public List routes() { - return singletonList(new Route(GET, "/_cat/nodeattrs")); + return List.of(new Route(GET, "/_cat/nodeattrs")); } @Override diff --git a/server/src/main/java/org/elasticsearch/rest/action/cat/RestNodesAction.java b/server/src/main/java/org/elasticsearch/rest/action/cat/RestNodesAction.java index a80390a0a04ff..0833a04ff45a1 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/cat/RestNodesAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/cat/RestNodesAction.java @@ -65,14 +65,13 @@ import java.util.Locale; import java.util.stream.Collectors; -import static java.util.Collections.singletonList; import static org.elasticsearch.rest.RestRequest.Method.GET; public class RestNodesAction extends AbstractCatAction { @Override public List routes() { - return singletonList(new Route(GET, "/_cat/nodes")); + return List.of(new Route(GET, "/_cat/nodes")); } @Override diff --git a/server/src/main/java/org/elasticsearch/rest/action/cat/RestPendingClusterTasksAction.java b/server/src/main/java/org/elasticsearch/rest/action/cat/RestPendingClusterTasksAction.java index f3071839612e2..8e002d4099720 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/cat/RestPendingClusterTasksAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/cat/RestPendingClusterTasksAction.java @@ -30,14 +30,13 @@ import java.util.List; -import static java.util.Collections.singletonList; import static org.elasticsearch.rest.RestRequest.Method.GET; public class RestPendingClusterTasksAction extends AbstractCatAction { @Override public List routes() { - return singletonList(new Route(GET, "/_cat/pending_tasks")); + return List.of(new Route(GET, "/_cat/pending_tasks")); } @Override diff --git a/server/src/main/java/org/elasticsearch/rest/action/cat/RestPluginsAction.java b/server/src/main/java/org/elasticsearch/rest/action/cat/RestPluginsAction.java index 9a50deee98c8e..dda070a27c458 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/cat/RestPluginsAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/cat/RestPluginsAction.java @@ -36,14 +36,13 @@ import java.util.List; -import static java.util.Collections.singletonList; import static org.elasticsearch.rest.RestRequest.Method.GET; public class RestPluginsAction extends AbstractCatAction { @Override public List routes() { - return singletonList(new Route(GET, "/_cat/plugins")); + return List.of(new Route(GET, "/_cat/plugins")); } @Override diff --git a/server/src/main/java/org/elasticsearch/rest/action/cat/RestRepositoriesAction.java b/server/src/main/java/org/elasticsearch/rest/action/cat/RestRepositoriesAction.java index e9a5bd6b3aac9..a8744f9fc984f 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/cat/RestRepositoriesAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/cat/RestRepositoriesAction.java @@ -30,7 +30,6 @@ import java.util.List; -import static java.util.Collections.singletonList; import static org.elasticsearch.rest.RestRequest.Method.GET; /** @@ -40,7 +39,7 @@ public class RestRepositoriesAction extends AbstractCatAction { @Override public List routes() { - return singletonList(new Route(GET, "/_cat/repositories")); + return List.of(new Route(GET, "/_cat/repositories")); } @Override diff --git a/server/src/main/java/org/elasticsearch/rest/action/cat/RestSegmentsAction.java b/server/src/main/java/org/elasticsearch/rest/action/cat/RestSegmentsAction.java index 3c63f7bbdbf30..c3f5c3c9d0ff3 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/cat/RestSegmentsAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/cat/RestSegmentsAction.java @@ -39,17 +39,15 @@ import java.util.List; import java.util.Map; -import static java.util.Arrays.asList; -import static java.util.Collections.unmodifiableList; import static org.elasticsearch.rest.RestRequest.Method.GET; public class RestSegmentsAction extends AbstractCatAction { @Override public List routes() { - return unmodifiableList(asList( + return List.of( new Route(GET, "/_cat/segments"), - new Route(GET, "/_cat/segments/{index}"))); + new Route(GET, "/_cat/segments/{index}")); } @Override diff --git a/server/src/main/java/org/elasticsearch/rest/action/cat/RestShardsAction.java b/server/src/main/java/org/elasticsearch/rest/action/cat/RestShardsAction.java index 9a321476efda7..40971a425e07e 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/cat/RestShardsAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/cat/RestShardsAction.java @@ -56,16 +56,14 @@ import java.util.Locale; import java.util.function.Function; -import static java.util.Arrays.asList; -import static java.util.Collections.unmodifiableList; import static org.elasticsearch.rest.RestRequest.Method.GET; public class RestShardsAction extends AbstractCatAction { @Override public List routes() { - return unmodifiableList(asList(new Route(GET, "/_cat/shards"), - new Route(GET, "/_cat/shards/{index}"))); + return List.of(new Route(GET, "/_cat/shards"), + new Route(GET, "/_cat/shards/{index}")); } @Override diff --git a/server/src/main/java/org/elasticsearch/rest/action/cat/RestSnapshotAction.java b/server/src/main/java/org/elasticsearch/rest/action/cat/RestSnapshotAction.java index 257bf5c1a2205..f4f93c8467837 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/cat/RestSnapshotAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/cat/RestSnapshotAction.java @@ -40,8 +40,6 @@ import java.util.Map; import java.util.concurrent.TimeUnit; -import static java.util.Arrays.asList; -import static java.util.Collections.unmodifiableList; import static org.elasticsearch.rest.RestRequest.Method.GET; /** @@ -51,9 +49,9 @@ public class RestSnapshotAction extends AbstractCatAction { @Override public List routes() { - return unmodifiableList(asList( + return List.of( new Route(GET, "/_cat/snapshots"), - new Route(GET, "/_cat/snapshots/{repository}"))); + new Route(GET, "/_cat/snapshots/{repository}")); } @Override diff --git a/server/src/main/java/org/elasticsearch/rest/action/cat/RestTasksAction.java b/server/src/main/java/org/elasticsearch/rest/action/cat/RestTasksAction.java index 2868d16d682fa..76e0beff31ac2 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/cat/RestTasksAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/cat/RestTasksAction.java @@ -43,7 +43,6 @@ import java.util.Set; import java.util.function.Supplier; -import static java.util.Collections.singletonList; import static org.elasticsearch.rest.RestRequest.Method.GET; import static org.elasticsearch.rest.action.admin.cluster.RestListTasksAction.generateListTasksRequest; @@ -56,7 +55,7 @@ public RestTasksAction(Supplier nodesInCluster) { @Override public List routes() { - return singletonList(new Route(GET, "/_cat/tasks")); + return List.of(new Route(GET, "/_cat/tasks")); } @Override diff --git a/server/src/main/java/org/elasticsearch/rest/action/cat/RestTemplatesAction.java b/server/src/main/java/org/elasticsearch/rest/action/cat/RestTemplatesAction.java index fb9946d5acfe0..771995acd786c 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/cat/RestTemplatesAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/cat/RestTemplatesAction.java @@ -33,17 +33,15 @@ import java.util.List; -import static java.util.Arrays.asList; -import static java.util.Collections.unmodifiableList; import static org.elasticsearch.rest.RestRequest.Method.GET; public class RestTemplatesAction extends AbstractCatAction { @Override public List routes() { - return unmodifiableList(asList( + return List.of( new Route(GET, "/_cat/templates"), - new Route(GET, "/_cat/templates/{name}"))); + new Route(GET, "/_cat/templates/{name}")); } @Override diff --git a/server/src/main/java/org/elasticsearch/rest/action/cat/RestThreadPoolAction.java b/server/src/main/java/org/elasticsearch/rest/action/cat/RestThreadPoolAction.java index caaaeba07b964..480c329808f86 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/cat/RestThreadPoolAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/cat/RestThreadPoolAction.java @@ -47,17 +47,15 @@ import java.util.Set; import java.util.TreeMap; -import static java.util.Arrays.asList; -import static java.util.Collections.unmodifiableList; import static org.elasticsearch.rest.RestRequest.Method.GET; public class RestThreadPoolAction extends AbstractCatAction { @Override public List routes() { - return unmodifiableList(asList( + return List.of( new Route(GET, "/_cat/thread_pool"), - new Route(GET, "/_cat/thread_pool/{thread_pool_patterns}"))); + new Route(GET, "/_cat/thread_pool/{thread_pool_patterns}")); } @Override diff --git a/server/src/main/java/org/elasticsearch/rest/action/document/RestBulkAction.java b/server/src/main/java/org/elasticsearch/rest/action/document/RestBulkAction.java index b9a36d181b3aa..ffe21bce355a4 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/document/RestBulkAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/document/RestBulkAction.java @@ -33,8 +33,6 @@ import java.io.IOException; import java.util.List; -import static java.util.Arrays.asList; -import static java.util.Collections.unmodifiableList; import static org.elasticsearch.rest.RestRequest.Method.POST; import static org.elasticsearch.rest.RestRequest.Method.PUT; @@ -57,11 +55,11 @@ public RestBulkAction(Settings settings) { @Override public List routes() { - return unmodifiableList(asList( + return List.of( new Route(POST, "/_bulk"), new Route(PUT, "/_bulk"), new Route(POST, "/{index}/_bulk"), - new Route(PUT, "/{index}/_bulk"))); + new Route(PUT, "/{index}/_bulk")); } @Override diff --git a/server/src/main/java/org/elasticsearch/rest/action/document/RestDeleteAction.java b/server/src/main/java/org/elasticsearch/rest/action/document/RestDeleteAction.java index 8e46244101e74..0e6b26916a7b1 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/document/RestDeleteAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/document/RestDeleteAction.java @@ -31,14 +31,13 @@ import java.io.IOException; import java.util.List; -import static java.util.Collections.singletonList; import static org.elasticsearch.rest.RestRequest.Method.DELETE; public class RestDeleteAction extends BaseRestHandler { @Override public List routes() { - return singletonList(new Route(DELETE, "/{index}/_doc/{id}")); + return List.of(new Route(DELETE, "/{index}/_doc/{id}")); } @Override diff --git a/server/src/main/java/org/elasticsearch/rest/action/document/RestGetAction.java b/server/src/main/java/org/elasticsearch/rest/action/document/RestGetAction.java index 54f1f954f816d..82548a505b47e 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/document/RestGetAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/document/RestGetAction.java @@ -34,8 +34,6 @@ import java.io.IOException; import java.util.List; -import static java.util.Arrays.asList; -import static java.util.Collections.unmodifiableList; import static org.elasticsearch.rest.RestRequest.Method.GET; import static org.elasticsearch.rest.RestRequest.Method.HEAD; import static org.elasticsearch.rest.RestStatus.NOT_FOUND; @@ -50,9 +48,9 @@ public String getName() { @Override public List routes() { - return unmodifiableList(asList( + return List.of( new Route(GET, "/{index}/_doc/{id}"), - new Route(HEAD, "/{index}/_doc/{id}"))); + new Route(HEAD, "/{index}/_doc/{id}")); } @Override diff --git a/server/src/main/java/org/elasticsearch/rest/action/document/RestGetSourceAction.java b/server/src/main/java/org/elasticsearch/rest/action/document/RestGetSourceAction.java index 72bc4538cbbe6..8af11f8dabb33 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/document/RestGetSourceAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/document/RestGetSourceAction.java @@ -39,8 +39,6 @@ import java.io.InputStream; import java.util.List; -import static java.util.Arrays.asList; -import static java.util.Collections.unmodifiableList; import static org.elasticsearch.rest.RestRequest.Method.GET; import static org.elasticsearch.rest.RestRequest.Method.HEAD; import static org.elasticsearch.rest.RestStatus.OK; @@ -52,9 +50,9 @@ public class RestGetSourceAction extends BaseRestHandler { @Override public List routes() { - return unmodifiableList(asList( + return List.of( new Route(GET, "/{index}/_source/{id}"), - new Route(HEAD, "/{index}/_source/{id}"))); + new Route(HEAD, "/{index}/_source/{id}")); } @Override diff --git a/server/src/main/java/org/elasticsearch/rest/action/document/RestIndexAction.java b/server/src/main/java/org/elasticsearch/rest/action/document/RestIndexAction.java index ef52af60e6efb..4a86ca118b176 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/document/RestIndexAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/document/RestIndexAction.java @@ -34,9 +34,6 @@ import java.util.List; import java.util.Locale; -import static java.util.Arrays.asList; -import static java.util.Collections.singletonList; -import static java.util.Collections.unmodifiableList; import static org.elasticsearch.rest.RestRequest.Method.POST; import static org.elasticsearch.rest.RestRequest.Method.PUT; @@ -44,9 +41,9 @@ public class RestIndexAction extends BaseRestHandler { @Override public List routes() { - return unmodifiableList(asList( + return List.of( new Route(POST, "/{index}/_doc/{id}"), - new Route(PUT, "/{index}/_doc/{id}"))); + new Route(PUT, "/{index}/_doc/{id}")); } @Override @@ -63,9 +60,9 @@ public String getName() { @Override public List routes() { - return unmodifiableList(asList( + return List.of( new Route(POST, "/{index}/_create/{id}"), - new Route(PUT, "/{index}/_create/{id}"))); + new Route(PUT, "/{index}/_create/{id}")); } @Override @@ -97,7 +94,7 @@ public String getName() { @Override public List routes() { - return singletonList(new Route(POST, "/{index}/_doc")); + return List.of(new Route(POST, "/{index}/_doc")); } @Override diff --git a/server/src/main/java/org/elasticsearch/rest/action/document/RestMultiGetAction.java b/server/src/main/java/org/elasticsearch/rest/action/document/RestMultiGetAction.java index c9fd67d678150..dcf1342b40b1d 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/document/RestMultiGetAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/document/RestMultiGetAction.java @@ -32,8 +32,6 @@ import java.io.IOException; import java.util.List; -import static java.util.Arrays.asList; -import static java.util.Collections.unmodifiableList; import static org.elasticsearch.rest.RestRequest.Method.GET; import static org.elasticsearch.rest.RestRequest.Method.POST; @@ -47,11 +45,11 @@ public RestMultiGetAction(Settings settings) { @Override public List routes() { - return unmodifiableList(asList( + return List.of( new Route(GET, "/_mget"), new Route(POST, "/_mget"), new Route(GET, "/{index}/_mget"), - new Route(POST, "/{index}/_mget"))); + new Route(POST, "/{index}/_mget")); } @Override diff --git a/server/src/main/java/org/elasticsearch/rest/action/document/RestMultiTermVectorsAction.java b/server/src/main/java/org/elasticsearch/rest/action/document/RestMultiTermVectorsAction.java index 504620a58f7e5..4f55a6e1cd44a 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/document/RestMultiTermVectorsAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/document/RestMultiTermVectorsAction.java @@ -30,8 +30,6 @@ import java.io.IOException; import java.util.List; -import static java.util.Arrays.asList; -import static java.util.Collections.unmodifiableList; import static org.elasticsearch.rest.RestRequest.Method.GET; import static org.elasticsearch.rest.RestRequest.Method.POST; @@ -39,11 +37,11 @@ public class RestMultiTermVectorsAction extends BaseRestHandler { @Override public List routes() { - return unmodifiableList(asList( + return List.of( new Route(GET, "/_mtermvectors"), new Route(POST, "/_mtermvectors"), new Route(GET, "/{index}/_mtermvectors"), - new Route(POST, "/{index}/_mtermvectors"))); + new Route(POST, "/{index}/_mtermvectors")); } @Override diff --git a/server/src/main/java/org/elasticsearch/rest/action/document/RestTermVectorsAction.java b/server/src/main/java/org/elasticsearch/rest/action/document/RestTermVectorsAction.java index b9c2e12cbf0c4..a2cca1bb564be 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/document/RestTermVectorsAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/document/RestTermVectorsAction.java @@ -34,8 +34,6 @@ import java.util.List; import java.util.Set; -import static java.util.Arrays.asList; -import static java.util.Collections.unmodifiableList; import static org.elasticsearch.rest.RestRequest.Method.GET; import static org.elasticsearch.rest.RestRequest.Method.POST; @@ -47,11 +45,11 @@ public class RestTermVectorsAction extends BaseRestHandler { @Override public List routes() { - return unmodifiableList(asList( + return List.of( new Route(GET, "/{index}/_termvectors"), new Route(POST, "/{index}/_termvectors"), new Route(GET, "/{index}/_termvectors/{id}"), - new Route(POST, "/{index}/_termvectors/{id}"))); + new Route(POST, "/{index}/_termvectors/{id}")); } @Override diff --git a/server/src/main/java/org/elasticsearch/rest/action/document/RestUpdateAction.java b/server/src/main/java/org/elasticsearch/rest/action/document/RestUpdateAction.java index 2ef58e23e1594..af451c02ecc58 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/document/RestUpdateAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/document/RestUpdateAction.java @@ -34,14 +34,13 @@ import java.io.IOException; import java.util.List; -import static java.util.Collections.singletonList; import static org.elasticsearch.rest.RestRequest.Method.POST; public class RestUpdateAction extends BaseRestHandler { @Override public List routes() { - return singletonList(new Route(POST, "/{index}/_update/{id}")); + return List.of(new Route(POST, "/{index}/_update/{id}")); } @Override diff --git a/server/src/main/java/org/elasticsearch/rest/action/ingest/RestDeletePipelineAction.java b/server/src/main/java/org/elasticsearch/rest/action/ingest/RestDeletePipelineAction.java index 2956811e26fed..2e750c3c93561 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/ingest/RestDeletePipelineAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/ingest/RestDeletePipelineAction.java @@ -28,13 +28,12 @@ import java.io.IOException; import java.util.List; -import static java.util.Collections.singletonList; import static org.elasticsearch.rest.RestRequest.Method.DELETE; public class RestDeletePipelineAction extends BaseRestHandler { @Override public List routes() { - return singletonList(new Route(DELETE, "/_ingest/pipeline/{id}")); + return List.of(new Route(DELETE, "/_ingest/pipeline/{id}")); } @Override diff --git a/server/src/main/java/org/elasticsearch/rest/action/ingest/RestGetPipelineAction.java b/server/src/main/java/org/elasticsearch/rest/action/ingest/RestGetPipelineAction.java index 1e4e016027b8e..4e911e2592332 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/ingest/RestGetPipelineAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/ingest/RestGetPipelineAction.java @@ -29,17 +29,15 @@ import java.io.IOException; import java.util.List; -import static java.util.Arrays.asList; -import static java.util.Collections.unmodifiableList; import static org.elasticsearch.rest.RestRequest.Method.GET; public class RestGetPipelineAction extends BaseRestHandler { @Override public List routes() { - return unmodifiableList(asList( + return List.of( new Route(GET, "/_ingest/pipeline"), - new Route(GET, "/_ingest/pipeline/{id}"))); + new Route(GET, "/_ingest/pipeline/{id}")); } @Override diff --git a/server/src/main/java/org/elasticsearch/rest/action/ingest/RestPutPipelineAction.java b/server/src/main/java/org/elasticsearch/rest/action/ingest/RestPutPipelineAction.java index b1fb8086e0653..692d4397e5f11 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/ingest/RestPutPipelineAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/ingest/RestPutPipelineAction.java @@ -31,7 +31,6 @@ import java.io.IOException; import java.util.List; -import static java.util.Collections.singletonList; import static org.elasticsearch.rest.RestRequest.Method.PUT; @@ -39,7 +38,7 @@ public class RestPutPipelineAction extends BaseRestHandler { @Override public List routes() { - return singletonList(new Route(PUT, "/_ingest/pipeline/{id}")); + return List.of(new Route(PUT, "/_ingest/pipeline/{id}")); } @Override diff --git a/server/src/main/java/org/elasticsearch/rest/action/ingest/RestSimulatePipelineAction.java b/server/src/main/java/org/elasticsearch/rest/action/ingest/RestSimulatePipelineAction.java index 1ac0bdd6fcd5a..d5ba078970031 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/ingest/RestSimulatePipelineAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/ingest/RestSimulatePipelineAction.java @@ -31,8 +31,6 @@ import java.io.IOException; import java.util.List; -import static java.util.Arrays.asList; -import static java.util.Collections.unmodifiableList; import static org.elasticsearch.rest.RestRequest.Method.GET; import static org.elasticsearch.rest.RestRequest.Method.POST; @@ -40,11 +38,11 @@ public class RestSimulatePipelineAction extends BaseRestHandler { @Override public List routes() { - return unmodifiableList(asList( + return List.of( new Route(GET, "/_ingest/pipeline/{id}/_simulate"), new Route(POST, "/_ingest/pipeline/{id}/_simulate"), new Route(GET, "/_ingest/pipeline/_simulate"), - new Route(POST, "/_ingest/pipeline/_simulate"))); + new Route(POST, "/_ingest/pipeline/_simulate")); } @Override diff --git a/server/src/main/java/org/elasticsearch/rest/action/search/RestClearScrollAction.java b/server/src/main/java/org/elasticsearch/rest/action/search/RestClearScrollAction.java index 90e8f95227ceb..b1361e4f3c10f 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/search/RestClearScrollAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/search/RestClearScrollAction.java @@ -30,16 +30,15 @@ import java.util.List; import static java.util.Arrays.asList; -import static java.util.Collections.unmodifiableList; import static org.elasticsearch.rest.RestRequest.Method.DELETE; public class RestClearScrollAction extends BaseRestHandler { @Override public List routes() { - return unmodifiableList(asList( + return List.of( new Route(DELETE, "/_search/scroll"), - new Route(DELETE, "/_search/scroll/{scroll_id}"))); + new Route(DELETE, "/_search/scroll/{scroll_id}")); } @Override diff --git a/server/src/main/java/org/elasticsearch/rest/action/search/RestCountAction.java b/server/src/main/java/org/elasticsearch/rest/action/search/RestCountAction.java index cc3211d2bf213..6cc76c0e781ff 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/search/RestCountAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/search/RestCountAction.java @@ -37,8 +37,6 @@ import java.io.IOException; import java.util.List; -import static java.util.Arrays.asList; -import static java.util.Collections.unmodifiableList; import static org.elasticsearch.rest.RestRequest.Method.GET; import static org.elasticsearch.rest.RestRequest.Method.POST; import static org.elasticsearch.rest.action.RestActions.buildBroadcastShardsHeader; @@ -48,11 +46,11 @@ public class RestCountAction extends BaseRestHandler { @Override public List routes() { - return unmodifiableList(asList( + return List.of( new Route(GET, "/_count"), new Route(POST, "/_count"), new Route(GET, "/{index}/_count"), - new Route(POST, "/{index}/_count"))); + new Route(POST, "/{index}/_count")); } @Override diff --git a/server/src/main/java/org/elasticsearch/rest/action/search/RestExplainAction.java b/server/src/main/java/org/elasticsearch/rest/action/search/RestExplainAction.java index 9ee2a4ee79e28..5ca28cd0e9a25 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/search/RestExplainAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/search/RestExplainAction.java @@ -32,8 +32,6 @@ import java.io.IOException; import java.util.List; -import static java.util.Arrays.asList; -import static java.util.Collections.unmodifiableList; import static org.elasticsearch.rest.RestRequest.Method.GET; import static org.elasticsearch.rest.RestRequest.Method.POST; @@ -44,9 +42,9 @@ public class RestExplainAction extends BaseRestHandler { @Override public List routes() { - return unmodifiableList(asList( + return List.of( new Route(GET, "/{index}/_explain/{id}"), - new Route(POST, "/{index}/_explain/{id}"))); + new Route(POST, "/{index}/_explain/{id}")); } @Override diff --git a/server/src/main/java/org/elasticsearch/rest/action/search/RestMultiSearchAction.java b/server/src/main/java/org/elasticsearch/rest/action/search/RestMultiSearchAction.java index 6966e67edeac4..4cef66b5da4b1 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/search/RestMultiSearchAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/search/RestMultiSearchAction.java @@ -43,8 +43,6 @@ import java.util.List; import java.util.Set; -import static java.util.Arrays.asList; -import static java.util.Collections.unmodifiableList; import static org.elasticsearch.rest.RestRequest.Method.GET; import static org.elasticsearch.rest.RestRequest.Method.POST; @@ -67,11 +65,11 @@ public RestMultiSearchAction(Settings settings) { @Override public List routes() { - return unmodifiableList(asList( + return List.of( new Route(GET, "/_msearch"), new Route(POST, "/_msearch"), new Route(GET, "/{index}/_msearch"), - new Route(POST, "/{index}/_msearch"))); + new Route(POST, "/{index}/_msearch")); } @Override diff --git a/server/src/main/java/org/elasticsearch/rest/action/search/RestSearchAction.java b/server/src/main/java/org/elasticsearch/rest/action/search/RestSearchAction.java index 782c613a36277..266ff0321033a 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/search/RestSearchAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/search/RestSearchAction.java @@ -49,8 +49,6 @@ import java.util.Set; import java.util.function.IntConsumer; -import static java.util.Arrays.asList; -import static java.util.Collections.unmodifiableList; import static org.elasticsearch.common.unit.TimeValue.parseTimeValue; import static org.elasticsearch.rest.RestRequest.Method.GET; import static org.elasticsearch.rest.RestRequest.Method.POST; @@ -77,11 +75,11 @@ public String getName() { @Override public List routes() { - return unmodifiableList(asList( + return List.of( new Route(GET, "/_search"), new Route(POST, "/_search"), new Route(GET, "/{index}/_search"), - new Route(POST, "/{index}/_search"))); + new Route(POST, "/{index}/_search")); } @Override diff --git a/server/src/main/java/org/elasticsearch/rest/action/search/RestSearchScrollAction.java b/server/src/main/java/org/elasticsearch/rest/action/search/RestSearchScrollAction.java index 6060574a7dbc7..990d80032c61e 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/search/RestSearchScrollAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/search/RestSearchScrollAction.java @@ -31,8 +31,6 @@ import java.util.List; import java.util.Set; -import static java.util.Arrays.asList; -import static java.util.Collections.unmodifiableList; import static org.elasticsearch.common.unit.TimeValue.parseTimeValue; import static org.elasticsearch.rest.RestRequest.Method.GET; import static org.elasticsearch.rest.RestRequest.Method.POST; @@ -47,11 +45,11 @@ public String getName() { @Override public List routes() { - return unmodifiableList(asList( + return List.of( new Route(GET, "/_search/scroll"), new Route(POST, "/_search/scroll"), new Route(GET, "/_search/scroll/{scroll_id}"), - new Route(POST, "/_search/scroll/{scroll_id}"))); + new Route(POST, "/_search/scroll/{scroll_id}")); } @Override diff --git a/server/src/test/java/org/elasticsearch/action/ActionModuleTests.java b/server/src/test/java/org/elasticsearch/action/ActionModuleTests.java index 1d2c67d6d2b0f..114abe0b2dcb7 100644 --- a/server/src/test/java/org/elasticsearch/action/ActionModuleTests.java +++ b/server/src/test/java/org/elasticsearch/action/ActionModuleTests.java @@ -120,7 +120,7 @@ public void handleRequest(RestRequest request, RestChannel channel, NodeClient c @Override public List routes() { - return singletonList(new Route(Method.GET, "/")); + return List.of(new Route(Method.GET, "/")); } })); assertThat(e.getMessage(), startsWith("Cannot replace existing handler for [/] for method: GET")); @@ -153,7 +153,7 @@ public void testPluginCanRegisterRestHandler() { class FakeHandler implements RestHandler { @Override public List routes() { - return singletonList(new Route(Method.GET, "/_dummy")); + return List.of(new Route(Method.GET, "/_dummy")); } @Override @@ -186,7 +186,7 @@ public void handleRequest(RestRequest request, RestChannel channel, NodeClient c @Override public List routes() { - return singletonList(new Route(Method.GET, "/_dummy")); + return List.of(new Route(Method.GET, "/_dummy")); } })); assertThat(e.getMessage(), startsWith("Cannot replace existing handler for [/_dummy] for method: GET")); diff --git a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/rest/RestCcrStatsAction.java b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/rest/RestCcrStatsAction.java index e320595690a25..0a35710f1a44b 100644 --- a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/rest/RestCcrStatsAction.java +++ b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/rest/RestCcrStatsAction.java @@ -14,14 +14,13 @@ import java.util.List; -import static java.util.Collections.singletonList; import static org.elasticsearch.rest.RestRequest.Method.GET; public class RestCcrStatsAction extends BaseRestHandler { @Override public List routes() { - return singletonList(new Route(GET, "/_ccr/stats")); + return List.of(new Route(GET, "/_ccr/stats")); } @Override diff --git a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/rest/RestDeleteAutoFollowPatternAction.java b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/rest/RestDeleteAutoFollowPatternAction.java index 853b8f7d6da15..8e20bf724cc38 100644 --- a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/rest/RestDeleteAutoFollowPatternAction.java +++ b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/rest/RestDeleteAutoFollowPatternAction.java @@ -13,7 +13,6 @@ import java.util.List; -import static java.util.Collections.singletonList; import static org.elasticsearch.rest.RestRequest.Method.DELETE; import static org.elasticsearch.xpack.core.ccr.action.DeleteAutoFollowPatternAction.INSTANCE; @@ -21,7 +20,7 @@ public class RestDeleteAutoFollowPatternAction extends BaseRestHandler { @Override public List routes() { - return singletonList(new Route(DELETE, "/_ccr/auto_follow/{name}")); + return List.of(new Route(DELETE, "/_ccr/auto_follow/{name}")); } @Override diff --git a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/rest/RestFollowInfoAction.java b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/rest/RestFollowInfoAction.java index e9763a43a7b07..35d644b80aeb6 100644 --- a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/rest/RestFollowInfoAction.java +++ b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/rest/RestFollowInfoAction.java @@ -15,14 +15,13 @@ import java.util.List; -import static java.util.Collections.singletonList; import static org.elasticsearch.rest.RestRequest.Method.GET; public class RestFollowInfoAction extends BaseRestHandler { @Override public List routes() { - return singletonList(new Route(GET, "/{index}/_ccr/info")); + return List.of(new Route(GET, "/{index}/_ccr/info")); } @Override diff --git a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/rest/RestFollowStatsAction.java b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/rest/RestFollowStatsAction.java index 2eed47b0a7abc..68fe41ed94819 100644 --- a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/rest/RestFollowStatsAction.java +++ b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/rest/RestFollowStatsAction.java @@ -15,14 +15,13 @@ import java.util.List; -import static java.util.Collections.singletonList; import static org.elasticsearch.rest.RestRequest.Method.GET; public class RestFollowStatsAction extends BaseRestHandler { @Override public List routes() { - return singletonList(new Route(GET, "/{index}/_ccr/stats")); + return List.of(new Route(GET, "/{index}/_ccr/stats")); } @Override diff --git a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/rest/RestForgetFollowerAction.java b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/rest/RestForgetFollowerAction.java index bb8246a7a780b..438347e2d8f77 100644 --- a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/rest/RestForgetFollowerAction.java +++ b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/rest/RestForgetFollowerAction.java @@ -17,14 +17,13 @@ import java.io.IOException; import java.util.List; -import static java.util.Collections.singletonList; import static org.elasticsearch.rest.RestRequest.Method.POST; public class RestForgetFollowerAction extends BaseRestHandler { @Override public List routes() { - return singletonList(new Route(POST, "/{index}/_ccr/forget_follower")); + return List.of(new Route(POST, "/{index}/_ccr/forget_follower")); } @Override diff --git a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/rest/RestGetAutoFollowPatternAction.java b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/rest/RestGetAutoFollowPatternAction.java index 7a7454c02fe18..e4bf5edc089d5 100644 --- a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/rest/RestGetAutoFollowPatternAction.java +++ b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/rest/RestGetAutoFollowPatternAction.java @@ -13,8 +13,6 @@ import java.util.List; -import static java.util.Arrays.asList; -import static java.util.Collections.unmodifiableList; import static org.elasticsearch.rest.RestRequest.Method.GET; import static org.elasticsearch.xpack.core.ccr.action.GetAutoFollowPatternAction.INSTANCE; @@ -22,9 +20,9 @@ public class RestGetAutoFollowPatternAction extends BaseRestHandler { @Override public List routes() { - return unmodifiableList(asList( + return List.of( new Route(GET, "/_ccr/auto_follow/{name}"), - new Route(GET, "/_ccr/auto_follow"))); + new Route(GET, "/_ccr/auto_follow")); } @Override diff --git a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/rest/RestPauseAutoFollowPatternAction.java b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/rest/RestPauseAutoFollowPatternAction.java index 04d6747a78aaf..2b6fcd5fa84a1 100644 --- a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/rest/RestPauseAutoFollowPatternAction.java +++ b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/rest/RestPauseAutoFollowPatternAction.java @@ -13,7 +13,6 @@ import java.util.List; -import static java.util.Collections.singletonList; import static org.elasticsearch.rest.RestRequest.Method.POST; import static org.elasticsearch.xpack.core.ccr.action.ActivateAutoFollowPatternAction.INSTANCE; @@ -21,7 +20,7 @@ public class RestPauseAutoFollowPatternAction extends BaseRestHandler { @Override public List routes() { - return singletonList(new Route(POST, "/_ccr/auto_follow/{name}/pause")); + return List.of(new Route(POST, "/_ccr/auto_follow/{name}/pause")); } @Override diff --git a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/rest/RestPauseFollowAction.java b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/rest/RestPauseFollowAction.java index 2bfec8f87e28b..747104e9c923e 100644 --- a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/rest/RestPauseFollowAction.java +++ b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/rest/RestPauseFollowAction.java @@ -12,7 +12,6 @@ import java.util.List; -import static java.util.Collections.singletonList; import static org.elasticsearch.rest.RestRequest.Method.POST; import static org.elasticsearch.xpack.core.ccr.action.PauseFollowAction.INSTANCE; import static org.elasticsearch.xpack.core.ccr.action.PauseFollowAction.Request; @@ -21,7 +20,7 @@ public class RestPauseFollowAction extends BaseRestHandler { @Override public List routes() { - return singletonList(new Route(POST, "/{index}/_ccr/pause_follow")); + return List.of(new Route(POST, "/{index}/_ccr/pause_follow")); } @Override diff --git a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/rest/RestPutAutoFollowPatternAction.java b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/rest/RestPutAutoFollowPatternAction.java index 5593aa7ac6155..3846438bbac1d 100644 --- a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/rest/RestPutAutoFollowPatternAction.java +++ b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/rest/RestPutAutoFollowPatternAction.java @@ -15,7 +15,6 @@ import java.io.IOException; import java.util.List; -import static java.util.Collections.singletonList; import static org.elasticsearch.rest.RestRequest.Method.PUT; import static org.elasticsearch.xpack.core.ccr.action.PutAutoFollowPatternAction.INSTANCE; @@ -23,7 +22,7 @@ public class RestPutAutoFollowPatternAction extends BaseRestHandler { @Override public List routes() { - return singletonList(new Route(PUT, "/_ccr/auto_follow/{name}")); + return List.of(new Route(PUT, "/_ccr/auto_follow/{name}")); } @Override diff --git a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/rest/RestPutFollowAction.java b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/rest/RestPutFollowAction.java index 9ee161555bdca..3e90f8f04121a 100644 --- a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/rest/RestPutFollowAction.java +++ b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/rest/RestPutFollowAction.java @@ -15,7 +15,6 @@ import java.io.IOException; import java.util.List; -import static java.util.Collections.singletonList; import static org.elasticsearch.rest.RestRequest.Method.PUT; import static org.elasticsearch.xpack.core.ccr.action.PutFollowAction.INSTANCE; import static org.elasticsearch.xpack.core.ccr.action.PutFollowAction.Request; @@ -24,7 +23,7 @@ public class RestPutFollowAction extends BaseRestHandler { @Override public List routes() { - return singletonList(new Route(PUT, "/{index}/_ccr/follow")); + return List.of(new Route(PUT, "/{index}/_ccr/follow")); } @Override diff --git a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/rest/RestResumeAutoFollowPatternAction.java b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/rest/RestResumeAutoFollowPatternAction.java index e20c038dff1e0..1938157a0c23c 100644 --- a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/rest/RestResumeAutoFollowPatternAction.java +++ b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/rest/RestResumeAutoFollowPatternAction.java @@ -13,7 +13,6 @@ import java.util.List; -import static java.util.Collections.singletonList; import static org.elasticsearch.rest.RestRequest.Method.POST; import static org.elasticsearch.xpack.core.ccr.action.ActivateAutoFollowPatternAction.INSTANCE; @@ -21,7 +20,7 @@ public class RestResumeAutoFollowPatternAction extends BaseRestHandler { @Override public List routes() { - return singletonList(new Route(POST, "/_ccr/auto_follow/{name}/resume")); + return List.of(new Route(POST, "/_ccr/auto_follow/{name}/resume")); } @Override diff --git a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/rest/RestResumeFollowAction.java b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/rest/RestResumeFollowAction.java index 146700888cfc8..a6bc255bfca7e 100644 --- a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/rest/RestResumeFollowAction.java +++ b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/rest/RestResumeFollowAction.java @@ -14,7 +14,6 @@ import java.io.IOException; import java.util.List; -import static java.util.Collections.singletonList; import static org.elasticsearch.rest.RestRequest.Method.POST; import static org.elasticsearch.xpack.core.ccr.action.ResumeFollowAction.INSTANCE; import static org.elasticsearch.xpack.core.ccr.action.ResumeFollowAction.Request; @@ -23,7 +22,7 @@ public class RestResumeFollowAction extends BaseRestHandler { @Override public List routes() { - return singletonList(new Route(POST, "/{index}/_ccr/resume_follow")); + return List.of(new Route(POST, "/{index}/_ccr/resume_follow")); } @Override diff --git a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/rest/RestUnfollowAction.java b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/rest/RestUnfollowAction.java index 0effd10b7f196..2e1d9645e5f3b 100644 --- a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/rest/RestUnfollowAction.java +++ b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/rest/RestUnfollowAction.java @@ -14,7 +14,6 @@ import java.util.List; -import static java.util.Collections.singletonList; import static org.elasticsearch.rest.RestRequest.Method.POST; import static org.elasticsearch.xpack.core.ccr.action.UnfollowAction.INSTANCE; @@ -22,7 +21,7 @@ public class RestUnfollowAction extends BaseRestHandler { @Override public List routes() { - return singletonList(new Route(POST, "/{index}/_ccr/unfollow")); + return List.of(new Route(POST, "/{index}/_ccr/unfollow")); } @Override diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/license/RestDeleteLicenseAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/license/RestDeleteLicenseAction.java index 0addc72d201da..91c99c553ae2f 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/license/RestDeleteLicenseAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/license/RestDeleteLicenseAction.java @@ -15,7 +15,6 @@ import java.io.IOException; import java.util.List; -import static java.util.Collections.singletonList; import static org.elasticsearch.rest.RestRequest.Method.DELETE; public class RestDeleteLicenseAction extends BaseRestHandler { @@ -24,7 +23,7 @@ public class RestDeleteLicenseAction extends BaseRestHandler { @Override public List routes() { - return singletonList(new Route(DELETE, "/_license")); + return List.of(new Route(DELETE, "/_license")); } @Override diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/license/RestGetBasicStatus.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/license/RestGetBasicStatus.java index baf17b2cd75a4..3186f05198696 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/license/RestGetBasicStatus.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/license/RestGetBasicStatus.java @@ -13,7 +13,6 @@ import java.util.List; -import static java.util.Collections.singletonList; import static org.elasticsearch.rest.RestRequest.Method.GET; public class RestGetBasicStatus extends BaseRestHandler { @@ -22,7 +21,7 @@ public class RestGetBasicStatus extends BaseRestHandler { @Override public List routes() { - return singletonList(new Route(GET, "/_license/basic_status")); + return List.of(new Route(GET, "/_license/basic_status")); } @Override diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/license/RestGetLicenseAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/license/RestGetLicenseAction.java index 33b013954be97..0093d8dee6a63 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/license/RestGetLicenseAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/license/RestGetLicenseAction.java @@ -23,7 +23,6 @@ import java.util.List; import java.util.Map; -import static java.util.Collections.singletonList; import static org.elasticsearch.rest.RestRequest.Method.GET; import static org.elasticsearch.rest.RestStatus.NOT_FOUND; import static org.elasticsearch.rest.RestStatus.OK; @@ -36,7 +35,7 @@ public class RestGetLicenseAction extends BaseRestHandler { @Override public List routes() { - return singletonList(new Route(GET, "/_license")); + return List.of(new Route(GET, "/_license")); } @Override diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/license/RestGetTrialStatus.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/license/RestGetTrialStatus.java index ea90b85f15e61..7e9ea2ec964f4 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/license/RestGetTrialStatus.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/license/RestGetTrialStatus.java @@ -13,7 +13,6 @@ import java.util.List; -import static java.util.Collections.singletonList; import static org.elasticsearch.rest.RestRequest.Method.GET; public class RestGetTrialStatus extends BaseRestHandler { @@ -22,7 +21,7 @@ public class RestGetTrialStatus extends BaseRestHandler { @Override public List routes() { - return singletonList(new Route(GET, "/_license/trial_status")); + return List.of(new Route(GET, "/_license/trial_status")); } @Override diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/license/RestPostStartBasicLicense.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/license/RestPostStartBasicLicense.java index 2346e143cc7e0..95ba58711cd5f 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/license/RestPostStartBasicLicense.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/license/RestPostStartBasicLicense.java @@ -14,7 +14,6 @@ import java.io.IOException; import java.util.List; -import static java.util.Collections.singletonList; import static org.elasticsearch.rest.RestRequest.Method.POST; public class RestPostStartBasicLicense extends BaseRestHandler { @@ -23,7 +22,7 @@ public class RestPostStartBasicLicense extends BaseRestHandler { @Override public List routes() { - return singletonList(new Route(POST, "/_license/start_basic")); + return List.of(new Route(POST, "/_license/start_basic")); } @Override diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/license/RestPostStartTrialLicense.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/license/RestPostStartTrialLicense.java index b9ecb91c9eb27..3aefb47eb8729 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/license/RestPostStartTrialLicense.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/license/RestPostStartTrialLicense.java @@ -18,7 +18,6 @@ import java.util.List; import java.util.Map; -import static java.util.Collections.singletonList; import static org.elasticsearch.rest.RestRequest.Method.POST; public class RestPostStartTrialLicense extends BaseRestHandler { @@ -27,7 +26,7 @@ public class RestPostStartTrialLicense extends BaseRestHandler { @Override public List routes() { - return singletonList(new Route(POST, "/_license/start_trial")); + return List.of(new Route(POST, "/_license/start_trial")); } @Override diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/license/RestPutLicenseAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/license/RestPutLicenseAction.java index 4634a56c66f9f..bbaad5cc36c14 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/license/RestPutLicenseAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/license/RestPutLicenseAction.java @@ -14,8 +14,6 @@ import java.io.IOException; import java.util.List; -import static java.util.Arrays.asList; -import static java.util.Collections.unmodifiableList; import static org.elasticsearch.rest.RestRequest.Method.POST; import static org.elasticsearch.rest.RestRequest.Method.PUT; @@ -26,9 +24,9 @@ public class RestPutLicenseAction extends BaseRestHandler { @Override public List routes() { // TODO: remove POST endpoint? - return unmodifiableList(asList( + return List.of( new Route(POST, "/_license"), - new Route(PUT, "/_license"))); + new Route(PUT, "/_license")); } @Override diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/rest/action/RestReloadAnalyzersAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/rest/action/RestReloadAnalyzersAction.java index 8d118960ed1f2..644c95cf3d12f 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/rest/action/RestReloadAnalyzersAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/rest/action/RestReloadAnalyzersAction.java @@ -17,8 +17,6 @@ import java.io.IOException; import java.util.List; -import static java.util.Arrays.asList; -import static java.util.Collections.unmodifiableList; import static org.elasticsearch.rest.RestRequest.Method.GET; import static org.elasticsearch.rest.RestRequest.Method.POST; @@ -26,9 +24,9 @@ public class RestReloadAnalyzersAction extends BaseRestHandler { @Override public List routes() { - return unmodifiableList(asList( + return List.of( new Route(GET, "/{index}/_reload_search_analyzers"), - new Route(POST, "/{index}/_reload_search_analyzers"))); + new Route(POST, "/{index}/_reload_search_analyzers")); } @Override diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/rest/action/RestXPackInfoAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/rest/action/RestXPackInfoAction.java index 6d83cd97e0df8..22104f973f831 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/rest/action/RestXPackInfoAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/rest/action/RestXPackInfoAction.java @@ -16,8 +16,6 @@ import java.util.EnumSet; import java.util.List; -import static java.util.Arrays.asList; -import static java.util.Collections.unmodifiableList; import static org.elasticsearch.rest.RestRequest.Method.GET; import static org.elasticsearch.rest.RestRequest.Method.HEAD; @@ -25,9 +23,9 @@ public class RestXPackInfoAction extends BaseRestHandler { @Override public List routes() { - return unmodifiableList(asList( + return List.of( new Route(GET, "/_xpack"), - new Route(HEAD, "/_xpack"))); + new Route(HEAD, "/_xpack")); } @Override diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/rest/action/RestXPackUsageAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/rest/action/RestXPackUsageAction.java index 86bfd8f5241f9..22ccc81927783 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/rest/action/RestXPackUsageAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/rest/action/RestXPackUsageAction.java @@ -21,7 +21,6 @@ import java.io.IOException; import java.util.List; -import static java.util.Collections.singletonList; import static org.elasticsearch.rest.RestRequest.Method.GET; import static org.elasticsearch.rest.RestStatus.OK; @@ -29,7 +28,7 @@ public class RestXPackUsageAction extends BaseRestHandler { @Override public List routes() { - return singletonList(new Route(GET, "/_xpack/usage")); + return List.of(new Route(GET, "/_xpack/usage")); } @Override diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ssl/rest/RestGetCertificateInfoAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ssl/rest/RestGetCertificateInfoAction.java index 3f6348b0b6ac2..ec25879f87772 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ssl/rest/RestGetCertificateInfoAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ssl/rest/RestGetCertificateInfoAction.java @@ -18,7 +18,6 @@ import java.util.List; -import static java.util.Collections.singletonList; import static org.elasticsearch.rest.RestRequest.Method.GET; /** @@ -29,7 +28,7 @@ public class RestGetCertificateInfoAction extends BaseRestHandler { @Override public List routes() { - return singletonList(new Route(GET, "/_ssl/certificates")); + return List.of(new Route(GET, "/_ssl/certificates")); } @Override diff --git a/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/RestDeprecationInfoAction.java b/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/RestDeprecationInfoAction.java index 1070d90d233e3..3b2ac7afcc48e 100644 --- a/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/RestDeprecationInfoAction.java +++ b/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/RestDeprecationInfoAction.java @@ -16,17 +16,15 @@ import java.io.IOException; import java.util.List; -import static java.util.Arrays.asList; -import static java.util.Collections.unmodifiableList; import static org.elasticsearch.rest.RestRequest.Method.GET; public class RestDeprecationInfoAction extends BaseRestHandler { @Override public List routes() { - return unmodifiableList(asList( + return List.of( new Route(GET, "/_migration/deprecations"), - new Route(GET, "/{index}/_migration/deprecations"))); + new Route(GET, "/{index}/_migration/deprecations")); } @Override diff --git a/x-pack/plugin/enrich/src/main/java/org/elasticsearch/xpack/enrich/rest/RestDeleteEnrichPolicyAction.java b/x-pack/plugin/enrich/src/main/java/org/elasticsearch/xpack/enrich/rest/RestDeleteEnrichPolicyAction.java index c8ff6fa5337de..0a28b3f9215a3 100644 --- a/x-pack/plugin/enrich/src/main/java/org/elasticsearch/xpack/enrich/rest/RestDeleteEnrichPolicyAction.java +++ b/x-pack/plugin/enrich/src/main/java/org/elasticsearch/xpack/enrich/rest/RestDeleteEnrichPolicyAction.java @@ -14,14 +14,13 @@ import java.io.IOException; import java.util.List; -import static java.util.Collections.singletonList; import static org.elasticsearch.rest.RestRequest.Method.DELETE; public class RestDeleteEnrichPolicyAction extends BaseRestHandler { @Override public List routes() { - return singletonList(new Route(DELETE, "/_enrich/policy/{name}")); + return List.of(new Route(DELETE, "/_enrich/policy/{name}")); } @Override diff --git a/x-pack/plugin/enrich/src/main/java/org/elasticsearch/xpack/enrich/rest/RestEnrichStatsAction.java b/x-pack/plugin/enrich/src/main/java/org/elasticsearch/xpack/enrich/rest/RestEnrichStatsAction.java index 4b74bcd3a64c0..808b3eea29968 100644 --- a/x-pack/plugin/enrich/src/main/java/org/elasticsearch/xpack/enrich/rest/RestEnrichStatsAction.java +++ b/x-pack/plugin/enrich/src/main/java/org/elasticsearch/xpack/enrich/rest/RestEnrichStatsAction.java @@ -14,14 +14,13 @@ import java.io.IOException; import java.util.List; -import static java.util.Collections.singletonList; import static org.elasticsearch.rest.RestRequest.Method.GET; public class RestEnrichStatsAction extends BaseRestHandler { @Override public List routes() { - return singletonList(new Route(GET, "/_enrich/_stats")); + return List.of(new Route(GET, "/_enrich/_stats")); } @Override diff --git a/x-pack/plugin/enrich/src/main/java/org/elasticsearch/xpack/enrich/rest/RestExecuteEnrichPolicyAction.java b/x-pack/plugin/enrich/src/main/java/org/elasticsearch/xpack/enrich/rest/RestExecuteEnrichPolicyAction.java index c6515876a7615..921456ae4b5ce 100644 --- a/x-pack/plugin/enrich/src/main/java/org/elasticsearch/xpack/enrich/rest/RestExecuteEnrichPolicyAction.java +++ b/x-pack/plugin/enrich/src/main/java/org/elasticsearch/xpack/enrich/rest/RestExecuteEnrichPolicyAction.java @@ -14,8 +14,6 @@ import java.io.IOException; import java.util.List; -import static java.util.Arrays.asList; -import static java.util.Collections.unmodifiableList; import static org.elasticsearch.rest.RestRequest.Method.POST; import static org.elasticsearch.rest.RestRequest.Method.PUT; @@ -23,9 +21,7 @@ public class RestExecuteEnrichPolicyAction extends BaseRestHandler { @Override public List routes() { - return unmodifiableList( - asList(new Route(POST, "/_enrich/policy/{name}/_execute"), new Route(PUT, "/_enrich/policy/{name}/_execute")) - ); + return List.of(new Route(POST, "/_enrich/policy/{name}/_execute"), new Route(PUT, "/_enrich/policy/{name}/_execute")); } @Override diff --git a/x-pack/plugin/enrich/src/main/java/org/elasticsearch/xpack/enrich/rest/RestGetEnrichPolicyAction.java b/x-pack/plugin/enrich/src/main/java/org/elasticsearch/xpack/enrich/rest/RestGetEnrichPolicyAction.java index 06e516592f7f6..6368062d49eff 100644 --- a/x-pack/plugin/enrich/src/main/java/org/elasticsearch/xpack/enrich/rest/RestGetEnrichPolicyAction.java +++ b/x-pack/plugin/enrich/src/main/java/org/elasticsearch/xpack/enrich/rest/RestGetEnrichPolicyAction.java @@ -15,15 +15,13 @@ import java.io.IOException; import java.util.List; -import static java.util.Arrays.asList; -import static java.util.Collections.unmodifiableList; import static org.elasticsearch.rest.RestRequest.Method.GET; public class RestGetEnrichPolicyAction extends BaseRestHandler { @Override public List routes() { - return unmodifiableList(asList(new Route(GET, "/_enrich/policy/{name}"), new Route(GET, "/_enrich/policy"))); + return List.of(new Route(GET, "/_enrich/policy/{name}"), new Route(GET, "/_enrich/policy")); } @Override diff --git a/x-pack/plugin/enrich/src/main/java/org/elasticsearch/xpack/enrich/rest/RestPutEnrichPolicyAction.java b/x-pack/plugin/enrich/src/main/java/org/elasticsearch/xpack/enrich/rest/RestPutEnrichPolicyAction.java index 8750891d34db0..4f646b32380f1 100644 --- a/x-pack/plugin/enrich/src/main/java/org/elasticsearch/xpack/enrich/rest/RestPutEnrichPolicyAction.java +++ b/x-pack/plugin/enrich/src/main/java/org/elasticsearch/xpack/enrich/rest/RestPutEnrichPolicyAction.java @@ -15,14 +15,13 @@ import java.io.IOException; import java.util.List; -import static java.util.Collections.singletonList; import static org.elasticsearch.rest.RestRequest.Method.PUT; public class RestPutEnrichPolicyAction extends BaseRestHandler { @Override public List routes() { - return singletonList(new Route(PUT, "/_enrich/policy/{name}")); + return List.of(new Route(PUT, "/_enrich/policy/{name}")); } @Override diff --git a/x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/plugin/RestEqlSearchAction.java b/x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/plugin/RestEqlSearchAction.java index c81b1b0319465..2c82a02e8f137 100644 --- a/x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/plugin/RestEqlSearchAction.java +++ b/x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/plugin/RestEqlSearchAction.java @@ -23,8 +23,6 @@ import java.io.IOException; import java.util.List; -import static java.util.Arrays.asList; -import static java.util.Collections.unmodifiableList; import static org.elasticsearch.rest.RestRequest.Method.GET; import static org.elasticsearch.rest.RestRequest.Method.POST; @@ -33,9 +31,9 @@ public class RestEqlSearchAction extends BaseRestHandler { @Override public List routes() { - return unmodifiableList(asList( + return List.of( new Route(GET, SEARCH_PATH), - new Route(POST, SEARCH_PATH))); + new Route(POST, SEARCH_PATH)); } @Override diff --git a/x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/plugin/RestEqlStatsAction.java b/x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/plugin/RestEqlStatsAction.java index cea859c359995..2d4f6ebb8fb8e 100644 --- a/x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/plugin/RestEqlStatsAction.java +++ b/x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/plugin/RestEqlStatsAction.java @@ -11,7 +11,6 @@ import org.elasticsearch.rest.RestRequest; import org.elasticsearch.rest.action.RestActions; -import java.util.Collections; import java.util.List; import static org.elasticsearch.rest.RestRequest.Method.GET; @@ -24,7 +23,7 @@ protected RestEqlStatsAction() { @Override public List routes() { - return Collections.singletonList(new Route(GET, "/_eql/stats")); + return List.of(new Route(GET, "/_eql/stats")); } @Override diff --git a/x-pack/plugin/frozen-indices/src/main/java/org/elasticsearch/xpack/frozen/rest/action/RestFreezeIndexAction.java b/x-pack/plugin/frozen-indices/src/main/java/org/elasticsearch/xpack/frozen/rest/action/RestFreezeIndexAction.java index 96cde5f4e3a22..51cfe34836ec1 100644 --- a/x-pack/plugin/frozen-indices/src/main/java/org/elasticsearch/xpack/frozen/rest/action/RestFreezeIndexAction.java +++ b/x-pack/plugin/frozen-indices/src/main/java/org/elasticsearch/xpack/frozen/rest/action/RestFreezeIndexAction.java @@ -17,17 +17,15 @@ import java.util.List; -import static java.util.Arrays.asList; -import static java.util.Collections.unmodifiableList; import static org.elasticsearch.rest.RestRequest.Method.POST; public final class RestFreezeIndexAction extends BaseRestHandler { @Override public List routes() { - return unmodifiableList(asList( + return List.of( new Route(POST, "/{index}/_freeze"), - new Route(POST, "/{index}/_unfreeze"))); + new Route(POST, "/{index}/_unfreeze")); } @Override diff --git a/x-pack/plugin/graph/src/main/java/org/elasticsearch/xpack/graph/rest/action/RestGraphAction.java b/x-pack/plugin/graph/src/main/java/org/elasticsearch/xpack/graph/rest/action/RestGraphAction.java index e84b2441d6bbb..22873fbd6926d 100644 --- a/x-pack/plugin/graph/src/main/java/org/elasticsearch/xpack/graph/rest/action/RestGraphAction.java +++ b/x-pack/plugin/graph/src/main/java/org/elasticsearch/xpack/graph/rest/action/RestGraphAction.java @@ -27,8 +27,6 @@ import java.util.List; import java.util.Map; -import static java.util.Arrays.asList; -import static java.util.Collections.unmodifiableList; import static org.elasticsearch.index.query.AbstractQueryBuilder.parseInnerQueryBuilder; import static org.elasticsearch.rest.RestRequest.Method.GET; import static org.elasticsearch.rest.RestRequest.Method.POST; @@ -60,9 +58,9 @@ public class RestGraphAction extends BaseRestHandler { @Override public List routes() { - return unmodifiableList(asList( + return List.of( new Route(GET, "/{index}/_graph/explore"), - new Route(POST, "/{index}/_graph/explore"))); + new Route(POST, "/{index}/_graph/explore")); } @Override diff --git a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/ilm/action/RestDeleteLifecycleAction.java b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/ilm/action/RestDeleteLifecycleAction.java index e2155b0b1698b..fda0bf12ae70c 100644 --- a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/ilm/action/RestDeleteLifecycleAction.java +++ b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/ilm/action/RestDeleteLifecycleAction.java @@ -14,14 +14,13 @@ import java.util.List; -import static java.util.Collections.singletonList; import static org.elasticsearch.rest.RestRequest.Method.DELETE; public class RestDeleteLifecycleAction extends BaseRestHandler { @Override public List routes() { - return singletonList(new Route(DELETE, "/_ilm/policy/{name}")); + return List.of(new Route(DELETE, "/_ilm/policy/{name}")); } @Override diff --git a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/ilm/action/RestExplainLifecycleAction.java b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/ilm/action/RestExplainLifecycleAction.java index 68b843794274a..510d76c796653 100644 --- a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/ilm/action/RestExplainLifecycleAction.java +++ b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/ilm/action/RestExplainLifecycleAction.java @@ -17,14 +17,13 @@ import java.util.List; -import static java.util.Collections.singletonList; import static org.elasticsearch.rest.RestRequest.Method.GET; public class RestExplainLifecycleAction extends BaseRestHandler { @Override public List routes() { - return singletonList(new Route(GET, "/{index}/_ilm/explain")); + return List.of(new Route(GET, "/{index}/_ilm/explain")); } @Override diff --git a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/ilm/action/RestGetLifecycleAction.java b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/ilm/action/RestGetLifecycleAction.java index df4af5ff58957..0c07f898114c7 100644 --- a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/ilm/action/RestGetLifecycleAction.java +++ b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/ilm/action/RestGetLifecycleAction.java @@ -15,17 +15,15 @@ import java.util.List; -import static java.util.Arrays.asList; -import static java.util.Collections.unmodifiableList; import static org.elasticsearch.rest.RestRequest.Method.GET; public class RestGetLifecycleAction extends BaseRestHandler { @Override public List routes() { - return unmodifiableList(asList( + return List.of( new Route(GET, "/_ilm/policy"), - new Route(GET, "/_ilm/policy/{name}"))); + new Route(GET, "/_ilm/policy/{name}")); } @Override diff --git a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/ilm/action/RestGetStatusAction.java b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/ilm/action/RestGetStatusAction.java index 1eb822ba765c3..959ec55c54c47 100644 --- a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/ilm/action/RestGetStatusAction.java +++ b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/ilm/action/RestGetStatusAction.java @@ -14,14 +14,13 @@ import java.util.List; -import static java.util.Collections.singletonList; import static org.elasticsearch.rest.RestRequest.Method.GET; public class RestGetStatusAction extends BaseRestHandler { @Override public List routes() { - return singletonList(new Route(GET, "/_ilm/status")); + return List.of(new Route(GET, "/_ilm/status")); } @Override diff --git a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/ilm/action/RestMoveToStepAction.java b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/ilm/action/RestMoveToStepAction.java index 0f072787d3f5f..40b2c47f841a9 100644 --- a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/ilm/action/RestMoveToStepAction.java +++ b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/ilm/action/RestMoveToStepAction.java @@ -17,14 +17,13 @@ import java.io.IOException; import java.util.List; -import static java.util.Collections.singletonList; import static org.elasticsearch.rest.RestRequest.Method.POST; public class RestMoveToStepAction extends BaseRestHandler { @Override public List routes() { - return singletonList(new Route(POST, "/_ilm/move/{name}")); + return List.of(new Route(POST, "/_ilm/move/{name}")); } @Override diff --git a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/ilm/action/RestPutLifecycleAction.java b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/ilm/action/RestPutLifecycleAction.java index 9f2f199ca6025..3a83a493b1d78 100644 --- a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/ilm/action/RestPutLifecycleAction.java +++ b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/ilm/action/RestPutLifecycleAction.java @@ -16,14 +16,13 @@ import java.io.IOException; import java.util.List; -import static java.util.Collections.singletonList; import static org.elasticsearch.rest.RestRequest.Method.PUT; public class RestPutLifecycleAction extends BaseRestHandler { @Override public List routes() { - return singletonList(new Route(PUT, "/_ilm/policy/{name}")); + return List.of(new Route(PUT, "/_ilm/policy/{name}")); } @Override diff --git a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/ilm/action/RestRemoveIndexLifecyclePolicyAction.java b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/ilm/action/RestRemoveIndexLifecyclePolicyAction.java index b10b2e4e282f8..761cc3a434c33 100644 --- a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/ilm/action/RestRemoveIndexLifecyclePolicyAction.java +++ b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/ilm/action/RestRemoveIndexLifecyclePolicyAction.java @@ -16,14 +16,13 @@ import java.util.List; -import static java.util.Collections.singletonList; import static org.elasticsearch.rest.RestRequest.Method.POST; public class RestRemoveIndexLifecyclePolicyAction extends BaseRestHandler { @Override public List routes() { - return singletonList(new Route(POST, "/{index}/_ilm/remove")); + return List.of(new Route(POST, "/{index}/_ilm/remove")); } @Override diff --git a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/ilm/action/RestRetryAction.java b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/ilm/action/RestRetryAction.java index 765ba44d1ffd3..bc6d63060dbac 100644 --- a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/ilm/action/RestRetryAction.java +++ b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/ilm/action/RestRetryAction.java @@ -17,14 +17,13 @@ import java.util.List; -import static java.util.Collections.singletonList; import static org.elasticsearch.rest.RestRequest.Method.POST; public class RestRetryAction extends BaseRestHandler { @Override public List routes() { - return singletonList(new Route(POST, "/{index}/_ilm/retry")); + return List.of(new Route(POST, "/{index}/_ilm/retry")); } @Override diff --git a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/ilm/action/RestStartILMAction.java b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/ilm/action/RestStartILMAction.java index f60ae2297d7fe..4912a14a00355 100644 --- a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/ilm/action/RestStartILMAction.java +++ b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/ilm/action/RestStartILMAction.java @@ -15,14 +15,13 @@ import java.util.List; -import static java.util.Collections.singletonList; import static org.elasticsearch.rest.RestRequest.Method.POST; public class RestStartILMAction extends BaseRestHandler { @Override public List routes() { - return singletonList(new Route(POST, "/_ilm/start")); + return List.of(new Route(POST, "/_ilm/start")); } @Override diff --git a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/ilm/action/RestStopAction.java b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/ilm/action/RestStopAction.java index 8b748ee677ffe..f7bb4a8786903 100644 --- a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/ilm/action/RestStopAction.java +++ b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/ilm/action/RestStopAction.java @@ -15,14 +15,13 @@ import java.util.List; -import static java.util.Collections.singletonList; import static org.elasticsearch.rest.RestRequest.Method.POST; public class RestStopAction extends BaseRestHandler { @Override public List routes() { - return singletonList(new Route(POST, "/_ilm/stop")); + return List.of(new Route(POST, "/_ilm/stop")); } @Override diff --git a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/slm/action/RestDeleteSnapshotLifecycleAction.java b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/slm/action/RestDeleteSnapshotLifecycleAction.java index fad46639bcc0f..ecf9d8c944456 100644 --- a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/slm/action/RestDeleteSnapshotLifecycleAction.java +++ b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/slm/action/RestDeleteSnapshotLifecycleAction.java @@ -14,14 +14,13 @@ import java.util.List; -import static java.util.Collections.singletonList; import static org.elasticsearch.rest.RestRequest.Method.DELETE; public class RestDeleteSnapshotLifecycleAction extends BaseRestHandler { @Override public List routes() { - return singletonList(new Route(DELETE, "/_slm/policy/{name}")); + return List.of(new Route(DELETE, "/_slm/policy/{name}")); } @Override diff --git a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/slm/action/RestExecuteSnapshotLifecycleAction.java b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/slm/action/RestExecuteSnapshotLifecycleAction.java index 093c52ffbe3ce..51b21653ef40d 100644 --- a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/slm/action/RestExecuteSnapshotLifecycleAction.java +++ b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/slm/action/RestExecuteSnapshotLifecycleAction.java @@ -14,8 +14,6 @@ import java.util.List; -import static java.util.Arrays.asList; -import static java.util.Collections.unmodifiableList; import static org.elasticsearch.rest.RestRequest.Method.POST; import static org.elasticsearch.rest.RestRequest.Method.PUT; @@ -23,9 +21,9 @@ public class RestExecuteSnapshotLifecycleAction extends BaseRestHandler { @Override public List routes() { - return unmodifiableList(asList( + return List.of( new Route(POST, "/_slm/policy/{name}/_execute"), - new Route(PUT, "/_slm/policy/{name}/_execute"))); + new Route(PUT, "/_slm/policy/{name}/_execute")); } @Override diff --git a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/slm/action/RestExecuteSnapshotRetentionAction.java b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/slm/action/RestExecuteSnapshotRetentionAction.java index 326ee5294e52c..8badaf40ced0e 100644 --- a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/slm/action/RestExecuteSnapshotRetentionAction.java +++ b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/slm/action/RestExecuteSnapshotRetentionAction.java @@ -14,14 +14,13 @@ import java.util.List; -import static java.util.Collections.singletonList; import static org.elasticsearch.rest.RestRequest.Method.POST; public class RestExecuteSnapshotRetentionAction extends BaseRestHandler { @Override public List routes() { - return singletonList(new Route(POST, "/_slm/_execute_retention")); + return List.of(new Route(POST, "/_slm/_execute_retention")); } @Override diff --git a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/slm/action/RestGetSLMStatusAction.java b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/slm/action/RestGetSLMStatusAction.java index f728fb314ddce..c998e81eec9d3 100644 --- a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/slm/action/RestGetSLMStatusAction.java +++ b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/slm/action/RestGetSLMStatusAction.java @@ -14,14 +14,13 @@ import java.util.List; -import static java.util.Collections.singletonList; import static org.elasticsearch.rest.RestRequest.Method.GET; public class RestGetSLMStatusAction extends BaseRestHandler { @Override public List routes() { - return singletonList(new Route(GET, "/_slm/status")); + return List.of(new Route(GET, "/_slm/status")); } @Override diff --git a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/slm/action/RestGetSnapshotLifecycleAction.java b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/slm/action/RestGetSnapshotLifecycleAction.java index 6b7841802599a..893b29eda7b81 100644 --- a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/slm/action/RestGetSnapshotLifecycleAction.java +++ b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/slm/action/RestGetSnapshotLifecycleAction.java @@ -15,17 +15,15 @@ import java.util.List; -import static java.util.Arrays.asList; -import static java.util.Collections.unmodifiableList; import static org.elasticsearch.rest.RestRequest.Method.GET; public class RestGetSnapshotLifecycleAction extends BaseRestHandler { @Override public List routes() { - return unmodifiableList(asList( + return List.of( new Route(GET, "/_slm/policy"), - new Route(GET, "/_slm/policy/{name}"))); + new Route(GET, "/_slm/policy/{name}")); } @Override diff --git a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/slm/action/RestGetSnapshotLifecycleStatsAction.java b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/slm/action/RestGetSnapshotLifecycleStatsAction.java index 688c271a16544..8245f25ee6260 100644 --- a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/slm/action/RestGetSnapshotLifecycleStatsAction.java +++ b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/slm/action/RestGetSnapshotLifecycleStatsAction.java @@ -14,14 +14,13 @@ import java.util.List; -import static java.util.Collections.singletonList; import static org.elasticsearch.rest.RestRequest.Method.GET; public class RestGetSnapshotLifecycleStatsAction extends BaseRestHandler { @Override public List routes() { - return singletonList(new Route(GET, "/_slm/stats")); + return List.of(new Route(GET, "/_slm/stats")); } @Override diff --git a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/slm/action/RestPutSnapshotLifecycleAction.java b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/slm/action/RestPutSnapshotLifecycleAction.java index c4416c2eb6d6c..60178a80b4bcd 100644 --- a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/slm/action/RestPutSnapshotLifecycleAction.java +++ b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/slm/action/RestPutSnapshotLifecycleAction.java @@ -16,14 +16,13 @@ import java.io.IOException; import java.util.List; -import static java.util.Collections.singletonList; import static org.elasticsearch.rest.RestRequest.Method.PUT; public class RestPutSnapshotLifecycleAction extends BaseRestHandler { @Override public List routes() { - return singletonList(new Route(PUT, "/_slm/policy/{name}")); + return List.of(new Route(PUT, "/_slm/policy/{name}")); } @Override diff --git a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/slm/action/RestStartSLMAction.java b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/slm/action/RestStartSLMAction.java index da71efbe504b2..bc504e2b0b055 100644 --- a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/slm/action/RestStartSLMAction.java +++ b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/slm/action/RestStartSLMAction.java @@ -14,14 +14,13 @@ import java.util.List; -import static java.util.Collections.singletonList; import static org.elasticsearch.rest.RestRequest.Method.POST; public class RestStartSLMAction extends BaseRestHandler { @Override public List routes() { - return singletonList(new Route(POST, "/_slm/start")); + return List.of(new Route(POST, "/_slm/start")); } @Override diff --git a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/slm/action/RestStopSLMAction.java b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/slm/action/RestStopSLMAction.java index 1a0af84c31f74..ed68baacc07e2 100644 --- a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/slm/action/RestStopSLMAction.java +++ b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/slm/action/RestStopSLMAction.java @@ -14,14 +14,13 @@ import java.util.List; -import static java.util.Collections.singletonList; import static org.elasticsearch.rest.RestRequest.Method.POST; public class RestStopSLMAction extends BaseRestHandler { @Override public List routes() { - return singletonList(new Route(POST, "/_slm/stop")); + return List.of(new Route(POST, "/_slm/stop")); } @Override diff --git a/x-pack/plugin/ml/qa/native-multi-node-tests/src/test/java/org/elasticsearch/xpack/ml/integration/ClassificationIT.java b/x-pack/plugin/ml/qa/native-multi-node-tests/src/test/java/org/elasticsearch/xpack/ml/integration/ClassificationIT.java index 96f8047bfab57..c3242e535a6d7 100644 --- a/x-pack/plugin/ml/qa/native-multi-node-tests/src/test/java/org/elasticsearch/xpack/ml/integration/ClassificationIT.java +++ b/x-pack/plugin/ml/qa/native-multi-node-tests/src/test/java/org/elasticsearch/xpack/ml/integration/ClassificationIT.java @@ -34,7 +34,6 @@ import java.util.ArrayList; import java.util.Arrays; -import java.util.Collections; import java.util.List; import java.util.Map; import java.util.Set; @@ -61,10 +60,10 @@ public class ClassificationIT extends MlNativeDataFrameAnalyticsIntegTestCase { private static final String NESTED_FIELD = "outer-field.inner-field"; private static final String ALIAS_TO_KEYWORD_FIELD = "alias-to-keyword-field"; private static final String ALIAS_TO_NESTED_FIELD = "alias-to-nested-field"; - private static final List BOOLEAN_FIELD_VALUES = Collections.unmodifiableList(Arrays.asList(false, true)); - private static final List NUMERICAL_FIELD_VALUES = Collections.unmodifiableList(Arrays.asList(1.0, 2.0)); - private static final List DISCRETE_NUMERICAL_FIELD_VALUES = Collections.unmodifiableList(Arrays.asList(10, 20)); - private static final List KEYWORD_FIELD_VALUES = Collections.unmodifiableList(Arrays.asList("cat", "dog")); + private static final List BOOLEAN_FIELD_VALUES = List.of(false, true); + private static final List NUMERICAL_FIELD_VALUES = List.of(1.0, 2.0); + private static final List DISCRETE_NUMERICAL_FIELD_VALUES = List.of(10, 20); + private static final List KEYWORD_FIELD_VALUES = List.of("cat", "dog"); private String jobId; private String sourceIndex; diff --git a/x-pack/plugin/ml/qa/native-multi-node-tests/src/test/java/org/elasticsearch/xpack/ml/integration/RegressionIT.java b/x-pack/plugin/ml/qa/native-multi-node-tests/src/test/java/org/elasticsearch/xpack/ml/integration/RegressionIT.java index 125998819fd9c..6e445dfbb3f38 100644 --- a/x-pack/plugin/ml/qa/native-multi-node-tests/src/test/java/org/elasticsearch/xpack/ml/integration/RegressionIT.java +++ b/x-pack/plugin/ml/qa/native-multi-node-tests/src/test/java/org/elasticsearch/xpack/ml/integration/RegressionIT.java @@ -21,8 +21,6 @@ import org.elasticsearch.xpack.core.ml.dataframe.analyses.Regression; import org.junit.After; -import java.util.Arrays; -import java.util.Collections; import java.util.List; import java.util.Map; import java.util.Set; @@ -37,9 +35,9 @@ public class RegressionIT extends MlNativeDataFrameAnalyticsIntegTestCase { private static final String NUMERICAL_FEATURE_FIELD = "feature"; private static final String DISCRETE_NUMERICAL_FEATURE_FIELD = "discrete-feature"; private static final String DEPENDENT_VARIABLE_FIELD = "variable"; - private static final List NUMERICAL_FEATURE_VALUES = Collections.unmodifiableList(Arrays.asList(1.0, 2.0, 3.0)); - private static final List DISCRETE_NUMERICAL_FEATURE_VALUES = Collections.unmodifiableList(Arrays.asList(10L, 20L, 30L)); - private static final List DEPENDENT_VARIABLE_VALUES = Collections.unmodifiableList(Arrays.asList(10.0, 20.0, 30.0)); + private static final List NUMERICAL_FEATURE_VALUES = List.of(1.0, 2.0, 3.0); + private static final List DISCRETE_NUMERICAL_FEATURE_VALUES = List.of(10L, 20L, 30L); + private static final List DEPENDENT_VARIABLE_VALUES = List.of(10.0, 20.0, 30.0); private String jobId; private String sourceIndex; diff --git a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/MachineLearning.java b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/MachineLearning.java index c703069b0f13e..6d5309aea34c6 100644 --- a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/MachineLearning.java +++ b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/MachineLearning.java @@ -1038,11 +1038,11 @@ public List getNamedXContent() { @Override public Collection getSystemIndexDescriptors() { - return Collections.unmodifiableList(Arrays.asList( + return List.of( new SystemIndexDescriptor(MlMetaIndex.INDEX_NAME, "Contains scheduling and anomaly tracking metadata"), new SystemIndexDescriptor(AnomalyDetectorsIndexFields.STATE_INDEX_PATTERN, "Contains ML model state"), new SystemIndexDescriptor(AnomalyDetectorsIndexFields.CONFIG_INDEX, "Contains ML configuration data"), new SystemIndexDescriptor(InferenceIndexConstants.INDEX_PATTERN, "Contains ML model configuration and statistics") - )); + ); } } diff --git a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/calendar/RestGetCalendarsAction.java b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/calendar/RestGetCalendarsAction.java index f0bb5ac991756..47a0e4d68f66d 100644 --- a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/calendar/RestGetCalendarsAction.java +++ b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/calendar/RestGetCalendarsAction.java @@ -17,7 +17,6 @@ import org.elasticsearch.xpack.ml.MachineLearning; import java.io.IOException; -import java.util.Arrays; import java.util.Collections; import java.util.List; @@ -34,7 +33,7 @@ public List routes() { @Override public List replacedRoutes() { // TODO: remove deprecated endpoint in 8.0.0 - return Collections.unmodifiableList(Arrays.asList( + return List.of( new ReplacedRoute(GET, MachineLearning.BASE_PATH + "calendars/{" + Calendar.ID.getPreferredName() + "}", GET, MachineLearning.PRE_V7_BASE_PATH + "calendars/{" + Calendar.ID.getPreferredName() + "}"), new ReplacedRoute(GET, MachineLearning.BASE_PATH + "calendars/", @@ -43,7 +42,7 @@ public List replacedRoutes() { POST, MachineLearning.PRE_V7_BASE_PATH + "calendars/{" + Calendar.ID.getPreferredName() + "}"), new ReplacedRoute(POST, MachineLearning.BASE_PATH + "calendars/", POST, MachineLearning.PRE_V7_BASE_PATH + "calendars/") - )); + ); } @Override diff --git a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/cat/RestCatDatafeedsAction.java b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/cat/RestCatDatafeedsAction.java index 6617c8046fa3f..9bc1b055f4d19 100644 --- a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/cat/RestCatDatafeedsAction.java +++ b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/cat/RestCatDatafeedsAction.java @@ -21,17 +21,15 @@ import java.util.List; -import static java.util.Arrays.asList; -import static java.util.Collections.unmodifiableList; import static org.elasticsearch.rest.RestRequest.Method.GET; public class RestCatDatafeedsAction extends AbstractCatAction { @Override public List routes() { - return unmodifiableList(asList( + return List.of( new Route(GET, "_cat/ml/datafeeds/{" + DatafeedConfig.ID.getPreferredName() + "}"), - new Route(GET, "_cat/ml/datafeeds"))); + new Route(GET, "_cat/ml/datafeeds")); } @Override diff --git a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/cat/RestCatJobsAction.java b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/cat/RestCatJobsAction.java index 55bd15aaf80be..a0153fc5e981e 100644 --- a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/cat/RestCatJobsAction.java +++ b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/cat/RestCatJobsAction.java @@ -26,17 +26,15 @@ import java.util.List; -import static java.util.Arrays.asList; -import static java.util.Collections.unmodifiableList; import static org.elasticsearch.rest.RestRequest.Method.GET; public class RestCatJobsAction extends AbstractCatAction { @Override public List routes() { - return unmodifiableList(asList( + return List.of( new Route(GET, "_cat/ml/anomaly_detectors/{" + Job.ID.getPreferredName() + "}"), - new Route(GET, "_cat/ml/anomaly_detectors"))); + new Route(GET, "_cat/ml/anomaly_detectors")); } @Override diff --git a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/cat/RestCatTrainedModelsAction.java b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/cat/RestCatTrainedModelsAction.java index d827f4830a7b0..265ef56514a74 100644 --- a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/cat/RestCatTrainedModelsAction.java +++ b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/cat/RestCatTrainedModelsAction.java @@ -37,8 +37,6 @@ import java.util.function.Function; import java.util.stream.Collectors; -import static java.util.Arrays.asList; -import static java.util.Collections.unmodifiableList; import static org.elasticsearch.rest.RestRequest.Method.GET; import static org.elasticsearch.xpack.core.ml.action.GetTrainedModelsAction.Request.ALLOW_NO_MATCH; @@ -46,9 +44,9 @@ public class RestCatTrainedModelsAction extends AbstractCatAction { @Override public List routes() { - return unmodifiableList(asList( + return List.of( new Route(GET, "_cat/ml/trained_models"), - new Route(GET, "_cat/ml/trained_models/{" + TrainedModelConfig.MODEL_ID.getPreferredName() + "}"))); + new Route(GET, "_cat/ml/trained_models/{" + TrainedModelConfig.MODEL_ID.getPreferredName() + "}")); } @Override diff --git a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/datafeeds/RestGetDatafeedStatsAction.java b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/datafeeds/RestGetDatafeedStatsAction.java index 8bb02d280db47..d2fb23ae9b696 100644 --- a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/datafeeds/RestGetDatafeedStatsAction.java +++ b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/datafeeds/RestGetDatafeedStatsAction.java @@ -15,7 +15,6 @@ import org.elasticsearch.xpack.ml.MachineLearning; import java.io.IOException; -import java.util.Arrays; import java.util.Collections; import java.util.List; @@ -31,12 +30,12 @@ public List routes() { @Override public List replacedRoutes() { // TODO: remove deprecated endpoint in 8.0.0 - return Collections.unmodifiableList(Arrays.asList( + return List.of( new ReplacedRoute(GET, MachineLearning.BASE_PATH + "datafeeds/{" + DatafeedConfig.ID.getPreferredName() + "}/_stats", GET, MachineLearning.PRE_V7_BASE_PATH + "datafeeds/{" + DatafeedConfig.ID.getPreferredName() + "}/_stats"), new ReplacedRoute(GET, MachineLearning.BASE_PATH + "datafeeds/_stats", GET, MachineLearning.PRE_V7_BASE_PATH + "datafeeds/_stats") - )); + ); } @Override diff --git a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/datafeeds/RestGetDatafeedsAction.java b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/datafeeds/RestGetDatafeedsAction.java index 5f3f0ea4d98a3..e00c571fb2021 100644 --- a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/datafeeds/RestGetDatafeedsAction.java +++ b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/datafeeds/RestGetDatafeedsAction.java @@ -14,7 +14,6 @@ import org.elasticsearch.xpack.ml.MachineLearning; import java.io.IOException; -import java.util.Arrays; import java.util.Collections; import java.util.List; @@ -30,12 +29,12 @@ public List routes() { @Override public List replacedRoutes() { // TODO: remove deprecated endpoint in 8.0.0 - return Collections.unmodifiableList(Arrays.asList( + return List.of( new ReplacedRoute(GET, MachineLearning.BASE_PATH + "datafeeds/{" + DatafeedConfig.ID.getPreferredName() + "}", GET, MachineLearning.PRE_V7_BASE_PATH + "datafeeds/{" + DatafeedConfig.ID.getPreferredName() + "}"), new ReplacedRoute(GET, MachineLearning.BASE_PATH + "datafeeds", GET, MachineLearning.PRE_V7_BASE_PATH + "datafeeds") - )); + ); } @Override diff --git a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/dataframe/RestEvaluateDataFrameAction.java b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/dataframe/RestEvaluateDataFrameAction.java index 73d2506f3713f..2142f29ea1691 100644 --- a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/dataframe/RestEvaluateDataFrameAction.java +++ b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/dataframe/RestEvaluateDataFrameAction.java @@ -15,14 +15,13 @@ import java.io.IOException; import java.util.List; -import static java.util.Collections.singletonList; import static org.elasticsearch.rest.RestRequest.Method.POST; public class RestEvaluateDataFrameAction extends BaseRestHandler { @Override public List routes() { - return singletonList(new Route(POST, MachineLearning.BASE_PATH + "data_frame/_evaluate")); + return List.of(new Route(POST, MachineLearning.BASE_PATH + "data_frame/_evaluate")); } @Override diff --git a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/dataframe/RestExplainDataFrameAnalyticsAction.java b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/dataframe/RestExplainDataFrameAnalyticsAction.java index 1d5f99aaf10c7..d6a2bd4a30430 100644 --- a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/dataframe/RestExplainDataFrameAnalyticsAction.java +++ b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/dataframe/RestExplainDataFrameAnalyticsAction.java @@ -22,8 +22,6 @@ import java.util.List; import java.util.stream.Collectors; -import static java.util.Arrays.asList; -import static java.util.Collections.unmodifiableList; import static org.elasticsearch.rest.RestRequest.Method.GET; import static org.elasticsearch.rest.RestRequest.Method.POST; @@ -31,13 +29,13 @@ public class RestExplainDataFrameAnalyticsAction extends BaseRestHandler { @Override public List routes() { - return unmodifiableList(asList( + return List.of( new Route(GET, MachineLearning.BASE_PATH + "data_frame/analytics/_explain"), new Route(POST, MachineLearning.BASE_PATH + "data_frame/analytics/_explain"), new Route( GET, MachineLearning.BASE_PATH + "data_frame/analytics/{" + DataFrameAnalyticsConfig.ID.getPreferredName() + "}/_explain"), new Route(POST, - MachineLearning.BASE_PATH + "data_frame/analytics/{" + DataFrameAnalyticsConfig.ID.getPreferredName() + "}/_explain"))); + MachineLearning.BASE_PATH + "data_frame/analytics/{" + DataFrameAnalyticsConfig.ID.getPreferredName() + "}/_explain")); } @Override diff --git a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/dataframe/RestGetDataFrameAnalyticsAction.java b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/dataframe/RestGetDataFrameAnalyticsAction.java index 639adbc375a3a..6d6c8f3676556 100644 --- a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/dataframe/RestGetDataFrameAnalyticsAction.java +++ b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/dataframe/RestGetDataFrameAnalyticsAction.java @@ -18,17 +18,15 @@ import java.io.IOException; import java.util.List; -import static java.util.Arrays.asList; -import static java.util.Collections.unmodifiableList; import static org.elasticsearch.rest.RestRequest.Method.GET; public class RestGetDataFrameAnalyticsAction extends BaseRestHandler { @Override public List routes() { - return unmodifiableList(asList( + return List.of( new Route(GET, MachineLearning.BASE_PATH + "data_frame/analytics"), - new Route(GET, MachineLearning.BASE_PATH + "data_frame/analytics/{" + DataFrameAnalyticsConfig.ID.getPreferredName() + "}"))); + new Route(GET, MachineLearning.BASE_PATH + "data_frame/analytics/{" + DataFrameAnalyticsConfig.ID.getPreferredName() + "}")); } @Override diff --git a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/dataframe/RestGetDataFrameAnalyticsStatsAction.java b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/dataframe/RestGetDataFrameAnalyticsStatsAction.java index 793f41796cc5f..00d639aae6193 100644 --- a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/dataframe/RestGetDataFrameAnalyticsStatsAction.java +++ b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/dataframe/RestGetDataFrameAnalyticsStatsAction.java @@ -18,18 +18,16 @@ import java.io.IOException; import java.util.List; -import static java.util.Arrays.asList; -import static java.util.Collections.unmodifiableList; import static org.elasticsearch.rest.RestRequest.Method.GET; public class RestGetDataFrameAnalyticsStatsAction extends BaseRestHandler { @Override public List routes() { - return unmodifiableList(asList( + return List.of( new Route(GET, MachineLearning.BASE_PATH + "data_frame/analytics/_stats"), new Route( - GET, MachineLearning.BASE_PATH + "data_frame/analytics/{" + DataFrameAnalyticsConfig.ID.getPreferredName() + "}/_stats"))); + GET, MachineLearning.BASE_PATH + "data_frame/analytics/{" + DataFrameAnalyticsConfig.ID.getPreferredName() + "}/_stats")); } @Override diff --git a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/filter/RestGetFiltersAction.java b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/filter/RestGetFiltersAction.java index 2752adfdd5fd3..0da9de686029f 100644 --- a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/filter/RestGetFiltersAction.java +++ b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/filter/RestGetFiltersAction.java @@ -16,7 +16,6 @@ import org.elasticsearch.xpack.ml.MachineLearning; import java.io.IOException; -import java.util.Arrays; import java.util.Collections; import java.util.List; @@ -32,12 +31,12 @@ public List routes() { @Override public List replacedRoutes() { // TODO: remove deprecated endpoint in 8.0.0 - return Collections.unmodifiableList(Arrays.asList( + return List.of( new ReplacedRoute(GET, MachineLearning.BASE_PATH + "filters/{" + MlFilter.ID.getPreferredName() + "}", GET, MachineLearning.PRE_V7_BASE_PATH + "filters/{" + MlFilter.ID.getPreferredName() + "}"), new ReplacedRoute(GET, MachineLearning.BASE_PATH + "filters/", GET, MachineLearning.PRE_V7_BASE_PATH + "filters/") - )); + ); } @Override diff --git a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/inference/RestGetTrainedModelsAction.java b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/inference/RestGetTrainedModelsAction.java index 8c783dbb609f9..04f5523365dd9 100644 --- a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/inference/RestGetTrainedModelsAction.java +++ b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/inference/RestGetTrainedModelsAction.java @@ -22,7 +22,6 @@ import java.util.Set; import static java.util.Arrays.asList; -import static java.util.Collections.unmodifiableList; import static org.elasticsearch.rest.RestRequest.Method.GET; import static org.elasticsearch.xpack.core.ml.action.GetTrainedModelsAction.Request.ALLOW_NO_MATCH; @@ -30,9 +29,9 @@ public class RestGetTrainedModelsAction extends BaseRestHandler { @Override public List routes() { - return unmodifiableList(asList( + return List.of( new Route(GET, MachineLearning.BASE_PATH + "inference/{" + TrainedModelConfig.MODEL_ID.getPreferredName() + "}"), - new Route(GET, MachineLearning.BASE_PATH + "inference"))); + new Route(GET, MachineLearning.BASE_PATH + "inference")); } @Override diff --git a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/inference/RestGetTrainedModelsStatsAction.java b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/inference/RestGetTrainedModelsStatsAction.java index a035a67022bc3..bd5ae402e8150 100644 --- a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/inference/RestGetTrainedModelsStatsAction.java +++ b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/inference/RestGetTrainedModelsStatsAction.java @@ -19,8 +19,6 @@ import java.io.IOException; import java.util.List; -import static java.util.Arrays.asList; -import static java.util.Collections.unmodifiableList; import static org.elasticsearch.rest.RestRequest.Method.GET; import static org.elasticsearch.xpack.core.ml.action.GetTrainedModelsAction.Request.ALLOW_NO_MATCH; @@ -28,9 +26,9 @@ public class RestGetTrainedModelsStatsAction extends BaseRestHandler { @Override public List routes() { - return unmodifiableList(asList( + return List.of( new Route(GET, MachineLearning.BASE_PATH + "inference/{" + TrainedModelConfig.MODEL_ID.getPreferredName() + "}/_stats"), - new Route(GET, MachineLearning.BASE_PATH + MachineLearning.BASE_PATH + "inference/_stats"))); + new Route(GET, MachineLearning.BASE_PATH + MachineLearning.BASE_PATH + "inference/_stats")); } @Override diff --git a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/job/RestGetJobStatsAction.java b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/job/RestGetJobStatsAction.java index 22060cab8cdf2..0fe3919e32a77 100644 --- a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/job/RestGetJobStatsAction.java +++ b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/job/RestGetJobStatsAction.java @@ -16,7 +16,6 @@ import org.elasticsearch.xpack.ml.MachineLearning; import java.io.IOException; -import java.util.Arrays; import java.util.Collections; import java.util.List; @@ -32,12 +31,12 @@ public List routes() { @Override public List replacedRoutes() { // TODO: remove deprecated endpoint in 8.0.0 - return Collections.unmodifiableList(Arrays.asList( + return List.of( new ReplacedRoute(GET, MachineLearning.BASE_PATH + "anomaly_detectors/{" + Job.ID.getPreferredName() + "}/_stats", GET, MachineLearning.PRE_V7_BASE_PATH + "anomaly_detectors/{" + Job.ID.getPreferredName() + "}/_stats"), new ReplacedRoute(GET, MachineLearning.BASE_PATH + "anomaly_detectors/_stats", GET, MachineLearning.PRE_V7_BASE_PATH + "anomaly_detectors/_stats") - )); + ); } @Override diff --git a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/job/RestGetJobsAction.java b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/job/RestGetJobsAction.java index 0b0d8f418114b..8f39d667bd74b 100644 --- a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/job/RestGetJobsAction.java +++ b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/job/RestGetJobsAction.java @@ -16,7 +16,6 @@ import org.elasticsearch.xpack.ml.MachineLearning; import java.io.IOException; -import java.util.Arrays; import java.util.Collections; import java.util.List; @@ -32,12 +31,12 @@ public List routes() { @Override public List replacedRoutes() { // TODO: remove deprecated endpoint in 8.0.0 - return Collections.unmodifiableList(Arrays.asList( + return List.of( new ReplacedRoute(GET, MachineLearning.BASE_PATH + "anomaly_detectors/{" + Job.ID.getPreferredName() + "}", GET, MachineLearning.PRE_V7_BASE_PATH + "anomaly_detectors/{" + Job.ID.getPreferredName() + "}"), new ReplacedRoute(GET, MachineLearning.BASE_PATH + "anomaly_detectors", GET, MachineLearning.PRE_V7_BASE_PATH + "anomaly_detectors") - )); + ); } @Override diff --git a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/modelsnapshots/RestGetModelSnapshotsAction.java b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/modelsnapshots/RestGetModelSnapshotsAction.java index b9e510af4fc82..07c0afdc46d13 100644 --- a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/modelsnapshots/RestGetModelSnapshotsAction.java +++ b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/modelsnapshots/RestGetModelSnapshotsAction.java @@ -17,7 +17,6 @@ import org.elasticsearch.xpack.ml.MachineLearning; import java.io.IOException; -import java.util.Arrays; import java.util.Collections; import java.util.List; @@ -44,7 +43,7 @@ public List routes() { @Override public List replacedRoutes() { // TODO: remove deprecated endpoint in 8.0.0 - return Collections.unmodifiableList(Arrays.asList( + return List.of( new ReplacedRoute(GET, MachineLearning.BASE_PATH + "anomaly_detectors/{" + Job.ID.getPreferredName() + "}/model_snapshots/{" + Request.SNAPSHOT_ID.getPreferredName() + "}", GET, MachineLearning.PRE_V7_BASE_PATH + "anomaly_detectors/{" @@ -61,7 +60,7 @@ public List replacedRoutes() { + Job.ID.getPreferredName() + "}/model_snapshots", POST, MachineLearning.PRE_V7_BASE_PATH + "anomaly_detectors/{" + Job.ID.getPreferredName() + "}/model_snapshots") - )); + ); } @Override diff --git a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/results/RestGetBucketsAction.java b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/results/RestGetBucketsAction.java index 6a776eb111ce4..43d051d70d1c8 100644 --- a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/results/RestGetBucketsAction.java +++ b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/results/RestGetBucketsAction.java @@ -18,7 +18,6 @@ import org.elasticsearch.xpack.ml.MachineLearning; import java.io.IOException; -import java.util.Arrays; import java.util.Collections; import java.util.List; @@ -35,7 +34,7 @@ public List routes() { @Override public List replacedRoutes() { // TODO: remove deprecated endpoint in 8.0.0 - return Collections.unmodifiableList(Arrays.asList( + return List.of( new ReplacedRoute(GET, MachineLearning.BASE_PATH + "anomaly_detectors/{" + Job.ID.getPreferredName() + "}/results/buckets/{" + Result.TIMESTAMP.getPreferredName() + "}", GET, MachineLearning.PRE_V7_BASE_PATH + "anomaly_detectors/{" + Job.ID.getPreferredName() @@ -52,7 +51,7 @@ public List replacedRoutes() { + "}/results/buckets", POST, MachineLearning.PRE_V7_BASE_PATH + "anomaly_detectors/{" + Job.ID.getPreferredName() + "}/results/buckets") - )); + ); } @Override diff --git a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/results/RestGetCategoriesAction.java b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/results/RestGetCategoriesAction.java index 2cb15f8a49edf..7777c61efd24d 100644 --- a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/results/RestGetCategoriesAction.java +++ b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/results/RestGetCategoriesAction.java @@ -17,7 +17,6 @@ import org.elasticsearch.xpack.ml.MachineLearning; import java.io.IOException; -import java.util.Arrays; import java.util.Collections; import java.util.List; @@ -34,7 +33,7 @@ public List routes() { @Override public List replacedRoutes() { // TODO: remove deprecated endpoint in 8.0.0 - return Collections.unmodifiableList(Arrays.asList( + return List.of( new ReplacedRoute( GET, MachineLearning.BASE_PATH + "anomaly_detectors/{" + Job.ID.getPreferredName() + "}/results/categories/{" + Request.CATEGORY_ID.getPreferredName() + "}", @@ -50,7 +49,7 @@ public List replacedRoutes() { new ReplacedRoute( POST, MachineLearning.BASE_PATH + "anomaly_detectors/{" + Job.ID.getPreferredName() + "}/results/categories", POST, MachineLearning.PRE_V7_BASE_PATH + "anomaly_detectors/{" + Job.ID.getPreferredName() + "}/results/categories") - )); + ); } @Override diff --git a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/results/RestGetInfluencersAction.java b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/results/RestGetInfluencersAction.java index e191f935bd4af..25d294d62cef1 100644 --- a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/results/RestGetInfluencersAction.java +++ b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/results/RestGetInfluencersAction.java @@ -16,7 +16,6 @@ import org.elasticsearch.xpack.ml.MachineLearning; import java.io.IOException; -import java.util.Arrays; import java.util.Collections; import java.util.List; @@ -33,14 +32,14 @@ public List routes() { @Override public List replacedRoutes() { // TODO: remove deprecated endpoint in 8.0.0 - return Collections.unmodifiableList(Arrays.asList( + return List.of( new ReplacedRoute( GET, MachineLearning.BASE_PATH + "anomaly_detectors/{" + Job.ID.getPreferredName() + "}/results/influencers", GET, MachineLearning.PRE_V7_BASE_PATH + "anomaly_detectors/{" + Job.ID.getPreferredName() + "}/results/influencers"), new ReplacedRoute( POST, MachineLearning.BASE_PATH + "anomaly_detectors/{" + Job.ID.getPreferredName() + "}/results/influencers", POST, MachineLearning.PRE_V7_BASE_PATH + "anomaly_detectors/{" + Job.ID.getPreferredName() + "}/results/influencers") - )); + ); } @Override diff --git a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/results/RestGetOverallBucketsAction.java b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/results/RestGetOverallBucketsAction.java index 03d17d1a2e20b..9e76ab49bb456 100644 --- a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/results/RestGetOverallBucketsAction.java +++ b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/results/RestGetOverallBucketsAction.java @@ -16,7 +16,6 @@ import org.elasticsearch.xpack.ml.MachineLearning; import java.io.IOException; -import java.util.Arrays; import java.util.Collections; import java.util.List; @@ -33,14 +32,14 @@ public List routes() { @Override public List replacedRoutes() { // TODO: remove deprecated endpoint in 8.0.0 - return Collections.unmodifiableList(Arrays.asList( + return List.of( new ReplacedRoute( GET, MachineLearning.BASE_PATH + "anomaly_detectors/{" + Job.ID.getPreferredName() + "}/results/overall_buckets", GET, MachineLearning.PRE_V7_BASE_PATH + "anomaly_detectors/{" + Job.ID.getPreferredName() + "}/results/overall_buckets"), new ReplacedRoute( POST, MachineLearning.BASE_PATH + "anomaly_detectors/{" + Job.ID.getPreferredName() + "}/results/overall_buckets", POST, MachineLearning.PRE_V7_BASE_PATH + "anomaly_detectors/{" + Job.ID.getPreferredName() + "}/results/overall_buckets") - )); + ); } @Override diff --git a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/results/RestGetRecordsAction.java b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/results/RestGetRecordsAction.java index c8207b1dc0870..fd72485d554f9 100644 --- a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/results/RestGetRecordsAction.java +++ b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/results/RestGetRecordsAction.java @@ -16,7 +16,6 @@ import org.elasticsearch.xpack.ml.MachineLearning; import java.io.IOException; -import java.util.Arrays; import java.util.Collections; import java.util.List; @@ -33,14 +32,14 @@ public List routes() { @Override public List replacedRoutes() { // TODO: remove deprecated endpoint in 8.0.0 - return Collections.unmodifiableList(Arrays.asList( + return List.of( new ReplacedRoute( GET, MachineLearning.BASE_PATH + "anomaly_detectors/{" + Job.ID.getPreferredName() + "}/results/records", GET, MachineLearning.PRE_V7_BASE_PATH + "anomaly_detectors/{" + Job.ID.getPreferredName() + "}/results/records"), new ReplacedRoute( POST, MachineLearning.BASE_PATH + "anomaly_detectors/{" + Job.ID.getPreferredName() + "}/results/records", POST, MachineLearning.PRE_V7_BASE_PATH + "anomaly_detectors/{" + Job.ID.getPreferredName() + "}/results/records") - )); + ); } @Override diff --git a/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/rest/action/RestMonitoringBulkAction.java b/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/rest/action/RestMonitoringBulkAction.java index 1382e27c8ef13..d97384287d2cf 100644 --- a/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/rest/action/RestMonitoringBulkAction.java +++ b/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/rest/action/RestMonitoringBulkAction.java @@ -26,7 +26,6 @@ import static java.util.Arrays.asList; import static java.util.Collections.emptyList; -import static java.util.Collections.unmodifiableList; import static org.elasticsearch.common.unit.TimeValue.parseTimeValue; import static org.elasticsearch.rest.RestRequest.Method.POST; import static org.elasticsearch.rest.RestRequest.Method.PUT; @@ -49,9 +48,9 @@ public class RestMonitoringBulkAction extends BaseRestHandler { @Override public List routes() { - return unmodifiableList(asList( + return List.of( new Route(POST, "/_monitoring/bulk"), - new Route(PUT, "/_monitoring/bulk"))); + new Route(PUT, "/_monitoring/bulk")); } @Override diff --git a/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/rest/RestDeleteRollupJobAction.java b/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/rest/RestDeleteRollupJobAction.java index e8a1d2928d72a..eb7fbb1400a01 100644 --- a/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/rest/RestDeleteRollupJobAction.java +++ b/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/rest/RestDeleteRollupJobAction.java @@ -16,7 +16,6 @@ import java.util.List; -import static java.util.Collections.singletonList; import static org.elasticsearch.rest.RestRequest.Method.DELETE; public class RestDeleteRollupJobAction extends BaseRestHandler { @@ -25,7 +24,7 @@ public class RestDeleteRollupJobAction extends BaseRestHandler { @Override public List routes() { - return singletonList(new Route(DELETE, "/_rollup/job/{id}")); + return List.of(new Route(DELETE, "/_rollup/job/{id}")); } @Override diff --git a/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/rest/RestGetRollupCapsAction.java b/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/rest/RestGetRollupCapsAction.java index c31a433b93ab1..e8635e17983bf 100644 --- a/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/rest/RestGetRollupCapsAction.java +++ b/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/rest/RestGetRollupCapsAction.java @@ -15,7 +15,6 @@ import java.util.List; -import static java.util.Collections.singletonList; import static org.elasticsearch.rest.RestRequest.Method.GET; public class RestGetRollupCapsAction extends BaseRestHandler { @@ -24,7 +23,7 @@ public class RestGetRollupCapsAction extends BaseRestHandler { @Override public List routes() { - return singletonList(new Route(GET, "/_rollup/data/{id}")); + return List.of(new Route(GET, "/_rollup/data/{id}")); } @Override diff --git a/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/rest/RestGetRollupIndexCapsAction.java b/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/rest/RestGetRollupIndexCapsAction.java index ed136df98b657..ae9885be83465 100644 --- a/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/rest/RestGetRollupIndexCapsAction.java +++ b/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/rest/RestGetRollupIndexCapsAction.java @@ -17,7 +17,6 @@ import java.util.List; -import static java.util.Collections.singletonList; import static org.elasticsearch.rest.RestRequest.Method.GET; public class RestGetRollupIndexCapsAction extends BaseRestHandler { @@ -26,7 +25,7 @@ public class RestGetRollupIndexCapsAction extends BaseRestHandler { @Override public List routes() { - return singletonList(new Route(GET, "/{index}/_rollup/data")); + return List.of(new Route(GET, "/{index}/_rollup/data")); } @Override diff --git a/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/rest/RestGetRollupJobsAction.java b/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/rest/RestGetRollupJobsAction.java index b6d18eb83d667..e6abf6a48ade8 100644 --- a/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/rest/RestGetRollupJobsAction.java +++ b/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/rest/RestGetRollupJobsAction.java @@ -15,7 +15,6 @@ import java.util.List; -import static java.util.Collections.singletonList; import static org.elasticsearch.rest.RestRequest.Method.GET; public class RestGetRollupJobsAction extends BaseRestHandler { @@ -24,7 +23,7 @@ public class RestGetRollupJobsAction extends BaseRestHandler { @Override public List routes() { - return singletonList(new Route(GET, "/_rollup/job/{id}")); + return List.of(new Route(GET, "/_rollup/job/{id}")); } @Override diff --git a/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/rest/RestPutRollupJobAction.java b/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/rest/RestPutRollupJobAction.java index f945055efd822..12814b103d41d 100644 --- a/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/rest/RestPutRollupJobAction.java +++ b/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/rest/RestPutRollupJobAction.java @@ -15,14 +15,13 @@ import java.io.IOException; import java.util.List; -import static java.util.Collections.singletonList; import static org.elasticsearch.rest.RestRequest.Method.PUT; public class RestPutRollupJobAction extends BaseRestHandler { @Override public List routes() { - return singletonList(new Route(PUT, "/_rollup/job/{id}")); + return List.of(new Route(PUT, "/_rollup/job/{id}")); } @Override diff --git a/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/rest/RestRollupSearchAction.java b/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/rest/RestRollupSearchAction.java index bc6e27501adc2..9a29b0f0c7ec6 100644 --- a/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/rest/RestRollupSearchAction.java +++ b/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/rest/RestRollupSearchAction.java @@ -17,8 +17,6 @@ import java.util.List; import java.util.Set; -import static java.util.Arrays.asList; -import static java.util.Collections.unmodifiableList; import static org.elasticsearch.rest.RestRequest.Method.GET; import static org.elasticsearch.rest.RestRequest.Method.POST; @@ -28,11 +26,11 @@ public class RestRollupSearchAction extends BaseRestHandler { @Override public List routes() { - return unmodifiableList(asList( + return List.of( new Route(GET, "_rollup_search"), new Route(POST, "_rollup_search"), new Route(GET, "{index}/_rollup_search"), - new Route(POST, "{index}/_rollup_search"))); + new Route(POST, "{index}/_rollup_search")); } @Override diff --git a/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/rest/RestStartRollupJobAction.java b/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/rest/RestStartRollupJobAction.java index 5704e8417aead..417195c024483 100644 --- a/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/rest/RestStartRollupJobAction.java +++ b/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/rest/RestStartRollupJobAction.java @@ -15,14 +15,13 @@ import java.util.List; -import static java.util.Collections.singletonList; import static org.elasticsearch.rest.RestRequest.Method.POST; public class RestStartRollupJobAction extends BaseRestHandler { @Override public List routes() { - return singletonList(new Route(POST, "/_rollup/job/{id}/_start")); + return List.of(new Route(POST, "/_rollup/job/{id}/_start")); } @Override diff --git a/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/rest/RestStopRollupJobAction.java b/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/rest/RestStopRollupJobAction.java index b82865d5e7246..f7e86c9998253 100644 --- a/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/rest/RestStopRollupJobAction.java +++ b/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/rest/RestStopRollupJobAction.java @@ -16,14 +16,13 @@ import java.util.List; -import static java.util.Collections.singletonList; import static org.elasticsearch.rest.RestRequest.Method.POST; public class RestStopRollupJobAction extends BaseRestHandler { @Override public List routes() { - return singletonList(new Route(POST, "/_rollup/job/{id}/_stop")); + return List.of(new Route(POST, "/_rollup/job/{id}/_stop")); } @Override diff --git a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/Security.java b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/Security.java index f5568489a153a..d5f9aaf064830 100644 --- a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/Security.java +++ b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/Security.java @@ -1071,13 +1071,13 @@ private synchronized NioGroupFactory getNioGroupFactory(Settings settings) { @Override public Collection getSystemIndexDescriptors() { - return Collections.unmodifiableList(Arrays.asList( + return List.of( new SystemIndexDescriptor(SECURITY_MAIN_ALIAS, "Contains Security configuration"), new SystemIndexDescriptor(RestrictedIndicesNames.INTERNAL_SECURITY_MAIN_INDEX_6, "Contains Security configuration"), new SystemIndexDescriptor(RestrictedIndicesNames.INTERNAL_SECURITY_MAIN_INDEX_7, "Contains Security configuration"), new SystemIndexDescriptor(RestrictedIndicesNames.SECURITY_TOKENS_ALIAS, "Contains auth token data"), new SystemIndexDescriptor(RestrictedIndicesNames.INTERNAL_SECURITY_TOKENS_INDEX_7, "Contains auth token data") - )); + ); } } diff --git a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/RestDelegatePkiAuthenticationAction.java b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/RestDelegatePkiAuthenticationAction.java index 4dea0899f83f2..64a4fcc11208d 100644 --- a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/RestDelegatePkiAuthenticationAction.java +++ b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/RestDelegatePkiAuthenticationAction.java @@ -29,7 +29,6 @@ import java.io.IOException; import java.util.List; -import static java.util.Collections.singletonList; import static org.elasticsearch.rest.RestRequest.Method.POST; /** @@ -47,7 +46,7 @@ public RestDelegatePkiAuthenticationAction(Settings settings, XPackLicenseState @Override public List routes() { - return singletonList(new Route(POST, "/_security/delegate_pki")); + return List.of(new Route(POST, "/_security/delegate_pki")); } @Override diff --git a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/apikey/RestCreateApiKeyAction.java b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/apikey/RestCreateApiKeyAction.java index af90797184db4..216dc6da8bb0c 100644 --- a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/apikey/RestCreateApiKeyAction.java +++ b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/apikey/RestCreateApiKeyAction.java @@ -18,8 +18,6 @@ import java.io.IOException; import java.util.List; -import static java.util.Arrays.asList; -import static java.util.Collections.unmodifiableList; import static org.elasticsearch.rest.RestRequest.Method.POST; import static org.elasticsearch.rest.RestRequest.Method.PUT; @@ -39,9 +37,9 @@ public RestCreateApiKeyAction(Settings settings, XPackLicenseState licenseState) @Override public List routes() { - return unmodifiableList(asList( + return List.of( new Route(POST, "/_security/api_key"), - new Route(PUT, "/_security/api_key"))); + new Route(PUT, "/_security/api_key")); } @Override diff --git a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/apikey/RestGetApiKeyAction.java b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/apikey/RestGetApiKeyAction.java index 74bf64ba4daf3..c29ed06cf573c 100644 --- a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/apikey/RestGetApiKeyAction.java +++ b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/apikey/RestGetApiKeyAction.java @@ -23,7 +23,6 @@ import java.io.IOException; import java.util.List; -import static java.util.Collections.singletonList; import static org.elasticsearch.rest.RestRequest.Method.GET; /** @@ -37,7 +36,7 @@ public RestGetApiKeyAction(Settings settings, XPackLicenseState licenseState) { @Override public List routes() { - return singletonList(new Route(GET, "/_security/api_key")); + return List.of(new Route(GET, "/_security/api_key")); } @Override diff --git a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/apikey/RestInvalidateApiKeyAction.java b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/apikey/RestInvalidateApiKeyAction.java index 86064b953d008..a9397c5e41f2b 100644 --- a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/apikey/RestInvalidateApiKeyAction.java +++ b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/apikey/RestInvalidateApiKeyAction.java @@ -25,7 +25,6 @@ import java.io.IOException; import java.util.List; -import static java.util.Collections.singletonList; import static org.elasticsearch.rest.RestRequest.Method.DELETE; /** @@ -52,7 +51,7 @@ public RestInvalidateApiKeyAction(Settings settings, XPackLicenseState licenseSt @Override public List routes() { - return singletonList(new Route(DELETE, "/_security/api_key")); + return List.of(new Route(DELETE, "/_security/api_key")); } @Override diff --git a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/oidc/RestOpenIdConnectAuthenticateAction.java b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/oidc/RestOpenIdConnectAuthenticateAction.java index a297b2f7cd6b5..45992d018a256 100644 --- a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/oidc/RestOpenIdConnectAuthenticateAction.java +++ b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/oidc/RestOpenIdConnectAuthenticateAction.java @@ -26,7 +26,6 @@ import java.io.IOException; import java.util.List; -import static java.util.Collections.singletonList; import static org.elasticsearch.rest.RestRequest.Method.POST; /** @@ -51,7 +50,7 @@ public RestOpenIdConnectAuthenticateAction(Settings settings, XPackLicenseState @Override public List routes() { - return singletonList(new Route(POST, "/_security/oidc/authenticate")); + return List.of(new Route(POST, "/_security/oidc/authenticate")); } @Override diff --git a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/oidc/RestOpenIdConnectLogoutAction.java b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/oidc/RestOpenIdConnectLogoutAction.java index f9485f91beba2..de01d8d2b5bc3 100644 --- a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/oidc/RestOpenIdConnectLogoutAction.java +++ b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/oidc/RestOpenIdConnectLogoutAction.java @@ -24,7 +24,6 @@ import java.io.IOException; import java.util.List; -import static java.util.Collections.singletonList; import static org.elasticsearch.rest.RestRequest.Method.POST; /** @@ -47,7 +46,7 @@ public RestOpenIdConnectLogoutAction(Settings settings, XPackLicenseState licens @Override public List routes() { - return singletonList(new Route(POST, "/_security/oidc/logout")); + return List.of(new Route(POST, "/_security/oidc/logout")); } @Override diff --git a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/oidc/RestOpenIdConnectPrepareAuthenticationAction.java b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/oidc/RestOpenIdConnectPrepareAuthenticationAction.java index d38febbbc33e8..10f7f9198fde0 100644 --- a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/oidc/RestOpenIdConnectPrepareAuthenticationAction.java +++ b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/oidc/RestOpenIdConnectPrepareAuthenticationAction.java @@ -26,7 +26,6 @@ import java.io.IOException; import java.util.List; -import static java.util.Collections.singletonList; import static org.elasticsearch.rest.RestRequest.Method.POST; /** @@ -52,7 +51,7 @@ public RestOpenIdConnectPrepareAuthenticationAction(Settings settings, XPackLice @Override public List routes() { - return singletonList(new Route(POST, "/_security/oidc/prepare")); + return List.of(new Route(POST, "/_security/oidc/prepare")); } @Override diff --git a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/privilege/RestGetBuiltinPrivilegesAction.java b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/privilege/RestGetBuiltinPrivilegesAction.java index a57b226c3156f..b8bdf978b6d10 100644 --- a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/privilege/RestGetBuiltinPrivilegesAction.java +++ b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/privilege/RestGetBuiltinPrivilegesAction.java @@ -22,7 +22,6 @@ import java.io.IOException; import java.util.List; -import static java.util.Collections.singletonList; import static org.elasticsearch.rest.RestRequest.Method.GET; /** @@ -36,7 +35,7 @@ public RestGetBuiltinPrivilegesAction(Settings settings, XPackLicenseState licen @Override public List routes() { - return singletonList(new Route(GET, "/_security/privilege/_builtin")); + return List.of(new Route(GET, "/_security/privilege/_builtin")); } @Override diff --git a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/privilege/RestGetPrivilegesAction.java b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/privilege/RestGetPrivilegesAction.java index f78d833168f56..9e67be444a6b3 100644 --- a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/privilege/RestGetPrivilegesAction.java +++ b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/privilege/RestGetPrivilegesAction.java @@ -48,13 +48,13 @@ public List routes() { @Override public List replacedRoutes() { // TODO: remove deprecated endpoint in 8.0.0 - return Collections.unmodifiableList(Arrays.asList( + return List.of( new ReplacedRoute(GET, "/_security/privilege/", GET, "/_xpack/security/privilege/"), new ReplacedRoute(GET, "/_security/privilege/{application}", GET, "/_xpack/security/privilege/{application}"), new ReplacedRoute(GET, "/_security/privilege/{application}/{privilege}", GET, "/_xpack/security/privilege/{application}/{privilege}") - )); + ); } @Override diff --git a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/privilege/RestPutPrivilegesAction.java b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/privilege/RestPutPrivilegesAction.java index d39207d4d078b..cb0cd679305a9 100644 --- a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/privilege/RestPutPrivilegesAction.java +++ b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/privilege/RestPutPrivilegesAction.java @@ -21,7 +21,6 @@ import org.elasticsearch.xpack.security.rest.action.SecurityBaseRestHandler; import java.io.IOException; -import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.List; @@ -47,10 +46,10 @@ public List routes() { @Override public List replacedRoutes() { // TODO: remove deprecated endpoint in 8.0.0 - return Collections.unmodifiableList(Arrays.asList( + return List.of( new ReplacedRoute(PUT, "/_security/privilege/", PUT, "/_xpack/security/privilege/"), new ReplacedRoute(POST, "/_security/privilege/", POST, "/_xpack/security/privilege/") - )); + ); } @Override diff --git a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/role/RestGetRolesAction.java b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/role/RestGetRolesAction.java index 901c7ddc9219a..2ecd45ca93121 100644 --- a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/role/RestGetRolesAction.java +++ b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/role/RestGetRolesAction.java @@ -21,7 +21,6 @@ import org.elasticsearch.xpack.security.rest.action.SecurityBaseRestHandler; import java.io.IOException; -import java.util.Arrays; import java.util.Collections; import java.util.List; @@ -44,10 +43,10 @@ public List routes() { @Override public List replacedRoutes() { // TODO: remove deprecated endpoint in 8.0.0 - return Collections.unmodifiableList(Arrays.asList( + return List.of( new ReplacedRoute(GET, "/_security/role/", GET, "/_xpack/security/role/"), new ReplacedRoute(GET, "/_security/role/{name}", GET, "/_xpack/security/role/{name}") - )); + ); } @Override diff --git a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/role/RestPutRoleAction.java b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/role/RestPutRoleAction.java index b5de02bdb13b9..2a92be067805d 100644 --- a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/role/RestPutRoleAction.java +++ b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/role/RestPutRoleAction.java @@ -19,7 +19,6 @@ import org.elasticsearch.xpack.security.rest.action.SecurityBaseRestHandler; import java.io.IOException; -import java.util.Arrays; import java.util.Collections; import java.util.List; @@ -43,10 +42,10 @@ public List routes() { @Override public List replacedRoutes() { // TODO: remove deprecated endpoint in 8.0.0 - return Collections.unmodifiableList(Arrays.asList( + return List.of( new ReplacedRoute(POST, "/_security/role/{name}", POST, "/_xpack/security/role/{name}"), new ReplacedRoute(PUT, "/_security/role/{name}", PUT, "/_xpack/security/role/{name}") - )); + ); } @Override diff --git a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/rolemapping/RestGetRoleMappingsAction.java b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/rolemapping/RestGetRoleMappingsAction.java index a255374e3c401..fe0dda3c344ec 100644 --- a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/rolemapping/RestGetRoleMappingsAction.java +++ b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/rolemapping/RestGetRoleMappingsAction.java @@ -20,7 +20,6 @@ import org.elasticsearch.xpack.security.rest.action.SecurityBaseRestHandler; import java.io.IOException; -import java.util.Arrays; import java.util.Collections; import java.util.List; @@ -43,10 +42,10 @@ public List routes() { @Override public List replacedRoutes() { // TODO: remove deprecated endpoint in 8.0.0 - return Collections.unmodifiableList(Arrays.asList( + return List.of( new ReplacedRoute(GET, "/_security/role_mapping/", GET, "/_xpack/security/role_mapping/"), new ReplacedRoute(GET, "/_security/role_mapping/{name}", GET, "/_xpack/security/role_mapping/{name}") - )); + ); } @Override diff --git a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/rolemapping/RestPutRoleMappingAction.java b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/rolemapping/RestPutRoleMappingAction.java index f5988caf73396..e2e28712139c5 100644 --- a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/rolemapping/RestPutRoleMappingAction.java +++ b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/rolemapping/RestPutRoleMappingAction.java @@ -19,7 +19,6 @@ import org.elasticsearch.xpack.security.rest.action.SecurityBaseRestHandler; import java.io.IOException; -import java.util.Arrays; import java.util.Collections; import java.util.List; @@ -45,10 +44,10 @@ public List routes() { @Override public List replacedRoutes() { // TODO: remove deprecated endpoint in 8.0.0 - return Collections.unmodifiableList(Arrays.asList( + return List.of( new ReplacedRoute(POST, "/_security/role_mapping/{name}", POST, "/_xpack/security/role_mapping/{name}"), new ReplacedRoute(PUT, "/_security/role_mapping/{name}", PUT, "/_xpack/security/role_mapping/{name}") - )); + ); } @Override diff --git a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/user/RestChangePasswordAction.java b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/user/RestChangePasswordAction.java index 1b637f043cf01..7072f926aaa6b 100644 --- a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/user/RestChangePasswordAction.java +++ b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/user/RestChangePasswordAction.java @@ -25,7 +25,6 @@ import org.elasticsearch.xpack.security.rest.action.SecurityBaseRestHandler; import java.io.IOException; -import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.Set; @@ -52,7 +51,7 @@ public List routes() { @Override public List replacedRoutes() { // TODO: remove deprecated endpoint in 8.0.0 - return Collections.unmodifiableList(Arrays.asList( + return List.of( new ReplacedRoute(PUT, "/_security/user/{username}/_password", PUT, "/_xpack/security/user/{username}/_password"), new ReplacedRoute(POST, "/_security/user/{username}/_password", @@ -61,7 +60,7 @@ public List replacedRoutes() { PUT, "/_xpack/security/user/_password"), new ReplacedRoute(POST, "/_security/user/_password", POST, "/_xpack/security/user/_password") - )); + ); } @Override diff --git a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/user/RestGetUsersAction.java b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/user/RestGetUsersAction.java index d3e51dce9bd3d..81c5510243c46 100644 --- a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/user/RestGetUsersAction.java +++ b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/user/RestGetUsersAction.java @@ -21,7 +21,6 @@ import org.elasticsearch.xpack.security.rest.action.SecurityBaseRestHandler; import java.io.IOException; -import java.util.Arrays; import java.util.Collections; import java.util.List; @@ -44,10 +43,10 @@ public List routes() { @Override public List replacedRoutes() { // TODO: remove deprecated endpoint in 8.0.0 - return Collections.unmodifiableList(Arrays.asList( + return List.of( new ReplacedRoute(GET, "/_security/user/", GET, "/_xpack/security/user/"), new ReplacedRoute(GET, "/_security/user/{username}", GET, "/_xpack/security/user/{username}") - )); + ); } @Override diff --git a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/user/RestHasPrivilegesAction.java b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/user/RestHasPrivilegesAction.java index 20d83436fecdd..2fabf96481aad 100644 --- a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/user/RestHasPrivilegesAction.java +++ b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/user/RestHasPrivilegesAction.java @@ -27,7 +27,6 @@ import org.elasticsearch.xpack.security.rest.action.SecurityBaseRestHandler; import java.io.IOException; -import java.util.Arrays; import java.util.Collections; import java.util.List; @@ -55,7 +54,7 @@ public List routes() { @Override public List replacedRoutes() { // TODO: remove deprecated endpoint in 8.0.0 - return Collections.unmodifiableList(Arrays.asList( + return List.of( new ReplacedRoute(GET, "/_security/user/{username}/_has_privileges", GET, "/_xpack/security/user/{username}/_has_privileges"), new ReplacedRoute(POST, "/_security/user/{username}/_has_privileges", @@ -64,7 +63,7 @@ public List replacedRoutes() { GET, "/_xpack/security/user/_has_privileges"), new ReplacedRoute(POST, "/_security/user/_has_privileges", POST, "/_xpack/security/user/_has_privileges") - )); + ); } @Override diff --git a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/user/RestPutUserAction.java b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/user/RestPutUserAction.java index c2d22b26f42d9..240d20fe008a4 100644 --- a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/user/RestPutUserAction.java +++ b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/user/RestPutUserAction.java @@ -23,7 +23,6 @@ import org.elasticsearch.xpack.security.rest.action.SecurityBaseRestHandler; import java.io.IOException; -import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.Set; @@ -51,12 +50,12 @@ public List routes() { @Override public List replacedRoutes() { // TODO: remove deprecated endpoint in 8.0.0 - return Collections.unmodifiableList(Arrays.asList( + return List.of( new ReplacedRoute(POST, "/_security/user/{username}", POST, "/_xpack/security/user/{username}"), new ReplacedRoute(PUT, "/_security/user/{username}", PUT, "/_xpack/security/user/{username}") - )); + ); } @Override diff --git a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/user/RestSetEnabledAction.java b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/user/RestSetEnabledAction.java index e2b77c7e90ee3..f2075da2946f9 100644 --- a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/user/RestSetEnabledAction.java +++ b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/user/RestSetEnabledAction.java @@ -19,7 +19,6 @@ import org.elasticsearch.xpack.security.rest.action.SecurityBaseRestHandler; import java.io.IOException; -import java.util.Arrays; import java.util.Collections; import java.util.List; @@ -44,7 +43,7 @@ public List routes() { @Override public List replacedRoutes() { // TODO: remove deprecated endpoint in 8.0.0 - return Collections.unmodifiableList(Arrays.asList( + return List.of( new ReplacedRoute(POST, "/_security/user/{username}/_enable", POST, "/_xpack/security/user/{username}/_enable"), new ReplacedRoute(PUT, "/_security/user/{username}/_enable", @@ -53,7 +52,7 @@ public List replacedRoutes() { POST, "/_xpack/security/user/{username}/_disable"), new ReplacedRoute(PUT, "/_security/user/{username}/_disable", PUT, "/_xpack/security/user/{username}/_disable") - )); + ); } @Override diff --git a/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/plugin/RestSqlClearCursorAction.java b/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/plugin/RestSqlClearCursorAction.java index b9d8c94c76abf..19bf3ea168789 100644 --- a/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/plugin/RestSqlClearCursorAction.java +++ b/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/plugin/RestSqlClearCursorAction.java @@ -18,14 +18,13 @@ import java.io.IOException; import java.util.List; -import static java.util.Collections.singletonList; import static org.elasticsearch.rest.RestRequest.Method.POST; public class RestSqlClearCursorAction extends BaseRestHandler { @Override public List routes() { - return singletonList(new Route(POST, Protocol.CLEAR_CURSOR_REST_ENDPOINT)); + return List.of(new Route(POST, Protocol.CLEAR_CURSOR_REST_ENDPOINT)); } @Override diff --git a/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/plugin/RestSqlQueryAction.java b/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/plugin/RestSqlQueryAction.java index c5af7b3a86c02..412f5475fbfc2 100644 --- a/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/plugin/RestSqlQueryAction.java +++ b/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/plugin/RestSqlQueryAction.java @@ -26,8 +26,6 @@ import java.nio.charset.StandardCharsets; import java.util.List; -import static java.util.Arrays.asList; -import static java.util.Collections.unmodifiableList; import static org.elasticsearch.rest.RestRequest.Method.GET; import static org.elasticsearch.rest.RestRequest.Method.POST; @@ -35,9 +33,9 @@ public class RestSqlQueryAction extends BaseRestHandler { @Override public List routes() { - return unmodifiableList(asList( + return List.of( new Route(GET, Protocol.SQL_QUERY_REST_ENDPOINT), - new Route(POST, Protocol.SQL_QUERY_REST_ENDPOINT))); + new Route(POST, Protocol.SQL_QUERY_REST_ENDPOINT)); } @Override diff --git a/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/plugin/RestSqlStatsAction.java b/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/plugin/RestSqlStatsAction.java index 01c3ec8be9e05..07033377e9645 100644 --- a/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/plugin/RestSqlStatsAction.java +++ b/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/plugin/RestSqlStatsAction.java @@ -14,14 +14,13 @@ import java.util.List; -import static java.util.Collections.singletonList; import static org.elasticsearch.rest.RestRequest.Method.GET; public class RestSqlStatsAction extends BaseRestHandler { @Override public List routes() { - return singletonList(new Route(GET, Protocol.SQL_STATS_REST_ENDPOINT)); + return List.of(new Route(GET, Protocol.SQL_STATS_REST_ENDPOINT)); } @Override diff --git a/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/plugin/RestSqlTranslateAction.java b/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/plugin/RestSqlTranslateAction.java index d059055feb22b..4744e09828f20 100644 --- a/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/plugin/RestSqlTranslateAction.java +++ b/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/plugin/RestSqlTranslateAction.java @@ -17,8 +17,6 @@ import java.io.IOException; import java.util.List; -import static java.util.Arrays.asList; -import static java.util.Collections.unmodifiableList; import static org.elasticsearch.rest.RestRequest.Method.GET; import static org.elasticsearch.rest.RestRequest.Method.POST; @@ -29,9 +27,9 @@ public class RestSqlTranslateAction extends BaseRestHandler { @Override public List routes() { - return unmodifiableList(asList( + return List.of( new Route(GET, Protocol.SQL_TRANSLATE_REST_ENDPOINT), - new Route(POST, Protocol.SQL_TRANSLATE_REST_ENDPOINT))); + new Route(POST, Protocol.SQL_TRANSLATE_REST_ENDPOINT)); } @Override diff --git a/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/rest/action/RestDeleteTransformAction.java b/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/rest/action/RestDeleteTransformAction.java index da60f8e040ee1..2df69749de3b3 100644 --- a/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/rest/action/RestDeleteTransformAction.java +++ b/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/rest/action/RestDeleteTransformAction.java @@ -15,14 +15,13 @@ import java.util.List; -import static java.util.Collections.singletonList; import static org.elasticsearch.rest.RestRequest.Method.DELETE; public class RestDeleteTransformAction extends BaseRestHandler { @Override public List routes() { - return singletonList(new Route(DELETE, TransformField.REST_BASE_PATH_TRANSFORMS_BY_ID)); + return List.of(new Route(DELETE, TransformField.REST_BASE_PATH_TRANSFORMS_BY_ID)); } @Override diff --git a/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/rest/action/RestGetTransformAction.java b/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/rest/action/RestGetTransformAction.java index 58670d10dce2a..f57e830debe7b 100644 --- a/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/rest/action/RestGetTransformAction.java +++ b/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/rest/action/RestGetTransformAction.java @@ -16,8 +16,6 @@ import java.util.List; -import static java.util.Arrays.asList; -import static java.util.Collections.unmodifiableList; import static org.elasticsearch.rest.RestRequest.Method.GET; import static org.elasticsearch.xpack.core.transform.TransformField.ALLOW_NO_MATCH; @@ -25,9 +23,9 @@ public class RestGetTransformAction extends BaseRestHandler { @Override public List routes() { - return unmodifiableList(asList( + return List.of( new Route(GET, TransformField.REST_BASE_PATH_TRANSFORMS), - new Route(GET, TransformField.REST_BASE_PATH_TRANSFORMS_BY_ID))); + new Route(GET, TransformField.REST_BASE_PATH_TRANSFORMS_BY_ID)); } @Override diff --git a/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/rest/action/RestGetTransformStatsAction.java b/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/rest/action/RestGetTransformStatsAction.java index fa4d2364437f8..2f59d5b8c568c 100644 --- a/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/rest/action/RestGetTransformStatsAction.java +++ b/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/rest/action/RestGetTransformStatsAction.java @@ -16,8 +16,6 @@ import java.util.List; -import static java.util.Arrays.asList; -import static java.util.Collections.unmodifiableList; import static org.elasticsearch.rest.RestRequest.Method.GET; import static org.elasticsearch.xpack.core.transform.TransformField.ALLOW_NO_MATCH; @@ -25,9 +23,9 @@ public class RestGetTransformStatsAction extends BaseRestHandler { @Override public List routes() { - return unmodifiableList(asList( + return List.of( new Route(GET, TransformField.REST_BASE_PATH_TRANSFORMS + "_stats"), - new Route(GET, TransformField.REST_BASE_PATH_TRANSFORMS_BY_ID + "_stats"))); + new Route(GET, TransformField.REST_BASE_PATH_TRANSFORMS_BY_ID + "_stats")); } @Override diff --git a/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/rest/action/RestPreviewTransformAction.java b/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/rest/action/RestPreviewTransformAction.java index f5c0fe1808c24..0ebf1da8158fe 100644 --- a/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/rest/action/RestPreviewTransformAction.java +++ b/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/rest/action/RestPreviewTransformAction.java @@ -17,14 +17,13 @@ import java.io.IOException; import java.util.List; -import static java.util.Collections.singletonList; import static org.elasticsearch.rest.RestRequest.Method.POST; public class RestPreviewTransformAction extends BaseRestHandler { @Override public List routes() { - return singletonList(new Route(POST, TransformField.REST_BASE_PATH_TRANSFORMS + "_preview")); + return List.of(new Route(POST, TransformField.REST_BASE_PATH_TRANSFORMS + "_preview")); } @Override diff --git a/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/rest/action/RestPutTransformAction.java b/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/rest/action/RestPutTransformAction.java index 06bb43ee3cd80..e32ab447577cd 100644 --- a/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/rest/action/RestPutTransformAction.java +++ b/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/rest/action/RestPutTransformAction.java @@ -17,14 +17,13 @@ import java.io.IOException; import java.util.List; -import static java.util.Collections.singletonList; import static org.elasticsearch.rest.RestRequest.Method.PUT; public class RestPutTransformAction extends BaseRestHandler { @Override public List routes() { - return singletonList(new Route(PUT, TransformField.REST_BASE_PATH_TRANSFORMS_BY_ID)); + return List.of(new Route(PUT, TransformField.REST_BASE_PATH_TRANSFORMS_BY_ID)); } @Override diff --git a/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/rest/action/RestStartTransformAction.java b/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/rest/action/RestStartTransformAction.java index bf791c2179103..c99dcb79344a7 100644 --- a/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/rest/action/RestStartTransformAction.java +++ b/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/rest/action/RestStartTransformAction.java @@ -16,14 +16,13 @@ import java.util.List; -import static java.util.Collections.singletonList; import static org.elasticsearch.rest.RestRequest.Method.POST; public class RestStartTransformAction extends BaseRestHandler { @Override public List routes() { - return singletonList(new Route(POST, TransformField.REST_BASE_PATH_TRANSFORMS_BY_ID + "_start")); + return List.of(new Route(POST, TransformField.REST_BASE_PATH_TRANSFORMS_BY_ID + "_start")); } @Override diff --git a/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/rest/action/RestStopTransformAction.java b/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/rest/action/RestStopTransformAction.java index 4ed3f03648ccb..aaf1c3470d8c8 100644 --- a/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/rest/action/RestStopTransformAction.java +++ b/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/rest/action/RestStopTransformAction.java @@ -15,14 +15,13 @@ import java.util.List; -import static java.util.Collections.singletonList; import static org.elasticsearch.rest.RestRequest.Method.POST; public class RestStopTransformAction extends BaseRestHandler { @Override public List routes() { - return singletonList(new Route(POST, TransformField.REST_BASE_PATH_TRANSFORMS_BY_ID + "_stop")); + return List.of(new Route(POST, TransformField.REST_BASE_PATH_TRANSFORMS_BY_ID + "_stop")); } @Override diff --git a/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/rest/action/RestUpdateTransformAction.java b/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/rest/action/RestUpdateTransformAction.java index 08ac7566ff469..65e7dac0596db 100644 --- a/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/rest/action/RestUpdateTransformAction.java +++ b/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/rest/action/RestUpdateTransformAction.java @@ -17,14 +17,13 @@ import java.io.IOException; import java.util.List; -import static java.util.Collections.singletonList; import static org.elasticsearch.rest.RestRequest.Method.POST; public class RestUpdateTransformAction extends BaseRestHandler { @Override public List routes() { - return singletonList(new Route(POST, TransformField.REST_BASE_PATH_TRANSFORMS_BY_ID + "_update")); + return List.of(new Route(POST, TransformField.REST_BASE_PATH_TRANSFORMS_BY_ID + "_update")); } @Override diff --git a/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/rest/action/compat/RestGetTransformActionDeprecated.java b/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/rest/action/compat/RestGetTransformActionDeprecated.java index a7ac8a4a0f014..cb4061803385d 100644 --- a/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/rest/action/compat/RestGetTransformActionDeprecated.java +++ b/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/rest/action/compat/RestGetTransformActionDeprecated.java @@ -21,8 +21,6 @@ import java.util.Collections; import java.util.List; -import static java.util.Arrays.asList; -import static java.util.Collections.unmodifiableList; import static org.elasticsearch.rest.RestRequest.Method.GET; import static org.elasticsearch.xpack.core.transform.TransformField.ALLOW_NO_MATCH; @@ -38,11 +36,11 @@ public List routes() { @Override public List deprecatedRoutes() { - return unmodifiableList(asList( + return List.of( new DeprecatedRoute(GET, TransformField.REST_BASE_PATH_TRANSFORMS_DEPRECATED, TransformMessages.REST_DEPRECATED_ENDPOINT), new DeprecatedRoute(GET, TransformField.REST_BASE_PATH_TRANSFORMS_BY_ID_DEPRECATED, - TransformMessages.REST_DEPRECATED_ENDPOINT))); + TransformMessages.REST_DEPRECATED_ENDPOINT)); } @Override diff --git a/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/rest/action/compat/RestGetTransformStatsActionDeprecated.java b/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/rest/action/compat/RestGetTransformStatsActionDeprecated.java index c66a08467b914..0eae6e7184eb4 100644 --- a/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/rest/action/compat/RestGetTransformStatsActionDeprecated.java +++ b/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/rest/action/compat/RestGetTransformStatsActionDeprecated.java @@ -21,8 +21,6 @@ import java.util.Collections; import java.util.List; -import static java.util.Arrays.asList; -import static java.util.Collections.unmodifiableList; import static org.elasticsearch.rest.RestRequest.Method.GET; import static org.elasticsearch.xpack.core.transform.TransformField.ALLOW_NO_MATCH; @@ -38,11 +36,11 @@ public List routes() { @Override public List deprecatedRoutes() { - return unmodifiableList(asList( + return List.of( new DeprecatedRoute(GET, TransformField.REST_BASE_PATH_TRANSFORMS_DEPRECATED + "_stats", TransformMessages.REST_DEPRECATED_ENDPOINT), new DeprecatedRoute(GET, TransformField.REST_BASE_PATH_TRANSFORMS_BY_ID_DEPRECATED + "_stats", - TransformMessages.REST_DEPRECATED_ENDPOINT))); + TransformMessages.REST_DEPRECATED_ENDPOINT)); } @Override diff --git a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/Watcher.java b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/Watcher.java index b7646930322f7..17a98b7532b88 100644 --- a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/Watcher.java +++ b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/Watcher.java @@ -689,9 +689,9 @@ public void reload(Settings settings) { @Override public Collection getSystemIndexDescriptors() { - return Collections.unmodifiableList(Arrays.asList( + return List.of( new SystemIndexDescriptor(Watch.INDEX, "Contains Watch definitions"), new SystemIndexDescriptor(TriggeredWatchStoreField.INDEX_NAME, "Used to track current and queued Watch execution") - )); + ); } } diff --git a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestAckWatchAction.java b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestAckWatchAction.java index 5ce678ac33ab9..e22325ad8e2c4 100644 --- a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestAckWatchAction.java +++ b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestAckWatchAction.java @@ -22,8 +22,6 @@ import java.util.List; -import static java.util.Arrays.asList; -import static java.util.Collections.unmodifiableList; import static org.elasticsearch.rest.RestRequest.Method.POST; import static org.elasticsearch.rest.RestRequest.Method.PUT; @@ -34,11 +32,11 @@ public class RestAckWatchAction extends BaseRestHandler { @Override public List routes() { - return unmodifiableList(asList( + return List.of( new Route(POST, "/_watcher/watch/{id}/_ack"), new Route(PUT, "/_watcher/watch/{id}/_ack"), new Route(POST, "/_watcher/watch/{id}/_ack/{actions}"), - new Route(PUT, "/_watcher/watch/{id}/_ack/{actions}"))); + new Route(PUT, "/_watcher/watch/{id}/_ack/{actions}")); } @Override diff --git a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestActivateWatchAction.java b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestActivateWatchAction.java index 7bfdb5e726c88..78584c2def7d1 100644 --- a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestActivateWatchAction.java +++ b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestActivateWatchAction.java @@ -22,8 +22,6 @@ import java.util.List; -import static java.util.Arrays.asList; -import static java.util.Collections.unmodifiableList; import static org.elasticsearch.rest.RestRequest.Method.POST; import static org.elasticsearch.rest.RestRequest.Method.PUT; @@ -34,9 +32,9 @@ public class RestActivateWatchAction extends BaseRestHandler { @Override public List routes() { - return unmodifiableList(asList( + return List.of( new Route(POST, "/_watcher/watch/{id}/_activate"), - new Route(PUT, "/_watcher/watch/{id}/_activate"))); + new Route(PUT, "/_watcher/watch/{id}/_activate")); } @Override @@ -63,9 +61,9 @@ public static class DeactivateRestHandler extends BaseRestHandler { @Override public List routes() { - return unmodifiableList(asList( + return List.of( new Route(POST, "/_watcher/watch/{id}/_deactivate"), - new Route(PUT, "/_watcher/watch/{id}/_deactivate"))); + new Route(PUT, "/_watcher/watch/{id}/_deactivate")); } @Override diff --git a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestDeleteWatchAction.java b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestDeleteWatchAction.java index 332fb8140aa35..51b88c989cb04 100644 --- a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestDeleteWatchAction.java +++ b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestDeleteWatchAction.java @@ -20,7 +20,6 @@ import java.util.List; -import static java.util.Collections.singletonList; import static org.elasticsearch.rest.RestRequest.Method.DELETE; import static org.elasticsearch.rest.RestStatus.NOT_FOUND; import static org.elasticsearch.rest.RestStatus.OK; @@ -29,7 +28,7 @@ public class RestDeleteWatchAction extends BaseRestHandler { @Override public List routes() { - return singletonList(new Route(DELETE, "/_watcher/watch/{id}")); + return List.of(new Route(DELETE, "/_watcher/watch/{id}")); } @Override diff --git a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestExecuteWatchAction.java b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestExecuteWatchAction.java index 14e841d23e857..d56839ab5f16c 100644 --- a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestExecuteWatchAction.java +++ b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestExecuteWatchAction.java @@ -34,7 +34,6 @@ import java.util.Set; import static java.util.Arrays.asList; -import static java.util.Collections.unmodifiableList; import static org.elasticsearch.rest.RestRequest.Method.POST; import static org.elasticsearch.rest.RestRequest.Method.PUT; import static org.elasticsearch.xpack.watcher.rest.action.RestExecuteWatchAction.Field.IGNORE_CONDITION; @@ -50,11 +49,11 @@ public class RestExecuteWatchAction extends BaseRestHandler implements RestReque @Override public List routes() { - return unmodifiableList(asList( + return List.of( new Route(POST, "/_watcher/watch/{id}/_execute"), new Route(PUT, "/_watcher/watch/{id}/_execute"), new Route(POST, "/_watcher/watch/_execute"), - new Route(PUT, "/_watcher/watch/_execute"))); + new Route(PUT, "/_watcher/watch/_execute")); } @Override diff --git a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestGetWatchAction.java b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestGetWatchAction.java index 0a3a4f576dae1..cedc69c816be8 100644 --- a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestGetWatchAction.java +++ b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestGetWatchAction.java @@ -20,7 +20,6 @@ import java.util.List; -import static java.util.Collections.singletonList; import static org.elasticsearch.rest.RestRequest.Method.GET; import static org.elasticsearch.rest.RestStatus.NOT_FOUND; import static org.elasticsearch.rest.RestStatus.OK; @@ -29,7 +28,7 @@ public class RestGetWatchAction extends BaseRestHandler { @Override public List routes() { - return singletonList(new Route(GET, "/_watcher/watch/{id}")); + return List.of(new Route(GET, "/_watcher/watch/{id}")); } @Override diff --git a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestPutWatchAction.java b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestPutWatchAction.java index 5cf1ca6ee4c30..c57a0ede0fb8d 100644 --- a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestPutWatchAction.java +++ b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestPutWatchAction.java @@ -25,8 +25,6 @@ import java.util.List; import java.util.Set; -import static java.util.Arrays.asList; -import static java.util.Collections.unmodifiableList; import static org.elasticsearch.rest.RestRequest.Method.POST; import static org.elasticsearch.rest.RestRequest.Method.PUT; import static org.elasticsearch.rest.RestStatus.CREATED; @@ -36,9 +34,9 @@ public class RestPutWatchAction extends BaseRestHandler implements RestRequestFi @Override public List routes() { - return unmodifiableList(asList( + return List.of( new Route(POST, "/_watcher/watch/{id}"), - new Route(PUT, "/_watcher/watch/{id}"))); + new Route(PUT, "/_watcher/watch/{id}")); } @Override diff --git a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestWatchServiceAction.java b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestWatchServiceAction.java index 991b724694129..ff5a860d6ec09 100644 --- a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestWatchServiceAction.java +++ b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestWatchServiceAction.java @@ -15,14 +15,13 @@ import java.util.List; -import static java.util.Collections.singletonList; import static org.elasticsearch.rest.RestRequest.Method.POST; public class RestWatchServiceAction extends BaseRestHandler { @Override public List routes() { - return singletonList(new Route(POST, "/_watcher/_start")); + return List.of(new Route(POST, "/_watcher/_start")); } @Override @@ -40,7 +39,7 @@ public static class StopRestHandler extends BaseRestHandler { @Override public List routes() { - return singletonList(new Route(POST, "/_watcher/_stop")); + return List.of(new Route(POST, "/_watcher/_stop")); } @Override diff --git a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestWatcherStatsAction.java b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestWatcherStatsAction.java index 2c3319b92c981..f1ce3a6c71964 100644 --- a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestWatcherStatsAction.java +++ b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestWatcherStatsAction.java @@ -21,8 +21,6 @@ import java.util.List; import java.util.Set; -import static java.util.Arrays.asList; -import static java.util.Collections.unmodifiableList; import static org.elasticsearch.rest.RestRequest.Method.GET; public class RestWatcherStatsAction extends BaseRestHandler { @@ -31,9 +29,9 @@ public class RestWatcherStatsAction extends BaseRestHandler { @Override public List routes() { - return unmodifiableList(asList( + return List.of( new Route(GET, "/_watcher/stats"), - new Route(GET, "/_watcher/stats/{metric}"))); + new Route(GET, "/_watcher/stats/{metric}")); } @Override