From 4d58656065af81b1e333f17347c150b4309d299f Mon Sep 17 00:00:00 2001 From: Nik Everett Date: Fri, 3 Jan 2020 11:48:11 -0500 Subject: [PATCH] Declare remaining parsers `final` (#50571) (#50615) We have about 800 `ObjectParsers` in Elasticsearch, about 700 of which are final. This is *probably* the right way to declare them because in practice we never mutate them after they are built. And we certainly don't change the static reference. Anyway, this adds `final` to these parsers. I found the non-final parsers with this: ``` diff \ <(find . -type f -name '*.java' -exec grep -iHe 'static.*PARSER\s*=' {} \+ | sort) \ <(find . -type f -name '*.java' -exec grep -iHe 'static.*final.*PARSER\s*=' {} \+ | sort) \ 2>&1 | grep '^<' ``` --- .../org/elasticsearch/client/SyncedFlushResponse.java | 2 +- .../org/elasticsearch/client/core/MainResponse.java | 3 +-- .../client/core/MultiTermVectorsResponse.java | 2 +- .../elasticsearch/client/core/TermVectorsResponse.java | 10 +++++----- .../elasticsearch/client/ml/StartDatafeedRequest.java | 2 +- .../client/ml/dataframe/DataFrameAnalyticsConfig.java | 2 +- .../client/ml/dataframe/DataFrameAnalyticsDest.java | 2 +- .../client/ml/dataframe/DataFrameAnalyticsSource.java | 2 +- .../client/ml/dataframe/OutlierDetection.java | 2 +- .../elasticsearch/client/watcher/AckWatchResponse.java | 2 +- .../client/watcher/ActivateWatchResponse.java | 2 +- .../elasticsearch/client/watcher/GetWatchResponse.java | 2 +- .../client/watcher/WatcherStatsResponse.java | 2 +- .../smoketest/DocsClientYamlTestSuiteIT.java | 2 +- .../aggregations/matrix/stats/ParsedMatrixStats.java | 2 +- .../index/query/RankFeatureQueryBuilder.java | 2 +- .../allocation/ClusterAllocationExplainRequest.java | 2 +- .../action/admin/indices/rollover/RolloverInfo.java | 2 +- .../admin/indices/validate/query/QueryExplanation.java | 2 +- .../indices/validate/query/ValidateQueryResponse.java | 2 +- .../elasticsearch/action/bulk/BulkItemResponse.java | 2 +- .../action/fieldcaps/FieldCapabilities.java | 2 +- .../action/fieldcaps/FieldCapabilitiesRequest.java | 2 +- .../java/org/elasticsearch/common/geo/GeoJson.java | 2 +- .../org/elasticsearch/index/query/IdsQueryBuilder.java | 3 +-- .../query/functionscore/ScriptScoreQueryBuilder.java | 2 +- .../elasticsearch/index/reindex/BulkByScrollTask.java | 2 +- .../org/elasticsearch/index/seqno/RetentionLease.java | 2 +- .../org/elasticsearch/index/seqno/RetentionLeases.java | 2 +- .../org/elasticsearch/script/ScriptContextInfo.java | 6 +++--- .../org/elasticsearch/script/ScriptLanguagesInfo.java | 4 ++-- .../main/java/org/elasticsearch/search/SearchHit.java | 2 +- .../bucket/adjacency/ParsedAdjacencyMatrix.java | 2 +- .../aggregations/bucket/composite/ParsedComposite.java | 2 +- .../aggregations/bucket/filter/ParsedFilters.java | 2 +- .../aggregations/bucket/geogrid/ParsedGeoHashGrid.java | 2 +- .../aggregations/bucket/geogrid/ParsedGeoTileGrid.java | 2 +- .../histogram/DateHistogramAggregationBuilder.java | 2 +- .../bucket/histogram/ParsedAutoDateHistogram.java | 2 +- .../bucket/histogram/ParsedDateHistogram.java | 2 +- .../aggregations/bucket/histogram/ParsedHistogram.java | 2 +- .../aggregations/bucket/range/ParsedBinaryRange.java | 2 +- .../aggregations/bucket/range/ParsedDateRange.java | 2 +- .../aggregations/bucket/range/ParsedGeoDistance.java | 2 +- .../search/aggregations/bucket/range/ParsedRange.java | 2 +- .../bucket/significant/ParsedSignificantLongTerms.java | 2 +- .../significant/ParsedSignificantStringTerms.java | 2 +- .../aggregations/bucket/terms/ParsedDoubleTerms.java | 2 +- .../aggregations/bucket/terms/ParsedLongTerms.java | 2 +- .../aggregations/bucket/terms/ParsedStringTerms.java | 2 +- .../aggregations/metrics/ParsedHDRPercentileRanks.java | 2 +- .../aggregations/metrics/ParsedHDRPercentiles.java | 2 +- .../metrics/ParsedTDigestPercentileRanks.java | 2 +- .../aggregations/metrics/ParsedTDigestPercentiles.java | 2 +- .../search/aggregations/metrics/ParsedTopHits.java | 2 +- .../aggregations/pipeline/ParsedPercentilesBucket.java | 2 +- .../elasticsearch/search/sort/FieldSortBuilder.java | 2 +- .../elasticsearch/search/sort/ScoreSortBuilder.java | 2 +- .../elasticsearch/search/sort/ScriptSortBuilder.java | 2 +- .../suggest/completion/CompletionSuggestion.java | 5 ++--- .../completion/context/CategoryQueryContext.java | 2 +- .../suggest/completion/context/GeoQueryContext.java | 2 +- .../search/suggest/phrase/PhraseSuggestion.java | 3 +-- .../search/suggest/term/TermSuggestion.java | 3 +-- .../common/geo/GeoJsonSerializationTests.java | 2 +- 65 files changed, 73 insertions(+), 78 deletions(-) diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/SyncedFlushResponse.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/SyncedFlushResponse.java index 303e8328d08..41e9c3d062b 100644 --- a/client/rest-high-level/src/main/java/org/elasticsearch/client/SyncedFlushResponse.java +++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/SyncedFlushResponse.java @@ -282,7 +282,7 @@ public class SyncedFlushResponse implements ToXContentObject { private Map routing; @SuppressWarnings("unchecked") - static ConstructingObjectParser PARSER = new ConstructingObjectParser<>( + static final ConstructingObjectParser PARSER = new ConstructingObjectParser<>( "shardfailure", a -> new ShardFailure((Integer)a[0], (String)a[1], (Map)a[2]) ); diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/core/MainResponse.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/core/MainResponse.java index 09fc2b49a01..5fa0120611f 100644 --- a/client/rest-high-level/src/main/java/org/elasticsearch/client/core/MainResponse.java +++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/core/MainResponse.java @@ -99,8 +99,7 @@ public class MainResponse { } public static class Version { - @SuppressWarnings("unchecked") - private static ConstructingObjectParser PARSER = + private static final ConstructingObjectParser PARSER = new ConstructingObjectParser<>(Version.class.getName(), true, args -> { return new Version((String) args[0], (String) args[1], (String) args[2], (String) args[3], (String) args[4], diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/core/MultiTermVectorsResponse.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/core/MultiTermVectorsResponse.java index 0a2974a8aa1..ea58e93eb9e 100644 --- a/client/rest-high-level/src/main/java/org/elasticsearch/client/core/MultiTermVectorsResponse.java +++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/core/MultiTermVectorsResponse.java @@ -36,7 +36,7 @@ public class MultiTermVectorsResponse { this.responses = responses; } - private static ConstructingObjectParser PARSER = + private static final ConstructingObjectParser PARSER = new ConstructingObjectParser<>("multi_term_vectors", true, args -> { // as the response comes from server, we are sure that args[0] will be a list of TermVectorsResponse diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/core/TermVectorsResponse.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/core/TermVectorsResponse.java index ca813502905..e448ba075a6 100644 --- a/client/rest-high-level/src/main/java/org/elasticsearch/client/core/TermVectorsResponse.java +++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/core/TermVectorsResponse.java @@ -51,7 +51,7 @@ public class TermVectorsResponse { this.termVectorList = termVectorList; } - private static ConstructingObjectParser PARSER = new ConstructingObjectParser<>("term_vectors", true, + private static final ConstructingObjectParser PARSER = new ConstructingObjectParser<>("term_vectors", true, args -> { // as the response comes from server, we are sure that args[6] will be a list of TermVector @SuppressWarnings("unchecked") List termVectorList = (List) args[6]; @@ -161,7 +161,7 @@ public class TermVectorsResponse { public static final class TermVector { - private static ConstructingObjectParser PARSER = new ConstructingObjectParser<>("term_vector", true, + private static final ConstructingObjectParser PARSER = new ConstructingObjectParser<>("term_vector", true, (args, ctxFieldName) -> { // as the response comes from server, we are sure that args[1] will be a list of Term @SuppressWarnings("unchecked") List terms = (List) args[1]; @@ -234,7 +234,7 @@ public class TermVectorsResponse { // Class containing a general field statistics for the field public static final class FieldStatistics { - private static ConstructingObjectParser PARSER = new ConstructingObjectParser<>( + private static final ConstructingObjectParser PARSER = new ConstructingObjectParser<>( "field_statistics", true, args -> { return new FieldStatistics((long) args[0], (int) args[1], (long) args[2]); @@ -298,7 +298,7 @@ public class TermVectorsResponse { public static final class Term { - private static ConstructingObjectParser PARSER = new ConstructingObjectParser<>("token", true, + private static final ConstructingObjectParser PARSER = new ConstructingObjectParser<>("token", true, (args, ctxTerm) -> { // as the response comes from server, we are sure that args[4] will be a list of Token @SuppressWarnings("unchecked") List tokens = (List) args[4]; @@ -409,7 +409,7 @@ public class TermVectorsResponse { public static final class Token { - private static ConstructingObjectParser PARSER = new ConstructingObjectParser<>("token", true, + private static final ConstructingObjectParser PARSER = new ConstructingObjectParser<>("token", true, args -> { return new Token((Integer) args[0], (Integer) args[1], (Integer) args[2], (String) args[3]); }); diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/ml/StartDatafeedRequest.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/ml/StartDatafeedRequest.java index 4ee6d747e57..d636c4da3dc 100644 --- a/client/rest-high-level/src/main/java/org/elasticsearch/client/ml/StartDatafeedRequest.java +++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/ml/StartDatafeedRequest.java @@ -39,7 +39,7 @@ public class StartDatafeedRequest extends ActionRequest implements ToXContentObj public static final ParseField END = new ParseField("end"); public static final ParseField TIMEOUT = new ParseField("timeout"); - public static ConstructingObjectParser PARSER = + public static final ConstructingObjectParser PARSER = new ConstructingObjectParser<>("start_datafeed_request", a -> new StartDatafeedRequest((String)a[0])); static { diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/ml/dataframe/DataFrameAnalyticsConfig.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/ml/dataframe/DataFrameAnalyticsConfig.java index 0c3f98b9a46..5e803f714cd 100644 --- a/client/rest-high-level/src/main/java/org/elasticsearch/client/ml/dataframe/DataFrameAnalyticsConfig.java +++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/ml/dataframe/DataFrameAnalyticsConfig.java @@ -58,7 +58,7 @@ public class DataFrameAnalyticsConfig implements ToXContentObject { private static final ParseField VERSION = new ParseField("version"); private static final ParseField ALLOW_LAZY_START = new ParseField("allow_lazy_start"); - private static ObjectParser PARSER = new ObjectParser<>("data_frame_analytics_config", true, Builder::new); + private static final ObjectParser PARSER = new ObjectParser<>("data_frame_analytics_config", true, Builder::new); static { PARSER.declareString(Builder::setId, ID); diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/ml/dataframe/DataFrameAnalyticsDest.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/ml/dataframe/DataFrameAnalyticsDest.java index 4123f85ee2f..3b765c9b49c 100644 --- a/client/rest-high-level/src/main/java/org/elasticsearch/client/ml/dataframe/DataFrameAnalyticsDest.java +++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/ml/dataframe/DataFrameAnalyticsDest.java @@ -45,7 +45,7 @@ public class DataFrameAnalyticsDest implements ToXContentObject { private static final ParseField INDEX = new ParseField("index"); private static final ParseField RESULTS_FIELD = new ParseField("results_field"); - private static ObjectParser PARSER = new ObjectParser<>("data_frame_analytics_dest", true, Builder::new); + private static final ObjectParser PARSER = new ObjectParser<>("data_frame_analytics_dest", true, Builder::new); static { PARSER.declareString(Builder::setIndex, INDEX); diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/ml/dataframe/DataFrameAnalyticsSource.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/ml/dataframe/DataFrameAnalyticsSource.java index 1f731f4c28a..29672fb569d 100644 --- a/client/rest-high-level/src/main/java/org/elasticsearch/client/ml/dataframe/DataFrameAnalyticsSource.java +++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/ml/dataframe/DataFrameAnalyticsSource.java @@ -47,7 +47,7 @@ public class DataFrameAnalyticsSource implements ToXContentObject { private static final ParseField QUERY = new ParseField("query"); public static final ParseField _SOURCE = new ParseField("_source"); - private static ObjectParser PARSER = new ObjectParser<>("data_frame_analytics_source", true, Builder::new); + private static final ObjectParser PARSER = new ObjectParser<>("data_frame_analytics_source", true, Builder::new); static { PARSER.declareStringArray(Builder::setIndex, INDEX); diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/ml/dataframe/OutlierDetection.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/ml/dataframe/OutlierDetection.java index f58c9b3d354..ceb6b6e71f2 100644 --- a/client/rest-high-level/src/main/java/org/elasticsearch/client/ml/dataframe/OutlierDetection.java +++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/ml/dataframe/OutlierDetection.java @@ -51,7 +51,7 @@ public class OutlierDetection implements DataFrameAnalysis { static final ParseField OUTLIER_FRACTION = new ParseField("outlier_fraction"); static final ParseField STANDARDIZATION_ENABLED = new ParseField("standardization_enabled"); - private static ObjectParser PARSER = new ObjectParser<>(NAME.getPreferredName(), true, Builder::new); + private static final ObjectParser PARSER = new ObjectParser<>(NAME.getPreferredName(), true, Builder::new); static { PARSER.declareInt(Builder::setNNeighbors, N_NEIGHBORS); diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/watcher/AckWatchResponse.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/watcher/AckWatchResponse.java index 5c6750193a7..61245462dbe 100644 --- a/client/rest-high-level/src/main/java/org/elasticsearch/client/watcher/AckWatchResponse.java +++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/watcher/AckWatchResponse.java @@ -45,7 +45,7 @@ public class AckWatchResponse { } private static final ParseField STATUS_FIELD = new ParseField("status"); - private static ConstructingObjectParser PARSER = + private static final ConstructingObjectParser PARSER = new ConstructingObjectParser<>("ack_watch_response", true, a -> new AckWatchResponse((WatchStatus) a[0])); diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/watcher/ActivateWatchResponse.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/watcher/ActivateWatchResponse.java index b1e63e767f3..d4dc044df64 100644 --- a/client/rest-high-level/src/main/java/org/elasticsearch/client/watcher/ActivateWatchResponse.java +++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/watcher/ActivateWatchResponse.java @@ -32,7 +32,7 @@ import java.util.Objects; public final class ActivateWatchResponse { private static final ParseField STATUS_FIELD = new ParseField("status"); - private static ConstructingObjectParser PARSER = + private static final ConstructingObjectParser PARSER = new ConstructingObjectParser<>("activate_watch_response", true, a -> new ActivateWatchResponse((WatchStatus) a[0])); diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/watcher/GetWatchResponse.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/watcher/GetWatchResponse.java index 83727003106..43a1a2a7815 100644 --- a/client/rest-high-level/src/main/java/org/elasticsearch/client/watcher/GetWatchResponse.java +++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/watcher/GetWatchResponse.java @@ -132,7 +132,7 @@ public class GetWatchResponse { private static final ParseField STATUS_FIELD = new ParseField("status"); private static final ParseField WATCH_FIELD = new ParseField("watch"); - private static ConstructingObjectParser PARSER = + private static final ConstructingObjectParser PARSER = new ConstructingObjectParser<>("get_watch_response", true, a -> { boolean isFound = (boolean) a[1]; diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/watcher/WatcherStatsResponse.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/watcher/WatcherStatsResponse.java index 708954e666b..513adc8bd14 100644 --- a/client/rest-high-level/src/main/java/org/elasticsearch/client/watcher/WatcherStatsResponse.java +++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/watcher/WatcherStatsResponse.java @@ -82,7 +82,7 @@ public class WatcherStatsResponse { } @SuppressWarnings("unchecked") - private static ConstructingObjectParser PARSER = + private static final ConstructingObjectParser PARSER = new ConstructingObjectParser<>("watcher_stats_response", true, a -> new WatcherStatsResponse((NodesResponseHeader) a[0], (String) a[1], new WatcherMetaData((boolean) a[2]), (List) a[3])); diff --git a/docs/src/test/java/org/elasticsearch/smoketest/DocsClientYamlTestSuiteIT.java b/docs/src/test/java/org/elasticsearch/smoketest/DocsClientYamlTestSuiteIT.java index 14fef433446..ff796aba81d 100644 --- a/docs/src/test/java/org/elasticsearch/smoketest/DocsClientYamlTestSuiteIT.java +++ b/docs/src/test/java/org/elasticsearch/smoketest/DocsClientYamlTestSuiteIT.java @@ -125,7 +125,7 @@ public class DocsClientYamlTestSuiteIT extends ESClientYamlSuiteTestCase { * small number of tokens. */ private static class CompareAnalyzers implements ExecutableSection { - private static ConstructingObjectParser PARSER = + private static final ConstructingObjectParser PARSER = new ConstructingObjectParser<>("test_analyzer", false, (a, location) -> { String index = (String) a[0]; String first = (String) a[1]; diff --git a/modules/aggs-matrix-stats/src/main/java/org/elasticsearch/search/aggregations/matrix/stats/ParsedMatrixStats.java b/modules/aggs-matrix-stats/src/main/java/org/elasticsearch/search/aggregations/matrix/stats/ParsedMatrixStats.java index ba28e0b0ee3..660ecc93098 100644 --- a/modules/aggs-matrix-stats/src/main/java/org/elasticsearch/search/aggregations/matrix/stats/ParsedMatrixStats.java +++ b/modules/aggs-matrix-stats/src/main/java/org/elasticsearch/search/aggregations/matrix/stats/ParsedMatrixStats.java @@ -187,7 +187,7 @@ public class ParsedMatrixStats extends ParsedAggregation implements MatrixStats Map covariances; Map correlations; - private static ObjectParser RESULT_PARSER = + private static final ObjectParser RESULT_PARSER = new ObjectParser<>(ParsedMatrixStatsResult.class.getSimpleName(), true, ParsedMatrixStatsResult::new); static { RESULT_PARSER.declareString((result, name) -> result.name = name, diff --git a/modules/mapper-extras/src/main/java/org/elasticsearch/index/query/RankFeatureQueryBuilder.java b/modules/mapper-extras/src/main/java/org/elasticsearch/index/query/RankFeatureQueryBuilder.java index c934e0c1f79..86990d95c42 100644 --- a/modules/mapper-extras/src/main/java/org/elasticsearch/index/query/RankFeatureQueryBuilder.java +++ b/modules/mapper-extras/src/main/java/org/elasticsearch/index/query/RankFeatureQueryBuilder.java @@ -260,7 +260,7 @@ public final class RankFeatureQueryBuilder extends AbstractQueryBuilder PARSER = new ConstructingObjectParser<>( + public static final ConstructingObjectParser PARSER = new ConstructingObjectParser<>( "feature", args -> { final String field = (String) args[0]; final float boost = args[1] == null ? DEFAULT_BOOST : (Float) args[1]; diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/allocation/ClusterAllocationExplainRequest.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/allocation/ClusterAllocationExplainRequest.java index 0b0bb8c57a9..e1c5856e116 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/allocation/ClusterAllocationExplainRequest.java +++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/allocation/ClusterAllocationExplainRequest.java @@ -37,7 +37,7 @@ import static org.elasticsearch.action.ValidateActions.addValidationError; */ public class ClusterAllocationExplainRequest extends MasterNodeRequest { - private static ObjectParser PARSER = new ObjectParser<>("cluster/allocation/explain"); + private static final ObjectParser PARSER = new ObjectParser<>("cluster/allocation/explain"); static { PARSER.declareString(ClusterAllocationExplainRequest::setIndex, new ParseField("index")); PARSER.declareInt(ClusterAllocationExplainRequest::setShard, new ParseField("shard")); diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/rollover/RolloverInfo.java b/server/src/main/java/org/elasticsearch/action/admin/indices/rollover/RolloverInfo.java index af593481e8a..61118852670 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/rollover/RolloverInfo.java +++ b/server/src/main/java/org/elasticsearch/action/admin/indices/rollover/RolloverInfo.java @@ -44,7 +44,7 @@ public class RolloverInfo extends AbstractDiffable implements Writ public static final ParseField TIME_FIELD = new ParseField("time"); @SuppressWarnings("unchecked") - public static ConstructingObjectParser PARSER = new ConstructingObjectParser<>("rollover_info", false, + public static final ConstructingObjectParser PARSER = new ConstructingObjectParser<>("rollover_info", false, (a, alias) -> new RolloverInfo(alias, (List>) a[0], (Long) a[1])); static { PARSER.declareNamedObjects(ConstructingObjectParser.constructorArg(), diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/validate/query/QueryExplanation.java b/server/src/main/java/org/elasticsearch/action/admin/indices/validate/query/QueryExplanation.java index 64a3b09018e..c00ac18c0b5 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/validate/query/QueryExplanation.java +++ b/server/src/main/java/org/elasticsearch/action/admin/indices/validate/query/QueryExplanation.java @@ -45,7 +45,7 @@ public class QueryExplanation implements Writeable, ToXContentFragment { public static final int RANDOM_SHARD = -1; - static ConstructingObjectParser PARSER = new ConstructingObjectParser<>( + static final ConstructingObjectParser PARSER = new ConstructingObjectParser<>( "query_explanation", true, a -> { diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/validate/query/ValidateQueryResponse.java b/server/src/main/java/org/elasticsearch/action/admin/indices/validate/query/ValidateQueryResponse.java index 2489011fd3d..9937d98c38a 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/validate/query/ValidateQueryResponse.java +++ b/server/src/main/java/org/elasticsearch/action/admin/indices/validate/query/ValidateQueryResponse.java @@ -48,7 +48,7 @@ public class ValidateQueryResponse extends BroadcastResponse { public static final String EXPLANATIONS_FIELD = "explanations"; @SuppressWarnings("unchecked") - static ConstructingObjectParser PARSER = new ConstructingObjectParser<>( + static final ConstructingObjectParser PARSER = new ConstructingObjectParser<>( "validate_query", true, arg -> { diff --git a/server/src/main/java/org/elasticsearch/action/bulk/BulkItemResponse.java b/server/src/main/java/org/elasticsearch/action/bulk/BulkItemResponse.java index fab0bd0e580..4b0d26afe88 100644 --- a/server/src/main/java/org/elasticsearch/action/bulk/BulkItemResponse.java +++ b/server/src/main/java/org/elasticsearch/action/bulk/BulkItemResponse.java @@ -179,7 +179,7 @@ public class BulkItemResponse implements Writeable, StatusToXContentObject { private final long term; private final boolean aborted; - public static ConstructingObjectParser PARSER = + public static final ConstructingObjectParser PARSER = new ConstructingObjectParser<>( "bulk_failures", true, diff --git a/server/src/main/java/org/elasticsearch/action/fieldcaps/FieldCapabilities.java b/server/src/main/java/org/elasticsearch/action/fieldcaps/FieldCapabilities.java index 20f525716a2..cfdda760cc4 100644 --- a/server/src/main/java/org/elasticsearch/action/fieldcaps/FieldCapabilities.java +++ b/server/src/main/java/org/elasticsearch/action/fieldcaps/FieldCapabilities.java @@ -141,7 +141,7 @@ public class FieldCapabilities implements Writeable, ToXContentObject { } @SuppressWarnings("unchecked") - private static ConstructingObjectParser PARSER = new ConstructingObjectParser<>( + private static final ConstructingObjectParser PARSER = new ConstructingObjectParser<>( "field_capabilities", true, (a, name) -> new FieldCapabilities(name, diff --git a/server/src/main/java/org/elasticsearch/action/fieldcaps/FieldCapabilitiesRequest.java b/server/src/main/java/org/elasticsearch/action/fieldcaps/FieldCapabilitiesRequest.java index 442ed3f68ee..905384a7639 100644 --- a/server/src/main/java/org/elasticsearch/action/fieldcaps/FieldCapabilitiesRequest.java +++ b/server/src/main/java/org/elasticsearch/action/fieldcaps/FieldCapabilitiesRequest.java @@ -49,7 +49,7 @@ public final class FieldCapabilitiesRequest extends ActionRequest implements Ind // pkg private API mainly for cross cluster search to signal that we do multiple reductions ie. the results should not be merged private boolean mergeResults = true; - private static ObjectParser PARSER = + private static final ObjectParser PARSER = new ObjectParser<>(NAME, FieldCapabilitiesRequest::new); static { diff --git a/server/src/main/java/org/elasticsearch/common/geo/GeoJson.java b/server/src/main/java/org/elasticsearch/common/geo/GeoJson.java index 9324d50d8e1..e1e0f0c9f02 100644 --- a/server/src/main/java/org/elasticsearch/common/geo/GeoJson.java +++ b/server/src/main/java/org/elasticsearch/common/geo/GeoJson.java @@ -206,7 +206,7 @@ public final class GeoJson { return builder.endObject(); } - private static ConstructingObjectParser PARSER = + private static final ConstructingObjectParser PARSER = new ConstructingObjectParser<>("geojson", true, (a, c) -> { String type = (String) a[0]; CoordinateNode coordinates = (CoordinateNode) a[1]; diff --git a/server/src/main/java/org/elasticsearch/index/query/IdsQueryBuilder.java b/server/src/main/java/org/elasticsearch/index/query/IdsQueryBuilder.java index 358a2fccff1..304f17e88cb 100644 --- a/server/src/main/java/org/elasticsearch/index/query/IdsQueryBuilder.java +++ b/server/src/main/java/org/elasticsearch/index/query/IdsQueryBuilder.java @@ -143,8 +143,7 @@ public class IdsQueryBuilder extends AbstractQueryBuilder { builder.endObject(); } - private static ObjectParser PARSER = new ObjectParser<>(NAME, - () -> new IdsQueryBuilder()); + private static final ObjectParser PARSER = new ObjectParser<>(NAME, IdsQueryBuilder::new); static { PARSER.declareStringArray(fromList(String.class, IdsQueryBuilder::types), IdsQueryBuilder.TYPE_FIELD); diff --git a/server/src/main/java/org/elasticsearch/index/query/functionscore/ScriptScoreQueryBuilder.java b/server/src/main/java/org/elasticsearch/index/query/functionscore/ScriptScoreQueryBuilder.java index e55c6d31877..74e51ff09a6 100644 --- a/server/src/main/java/org/elasticsearch/index/query/functionscore/ScriptScoreQueryBuilder.java +++ b/server/src/main/java/org/elasticsearch/index/query/functionscore/ScriptScoreQueryBuilder.java @@ -53,7 +53,7 @@ public class ScriptScoreQueryBuilder extends AbstractQueryBuilder PARSER = new ConstructingObjectParser<>(NAME, false, + private static final ConstructingObjectParser PARSER = new ConstructingObjectParser<>(NAME, false, args -> { ScriptScoreQueryBuilder ssQueryBuilder = new ScriptScoreQueryBuilder((QueryBuilder) args[0], (Script) args[1]); if (args[2] != null) ssQueryBuilder.setMinScore((Float) args[2]); diff --git a/server/src/main/java/org/elasticsearch/index/reindex/BulkByScrollTask.java b/server/src/main/java/org/elasticsearch/index/reindex/BulkByScrollTask.java index 8df6620dabc..f60b6fc85e1 100644 --- a/server/src/main/java/org/elasticsearch/index/reindex/BulkByScrollTask.java +++ b/server/src/main/java/org/elasticsearch/index/reindex/BulkByScrollTask.java @@ -383,7 +383,7 @@ public class BulkByScrollTask extends CancellableTask { } @SuppressWarnings("unchecked") - static ConstructingObjectParser, Void> RETRIES_PARSER = new ConstructingObjectParser<>( + static final ConstructingObjectParser, Void> RETRIES_PARSER = new ConstructingObjectParser<>( "bulk_by_scroll_task_status_retries", true, a -> new Tuple(a[0], a[1]) diff --git a/server/src/main/java/org/elasticsearch/index/seqno/RetentionLease.java b/server/src/main/java/org/elasticsearch/index/seqno/RetentionLease.java index 9cfad7c36ea..bf667cc2937 100644 --- a/server/src/main/java/org/elasticsearch/index/seqno/RetentionLease.java +++ b/server/src/main/java/org/elasticsearch/index/seqno/RetentionLease.java @@ -145,7 +145,7 @@ public final class RetentionLease implements ToXContentObject, Writeable { private static final ParseField TIMESTAMP_FIELD = new ParseField("timestamp"); private static final ParseField SOURCE_FIELD = new ParseField("source"); - private static ConstructingObjectParser PARSER = new ConstructingObjectParser<>( + private static final ConstructingObjectParser PARSER = new ConstructingObjectParser<>( "retention_leases", (a) -> new RetentionLease((String) a[0], (Long) a[1], (Long) a[2], (String) a[3])); diff --git a/server/src/main/java/org/elasticsearch/index/seqno/RetentionLeases.java b/server/src/main/java/org/elasticsearch/index/seqno/RetentionLeases.java index d29e82d3ab3..06313a48a82 100644 --- a/server/src/main/java/org/elasticsearch/index/seqno/RetentionLeases.java +++ b/server/src/main/java/org/elasticsearch/index/seqno/RetentionLeases.java @@ -182,7 +182,7 @@ public class RetentionLeases implements ToXContentFragment, Writeable { private static final ParseField LEASES_FIELD = new ParseField("leases"); @SuppressWarnings("unchecked") - private static ConstructingObjectParser PARSER = new ConstructingObjectParser<>( + private static final ConstructingObjectParser PARSER = new ConstructingObjectParser<>( "retention_leases", (a) -> new RetentionLeases((Long) a[0], (Long) a[1], (Collection) a[2])); diff --git a/server/src/main/java/org/elasticsearch/script/ScriptContextInfo.java b/server/src/main/java/org/elasticsearch/script/ScriptContextInfo.java index 6969af32915..245b8809496 100644 --- a/server/src/main/java/org/elasticsearch/script/ScriptContextInfo.java +++ b/server/src/main/java/org/elasticsearch/script/ScriptContextInfo.java @@ -135,7 +135,7 @@ public class ScriptContextInfo implements ToXContentObject, Writeable { } @SuppressWarnings("unchecked") - public static ConstructingObjectParser PARSER = + public static final ConstructingObjectParser PARSER = new ConstructingObjectParser<>("script_context_info", true, (m, name) -> new ScriptContextInfo((String) m[0], (List) m[1]) ); @@ -210,7 +210,7 @@ public class ScriptContextInfo implements ToXContentObject, Writeable { } @SuppressWarnings("unchecked") - private static ConstructingObjectParser PARSER = + private static final ConstructingObjectParser PARSER = new ConstructingObjectParser<>("method", true, (m, name) -> new ScriptMethodInfo((String) m[0], (String) m[1], (List) m[2]) ); @@ -271,7 +271,7 @@ public class ScriptContextInfo implements ToXContentObject, Writeable { out.writeString(name); } - private static ConstructingObjectParser PARSER = + private static final ConstructingObjectParser PARSER = new ConstructingObjectParser<>("parameters", true, (p) -> new ParameterInfo((String)p[0], (String)p[1]) ); diff --git a/server/src/main/java/org/elasticsearch/script/ScriptLanguagesInfo.java b/server/src/main/java/org/elasticsearch/script/ScriptLanguagesInfo.java index 4a131bc8af5..28b1c13e555 100644 --- a/server/src/main/java/org/elasticsearch/script/ScriptLanguagesInfo.java +++ b/server/src/main/java/org/elasticsearch/script/ScriptLanguagesInfo.java @@ -98,7 +98,7 @@ public class ScriptLanguagesInfo implements ToXContentObject, Writeable { } @SuppressWarnings("unchecked") - public static ConstructingObjectParser PARSER = + public static final ConstructingObjectParser PARSER = new ConstructingObjectParser<>("script_languages_info", true, (a) -> new ScriptLanguagesInfo( new HashSet<>((List)a[0]), @@ -107,7 +107,7 @@ public class ScriptLanguagesInfo implements ToXContentObject, Writeable { ); @SuppressWarnings("unchecked") - private static ConstructingObjectParser>,Void> LANGUAGE_CONTEXT_PARSER = + private static final ConstructingObjectParser>,Void> LANGUAGE_CONTEXT_PARSER = new ConstructingObjectParser<>("language_contexts", true, (m, name) -> new Tuple<>((String)m[0], Collections.unmodifiableSet(new HashSet<>((List)m[1]))) ); diff --git a/server/src/main/java/org/elasticsearch/search/SearchHit.java b/server/src/main/java/org/elasticsearch/search/SearchHit.java index 2c56c713bb8..864133e571e 100644 --- a/server/src/main/java/org/elasticsearch/search/SearchHit.java +++ b/server/src/main/java/org/elasticsearch/search/SearchHit.java @@ -676,7 +676,7 @@ public final class SearchHit implements Writeable, ToXContentObject, Iterable, Void> MAP_PARSER = new ObjectParser<>("innerHitParser", true, HashMap::new); + private static final ObjectParser, Void> MAP_PARSER = new ObjectParser<>("innerHitParser", true, HashMap::new); static { declareInnerHitsParseFields(MAP_PARSER); diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/adjacency/ParsedAdjacencyMatrix.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/adjacency/ParsedAdjacencyMatrix.java index 1fb356d45c2..b07bbf529d2 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/adjacency/ParsedAdjacencyMatrix.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/adjacency/ParsedAdjacencyMatrix.java @@ -53,7 +53,7 @@ public class ParsedAdjacencyMatrix extends ParsedMultiBucketAggregation PARSER = + private static final ObjectParser PARSER = new ObjectParser<>(ParsedAdjacencyMatrix.class.getSimpleName(), true, ParsedAdjacencyMatrix::new); static { declareMultiBucketAggregationFields(PARSER, diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/composite/ParsedComposite.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/composite/ParsedComposite.java index e7d6f775f1d..6dc42c7405d 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/composite/ParsedComposite.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/composite/ParsedComposite.java @@ -30,7 +30,7 @@ import java.util.List; import java.util.Map; public class ParsedComposite extends ParsedMultiBucketAggregation implements CompositeAggregation { - private static ObjectParser PARSER = + private static final ObjectParser PARSER = new ObjectParser<>(ParsedComposite.class.getSimpleName(), true, ParsedComposite::new); static { diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/filter/ParsedFilters.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/filter/ParsedFilters.java index b2e9c36ccbe..194c18cc4ab 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/filter/ParsedFilters.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/filter/ParsedFilters.java @@ -60,7 +60,7 @@ public class ParsedFilters extends ParsedMultiBucketAggregation PARSER = + private static final ObjectParser PARSER = new ObjectParser<>(ParsedFilters.class.getSimpleName(), true, ParsedFilters::new); static { declareMultiBucketAggregationFields(PARSER, diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/geogrid/ParsedGeoHashGrid.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/geogrid/ParsedGeoHashGrid.java index b9af237eb63..362c220fdff 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/geogrid/ParsedGeoHashGrid.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/geogrid/ParsedGeoHashGrid.java @@ -26,7 +26,7 @@ import java.io.IOException; public class ParsedGeoHashGrid extends ParsedGeoGrid { - private static ObjectParser PARSER = createParser(ParsedGeoHashGrid::new, + private static final ObjectParser PARSER = createParser(ParsedGeoHashGrid::new, ParsedGeoHashGridBucket::fromXContent, ParsedGeoHashGridBucket::fromXContent); public static ParsedGeoGrid fromXContent(XContentParser parser, String name) throws IOException { diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/geogrid/ParsedGeoTileGrid.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/geogrid/ParsedGeoTileGrid.java index e88c7ad3054..9e07d6af1dc 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/geogrid/ParsedGeoTileGrid.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/geogrid/ParsedGeoTileGrid.java @@ -26,7 +26,7 @@ import java.io.IOException; public class ParsedGeoTileGrid extends ParsedGeoGrid { - private static ObjectParser PARSER = createParser(ParsedGeoTileGrid::new, + private static final ObjectParser PARSER = createParser(ParsedGeoTileGrid::new, ParsedGeoTileGridBucket::fromXContent, ParsedGeoTileGridBucket::fromXContent); public static ParsedGeoGrid fromXContent(XContentParser parser, String name) throws IOException { diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/DateHistogramAggregationBuilder.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/DateHistogramAggregationBuilder.java index 5b70c63ee4d..461a83ea3bb 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/DateHistogramAggregationBuilder.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/DateHistogramAggregationBuilder.java @@ -73,7 +73,7 @@ public class DateHistogramAggregationBuilder extends ValuesSourceAggregationBuil implements MultiBucketAggregationBuilder, DateIntervalConsumer { public static final String NAME = "date_histogram"; - private static DateMathParser EPOCH_MILLIS_PARSER = DateFormatter.forPattern("epoch_millis").toDateMathParser(); + private static final DateMathParser EPOCH_MILLIS_PARSER = DateFormatter.forPattern("epoch_millis").toDateMathParser(); public static final Map DATE_FIELD_UNITS; diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/ParsedAutoDateHistogram.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/ParsedAutoDateHistogram.java index 66a29b4e050..525591f5567 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/ParsedAutoDateHistogram.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/ParsedAutoDateHistogram.java @@ -52,7 +52,7 @@ public class ParsedAutoDateHistogram extends ParsedMultiBucketAggregation PARSER = + private static final ObjectParser PARSER = new ObjectParser<>(ParsedAutoDateHistogram.class.getSimpleName(), true, ParsedAutoDateHistogram::new); static { declareMultiBucketAggregationFields(PARSER, diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/ParsedDateHistogram.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/ParsedDateHistogram.java index 1cf43a53ed2..e212ecc6fb4 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/ParsedDateHistogram.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/ParsedDateHistogram.java @@ -41,7 +41,7 @@ public class ParsedDateHistogram extends ParsedMultiBucketAggregation PARSER = + private static final ObjectParser PARSER = new ObjectParser<>(ParsedDateHistogram.class.getSimpleName(), true, ParsedDateHistogram::new); static { declareMultiBucketAggregationFields(PARSER, diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/ParsedHistogram.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/ParsedHistogram.java index 6037c155886..6e0caac936f 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/ParsedHistogram.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/ParsedHistogram.java @@ -38,7 +38,7 @@ public class ParsedHistogram extends ParsedMultiBucketAggregation PARSER = + private static final ObjectParser PARSER = new ObjectParser<>(ParsedHistogram.class.getSimpleName(), true, ParsedHistogram::new); static { declareMultiBucketAggregationFields(PARSER, diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/range/ParsedBinaryRange.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/range/ParsedBinaryRange.java index 79b1cd6cc0d..4aadbb44a48 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/range/ParsedBinaryRange.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/range/ParsedBinaryRange.java @@ -45,7 +45,7 @@ public class ParsedBinaryRange extends ParsedMultiBucketAggregation PARSER = + private static final ObjectParser PARSER = new ObjectParser<>(ParsedBinaryRange.class.getSimpleName(), true, ParsedBinaryRange::new); static { declareMultiBucketAggregationFields(PARSER, diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/range/ParsedDateRange.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/range/ParsedDateRange.java index d4504e24554..3028aec4af2 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/range/ParsedDateRange.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/range/ParsedDateRange.java @@ -34,7 +34,7 @@ public class ParsedDateRange extends ParsedRange { return DateRangeAggregationBuilder.NAME; } - private static ObjectParser PARSER = + private static final ObjectParser PARSER = new ObjectParser<>(ParsedDateRange.class.getSimpleName(), true, ParsedDateRange::new); static { declareParsedRangeFields(PARSER, diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/range/ParsedGeoDistance.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/range/ParsedGeoDistance.java index 3a49a8e8de2..5d4afb1e3f0 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/range/ParsedGeoDistance.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/range/ParsedGeoDistance.java @@ -31,7 +31,7 @@ public class ParsedGeoDistance extends ParsedRange { return GeoDistanceAggregationBuilder.NAME; } - private static ObjectParser PARSER = + private static final ObjectParser PARSER = new ObjectParser<>(ParsedGeoDistance.class.getSimpleName(), true, ParsedGeoDistance::new); static { declareParsedRangeFields(PARSER, diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/range/ParsedRange.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/range/ParsedRange.java index 6095348e688..9546ff3784d 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/range/ParsedRange.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/range/ParsedRange.java @@ -53,7 +53,7 @@ public class ParsedRange extends ParsedMultiBucketAggregation PARSER = + private static final ObjectParser PARSER = new ObjectParser<>(ParsedRange.class.getSimpleName(), true, ParsedRange::new); static { declareParsedRangeFields(PARSER, diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/significant/ParsedSignificantLongTerms.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/significant/ParsedSignificantLongTerms.java index 9592d80c776..f48d0680698 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/significant/ParsedSignificantLongTerms.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/significant/ParsedSignificantLongTerms.java @@ -32,7 +32,7 @@ public class ParsedSignificantLongTerms extends ParsedSignificantTerms { return SignificantLongTerms.NAME; } - private static ObjectParser PARSER = + private static final ObjectParser PARSER = new ObjectParser<>(ParsedSignificantLongTerms.class.getSimpleName(), true, ParsedSignificantLongTerms::new); static { declareParsedSignificantTermsFields(PARSER, ParsedBucket::fromXContent); diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/significant/ParsedSignificantStringTerms.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/significant/ParsedSignificantStringTerms.java index 365cc8b588a..076aa74457f 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/significant/ParsedSignificantStringTerms.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/significant/ParsedSignificantStringTerms.java @@ -34,7 +34,7 @@ public class ParsedSignificantStringTerms extends ParsedSignificantTerms { return SignificantStringTerms.NAME; } - private static ObjectParser PARSER = + private static final ObjectParser PARSER = new ObjectParser<>(ParsedSignificantStringTerms.class.getSimpleName(), true, ParsedSignificantStringTerms::new); static { declareParsedSignificantTermsFields(PARSER, ParsedBucket::fromXContent); diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/ParsedDoubleTerms.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/ParsedDoubleTerms.java index d3afe5c1760..02bc3e636bb 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/ParsedDoubleTerms.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/ParsedDoubleTerms.java @@ -32,7 +32,7 @@ public class ParsedDoubleTerms extends ParsedTerms { return DoubleTerms.NAME; } - private static ObjectParser PARSER = + private static final ObjectParser PARSER = new ObjectParser<>(ParsedDoubleTerms.class.getSimpleName(), true, ParsedDoubleTerms::new); static { declareParsedTermsFields(PARSER, ParsedBucket::fromXContent); diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/ParsedLongTerms.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/ParsedLongTerms.java index b5869fc6ee2..07185abdcc0 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/ParsedLongTerms.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/ParsedLongTerms.java @@ -32,7 +32,7 @@ public class ParsedLongTerms extends ParsedTerms { return LongTerms.NAME; } - private static ObjectParser PARSER = + private static final ObjectParser PARSER = new ObjectParser<>(ParsedLongTerms.class.getSimpleName(), true, ParsedLongTerms::new); static { declareParsedTermsFields(PARSER, ParsedBucket::fromXContent); diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/ParsedStringTerms.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/ParsedStringTerms.java index ecd88c871df..29304ec1871 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/ParsedStringTerms.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/ParsedStringTerms.java @@ -34,7 +34,7 @@ public class ParsedStringTerms extends ParsedTerms { return StringTerms.NAME; } - private static ObjectParser PARSER = + private static final ObjectParser PARSER = new ObjectParser<>(ParsedStringTerms.class.getSimpleName(), true, ParsedStringTerms::new); static { declareParsedTermsFields(PARSER, ParsedBucket::fromXContent); diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/metrics/ParsedHDRPercentileRanks.java b/server/src/main/java/org/elasticsearch/search/aggregations/metrics/ParsedHDRPercentileRanks.java index eac1f210905..278f2423a43 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/metrics/ParsedHDRPercentileRanks.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/metrics/ParsedHDRPercentileRanks.java @@ -49,7 +49,7 @@ public class ParsedHDRPercentileRanks extends ParsedPercentileRanks { }; } - private static ObjectParser PARSER = + private static final ObjectParser PARSER = new ObjectParser<>(ParsedHDRPercentileRanks.class.getSimpleName(), true, ParsedHDRPercentileRanks::new); static { ParsedPercentiles.declarePercentilesFields(PARSER); diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/metrics/ParsedHDRPercentiles.java b/server/src/main/java/org/elasticsearch/search/aggregations/metrics/ParsedHDRPercentiles.java index bb34d8550d0..60f3a887343 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/metrics/ParsedHDRPercentiles.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/metrics/ParsedHDRPercentiles.java @@ -41,7 +41,7 @@ public class ParsedHDRPercentiles extends ParsedPercentiles implements Percentil return getPercentileAsString(percent); } - private static ObjectParser PARSER = + private static final ObjectParser PARSER = new ObjectParser<>(ParsedHDRPercentiles.class.getSimpleName(), true, ParsedHDRPercentiles::new); static { ParsedPercentiles.declarePercentilesFields(PARSER); diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/metrics/ParsedTDigestPercentileRanks.java b/server/src/main/java/org/elasticsearch/search/aggregations/metrics/ParsedTDigestPercentileRanks.java index f17bc8784ae..f15dacd74c1 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/metrics/ParsedTDigestPercentileRanks.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/metrics/ParsedTDigestPercentileRanks.java @@ -49,7 +49,7 @@ public class ParsedTDigestPercentileRanks extends ParsedPercentileRanks { }; } - private static ObjectParser PARSER = + private static final ObjectParser PARSER = new ObjectParser<>(ParsedTDigestPercentileRanks.class.getSimpleName(), true, ParsedTDigestPercentileRanks::new); static { ParsedPercentiles.declarePercentilesFields(PARSER); diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/metrics/ParsedTDigestPercentiles.java b/server/src/main/java/org/elasticsearch/search/aggregations/metrics/ParsedTDigestPercentiles.java index 2453c702b96..f7a876c16bf 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/metrics/ParsedTDigestPercentiles.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/metrics/ParsedTDigestPercentiles.java @@ -41,7 +41,7 @@ public class ParsedTDigestPercentiles extends ParsedPercentiles implements Perce return getPercentileAsString(percent); } - private static ObjectParser PARSER = + private static final ObjectParser PARSER = new ObjectParser<>(ParsedTDigestPercentiles.class.getSimpleName(), true, ParsedTDigestPercentiles::new); static { ParsedPercentiles.declarePercentilesFields(PARSER); diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/metrics/ParsedTopHits.java b/server/src/main/java/org/elasticsearch/search/aggregations/metrics/ParsedTopHits.java index 321ed5709e8..ced2698a52a 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/metrics/ParsedTopHits.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/metrics/ParsedTopHits.java @@ -47,7 +47,7 @@ public class ParsedTopHits extends ParsedAggregation implements TopHits { return searchHits.toXContent(builder, params); } - private static ObjectParser PARSER = + private static final ObjectParser PARSER = new ObjectParser<>(ParsedTopHits.class.getSimpleName(), true, ParsedTopHits::new); static { declareAggregationFields(PARSER); diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/pipeline/ParsedPercentilesBucket.java b/server/src/main/java/org/elasticsearch/search/aggregations/pipeline/ParsedPercentilesBucket.java index 360ed9de214..93bc53f3279 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/pipeline/ParsedPercentilesBucket.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/pipeline/ParsedPercentilesBucket.java @@ -73,7 +73,7 @@ public class ParsedPercentilesBucket extends ParsedPercentiles implements Percen return builder; } - private static ObjectParser PARSER = + private static final ObjectParser PARSER = new ObjectParser<>(ParsedPercentilesBucket.class.getSimpleName(), true, ParsedPercentilesBucket::new); static { diff --git a/server/src/main/java/org/elasticsearch/search/sort/FieldSortBuilder.java b/server/src/main/java/org/elasticsearch/search/sort/FieldSortBuilder.java index 98c423e6644..fb0f3fd15c1 100644 --- a/server/src/main/java/org/elasticsearch/search/sort/FieldSortBuilder.java +++ b/server/src/main/java/org/elasticsearch/search/sort/FieldSortBuilder.java @@ -616,7 +616,7 @@ public class FieldSortBuilder extends SortBuilder { return PARSER.parse(parser, new FieldSortBuilder(fieldName), null); } - private static ObjectParser PARSER = new ObjectParser<>(NAME); + private static final ObjectParser PARSER = new ObjectParser<>(NAME); static { PARSER.declareField(FieldSortBuilder::missing, p -> p.objectText(), MISSING, ValueType.VALUE); diff --git a/server/src/main/java/org/elasticsearch/search/sort/ScoreSortBuilder.java b/server/src/main/java/org/elasticsearch/search/sort/ScoreSortBuilder.java index c27979fdc74..112a5eb2c8c 100644 --- a/server/src/main/java/org/elasticsearch/search/sort/ScoreSortBuilder.java +++ b/server/src/main/java/org/elasticsearch/search/sort/ScoreSortBuilder.java @@ -86,7 +86,7 @@ public class ScoreSortBuilder extends SortBuilder { return PARSER.apply(parser, null); } - private static ObjectParser PARSER = new ObjectParser<>(NAME, ScoreSortBuilder::new); + private static final ObjectParser PARSER = new ObjectParser<>(NAME, ScoreSortBuilder::new); static { PARSER.declareString((builder, order) -> builder.order(SortOrder.fromString(order)), ORDER_FIELD); diff --git a/server/src/main/java/org/elasticsearch/search/sort/ScriptSortBuilder.java b/server/src/main/java/org/elasticsearch/search/sort/ScriptSortBuilder.java index fd0408a85bc..ded7c8e7817 100644 --- a/server/src/main/java/org/elasticsearch/search/sort/ScriptSortBuilder.java +++ b/server/src/main/java/org/elasticsearch/search/sort/ScriptSortBuilder.java @@ -270,7 +270,7 @@ public class ScriptSortBuilder extends SortBuilder { return builder; } - private static ConstructingObjectParser PARSER = new ConstructingObjectParser<>(NAME, + private static final ConstructingObjectParser PARSER = new ConstructingObjectParser<>(NAME, a -> new ScriptSortBuilder((Script) a[0], (ScriptSortType) a[1])); static { diff --git a/server/src/main/java/org/elasticsearch/search/suggest/completion/CompletionSuggestion.java b/server/src/main/java/org/elasticsearch/search/suggest/completion/CompletionSuggestion.java index b9bdd50569a..da1d48f81f8 100644 --- a/server/src/main/java/org/elasticsearch/search/suggest/completion/CompletionSuggestion.java +++ b/server/src/main/java/org/elasticsearch/search/suggest/completion/CompletionSuggestion.java @@ -265,9 +265,8 @@ public final class CompletionSuggestion extends Suggest.Suggestion PARSER = new ObjectParser<>("CompletionSuggestionEntryParser", true, + private static final ObjectParser PARSER = new ObjectParser<>("CompletionSuggestionEntryParser", true, Entry::new); - static { declareCommonFields(PARSER); PARSER.declareObjectArray(Entry::addOptions, (p,c) -> Option.fromXContent(p), new ParseField(OPTIONS)); @@ -358,7 +357,7 @@ public final class CompletionSuggestion extends Suggest.Suggestion, Void> PARSER = new ObjectParser<>("CompletionOptionParser", + private static final ObjectParser, Void> PARSER = new ObjectParser<>("CompletionOptionParser", true, HashMap::new); static { diff --git a/server/src/main/java/org/elasticsearch/search/suggest/completion/context/CategoryQueryContext.java b/server/src/main/java/org/elasticsearch/search/suggest/completion/context/CategoryQueryContext.java index e391f78f27c..9326e0ff666 100644 --- a/server/src/main/java/org/elasticsearch/search/suggest/completion/context/CategoryQueryContext.java +++ b/server/src/main/java/org/elasticsearch/search/suggest/completion/context/CategoryQueryContext.java @@ -95,7 +95,7 @@ public final class CategoryQueryContext implements ToXContentObject { return result; } - private static ObjectParser CATEGORY_PARSER = new ObjectParser<>(NAME, null); + private static final ObjectParser CATEGORY_PARSER = new ObjectParser<>(NAME, null); static { CATEGORY_PARSER.declareField(Builder::setCategory, XContentParser::text, new ParseField(CONTEXT_VALUE), ObjectParser.ValueType.VALUE); diff --git a/server/src/main/java/org/elasticsearch/search/suggest/completion/context/GeoQueryContext.java b/server/src/main/java/org/elasticsearch/search/suggest/completion/context/GeoQueryContext.java index 7885dd1d296..439fa161d38 100644 --- a/server/src/main/java/org/elasticsearch/search/suggest/completion/context/GeoQueryContext.java +++ b/server/src/main/java/org/elasticsearch/search/suggest/completion/context/GeoQueryContext.java @@ -112,7 +112,7 @@ public final class GeoQueryContext implements ToXContentObject { return new Builder(); } - private static ObjectParser GEO_CONTEXT_PARSER = new ObjectParser<>(NAME, null); + private static final ObjectParser GEO_CONTEXT_PARSER = new ObjectParser<>(NAME, null); static { GEO_CONTEXT_PARSER.declareField((parser, geoQueryContext, geoContextMapping) -> geoQueryContext.setGeoPoint(GeoUtils.parseGeoPoint(parser)), diff --git a/server/src/main/java/org/elasticsearch/search/suggest/phrase/PhraseSuggestion.java b/server/src/main/java/org/elasticsearch/search/suggest/phrase/PhraseSuggestion.java index a29c6f08a7d..fe7c03b11b1 100644 --- a/server/src/main/java/org/elasticsearch/search/suggest/phrase/PhraseSuggestion.java +++ b/server/src/main/java/org/elasticsearch/search/suggest/phrase/PhraseSuggestion.java @@ -120,8 +120,7 @@ public class PhraseSuggestion extends Suggest.Suggestion } } - private static ObjectParser PARSER = new ObjectParser<>("PhraseSuggestionEntryParser", true, Entry::new); - + private static final ObjectParser PARSER = new ObjectParser<>("PhraseSuggestionEntryParser", true, Entry::new); static { declareCommonFields(PARSER); PARSER.declareObjectArray(Entry::addOptions, (p, c) -> Option.fromXContent(p), new ParseField(OPTIONS)); diff --git a/server/src/main/java/org/elasticsearch/search/suggest/term/TermSuggestion.java b/server/src/main/java/org/elasticsearch/search/suggest/term/TermSuggestion.java index a1ffdd56709..938e452ae77 100644 --- a/server/src/main/java/org/elasticsearch/search/suggest/term/TermSuggestion.java +++ b/server/src/main/java/org/elasticsearch/search/suggest/term/TermSuggestion.java @@ -185,8 +185,7 @@ public class TermSuggestion extends Suggestion { return new Option(in); } - private static ObjectParser PARSER = new ObjectParser<>("TermSuggestionEntryParser", true, Entry::new); - + private static final ObjectParser PARSER = new ObjectParser<>("TermSuggestionEntryParser", true, Entry::new); static { declareCommonFields(PARSER); PARSER.declareObjectArray(Entry::addOptions, (p,c) -> Option.fromXContent(p), new ParseField(OPTIONS)); diff --git a/server/src/test/java/org/elasticsearch/common/geo/GeoJsonSerializationTests.java b/server/src/test/java/org/elasticsearch/common/geo/GeoJsonSerializationTests.java index 7d1ff1bfc58..e3974872dee 100644 --- a/server/src/test/java/org/elasticsearch/common/geo/GeoJsonSerializationTests.java +++ b/server/src/test/java/org/elasticsearch/common/geo/GeoJsonSerializationTests.java @@ -47,7 +47,7 @@ public class GeoJsonSerializationTests extends ESTestCase { private static class GeometryWrapper implements ToXContentObject { private Geometry geometry; - private static GeoJson PARSER = new GeoJson(true, false, new GeographyValidator(true)); + private static final GeoJson PARSER = new GeoJson(true, false, new GeographyValidator(true)); GeometryWrapper(Geometry geometry) { this.geometry = geometry;