Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use List convenience methods in rest actions #52286

Merged
merged 1 commit into from
Feb 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -49,11 +47,11 @@ public class RestNoopBulkAction extends BaseRestHandler {

@Override
public List<Route> 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,18 @@

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;

public class RestNoopSearchAction extends BaseRestHandler {

@Override
public List<Route> 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -120,7 +119,7 @@ public static class RestAction extends BaseRestHandler {

@Override
public List<Route> routes() {
return singletonList(new Route(GET, "/_ingest/processor/grok"));
return List.of(new Route(GET, "/_ingest/processor/grok"));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -58,11 +57,11 @@ public RestMultiSearchTemplateAction(Settings settings) {

@Override
public List<Route> 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,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;
import static org.elasticsearch.rest.RestRequest.Method.POST;

public class RestRenderSearchTemplateAction extends BaseRestHandler {

@Override
public List<Route> 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -50,11 +48,11 @@ public class RestSearchTemplateAction extends BaseRestHandler {

@Override
public List<Route> 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down Expand Up @@ -196,7 +195,7 @@ public static class RestAction extends BaseRestHandler {

@Override
public List<Route> routes() {
return singletonList(new Route(GET, "/_scripts/painless/_context"));
return List.of(new Route(GET, "/_scripts/painless/_context"));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -568,9 +566,9 @@ public static class RestAction extends BaseRestHandler {

@Override
public List<Route> 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -94,11 +92,11 @@ public class RestRankEvalAction extends BaseRestHandler {

@Override
public List<Route> 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<DeleteByQueryRequest, DeleteByQueryAction> {
Expand All @@ -39,7 +38,7 @@ public RestDeleteByQueryAction() {

@Override
public List<Route> routes() {
return singletonList(new Route(POST, "/{index}/_delete_by_query"));
return List.of(new Route(POST, "/{index}/_delete_by_query"));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -41,7 +40,7 @@ public RestReindexAction() {

@Override
public List<Route> routes() {
return singletonList(new Route(POST, "/_reindex"));
return List.of(new Route(POST, "/_reindex"));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -42,10 +40,10 @@ public RestRethrottleAction(Supplier<DiscoveryNodes> nodesInCluster) {

@Override
public List<Route> 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -46,7 +45,7 @@ public RestUpdateByQueryAction() {

@Override
public List<Route> routes() {
return singletonList(new Route(POST, "/{index}/_update_by_query"));
return List.of(new Route(POST, "/{index}/_update_by_query"));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -39,9 +37,9 @@ public class ExampleCatAction extends AbstractCatAction {

@Override
public List<Route> routes() {
return unmodifiableList(asList(
return List.of(
new Route(GET, "/_cat/example"),
new Route(POST, "/_cat/example")));
new Route(POST, "/_cat/example"));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -34,7 +33,7 @@ public class RestDieWithDignityAction extends BaseRestHandler {

@Override
public List<Route> routes() {
return singletonList(new Route(GET, "/_die_with_dignity"));
return List.of(new Route(GET, "/_die_with_dignity"));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Route> routes() {
return singletonList(new Route(GET, "/_protected"));
return List.of(new Route(GET, "/_protected"));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,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;
import static org.elasticsearch.rest.RestRequest.Method.POST;

public class RestFieldCapabilitiesAction extends BaseRestHandler {

@Override
public List<Route> 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,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;
import static org.elasticsearch.rest.RestRequest.Method.HEAD;

public class RestMainAction extends BaseRestHandler {

@Override
public List<Route> routes() {
return unmodifiableList(asList(
return List.of(
new Route(GET, "/"),
new Route(HEAD, "/")));
new Route(HEAD, "/"));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -45,7 +44,7 @@ public String getName() {

@Override
public List<Route> 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -51,8 +49,8 @@ public String getName() {

@Override
public List<Route> 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
Expand Down
Loading