Remove ParseFieldMatcher usage from ParseFieldRegistry

This commit is contained in:
javanna 2016-12-31 11:35:38 +01:00 committed by Luca Cavanna
parent 41c7d3e092
commit 8f297ec42c
6 changed files with 10 additions and 17 deletions

View File

@ -130,8 +130,7 @@ public class AllocationCommands extends ToXContentToBytes {
* @return {@link AllocationCommands} read
* @throws IOException if something bad happens while reading the stream
*/
public static AllocationCommands fromXContent(XContentParser parser, ParseFieldMatcher parseFieldMatcher,
AllocationCommandRegistry registry) throws IOException {
public static AllocationCommands fromXContent(XContentParser parser, ParseFieldMatcher parseFieldMatcher, AllocationCommandRegistry registry) throws IOException {
AllocationCommands commands = new AllocationCommands();
XContentParser.Token token = parser.currentToken();
@ -160,7 +159,7 @@ public class AllocationCommands extends ToXContentToBytes {
token = parser.nextToken();
String commandName = parser.currentName();
token = parser.nextToken();
commands.add(registry.lookup(commandName, parseFieldMatcher, parser.getTokenLocation()).fromXContent(parser));
commands.add(registry.lookup(commandName, parser.getTokenLocation()).fromXContent(parser));
// move to the end object one
if (parser.nextToken() != XContentParser.Token.END_OBJECT) {
throw new ElasticsearchParseException("allocation command is malformed, done parsing a command, but didn't get END_OBJECT, got [{}] instead", token);

View File

@ -20,7 +20,6 @@
package org.elasticsearch.common.xcontent;
import org.elasticsearch.common.ParseField;
import org.elasticsearch.common.ParseFieldMatcher;
import org.elasticsearch.common.ParsingException;
import org.elasticsearch.common.collect.Tuple;
@ -75,12 +74,11 @@ public class ParseFieldRegistry<T> {
* Lookup a value from the registry by name while checking that the name matches the ParseField.
*
* @param name The name of the thing to look up.
* @param parseFieldMatcher to build nice error messages.
* @return The value being looked up. Never null.
* @throws ParsingException if the named thing isn't in the registry or the name was deprecated and deprecated names aren't supported.
*/
public T lookup(String name, ParseFieldMatcher parseFieldMatcher, XContentLocation xContentLocation) {
T value = lookupReturningNullIfNotFound(name, parseFieldMatcher);
public T lookup(String name, XContentLocation xContentLocation) {
T value = lookupReturningNullIfNotFound(name);
if (value == null) {
throw new ParsingException(xContentLocation, "no [" + registryName + "] registered for [" + name + "]");
}
@ -91,12 +89,10 @@ public class ParseFieldRegistry<T> {
* Lookup a value from the registry by name while checking that the name matches the ParseField.
*
* @param name The name of the thing to look up.
* @param parseFieldMatcher The parseFieldMatcher. This is used to resolve the {@link ParseFieldMatcher} and to build nice
* error messages.
* @return The value being looked up or null if it wasn't found.
* @throws ParsingException if the named thing isn't in the registry or the name was deprecated and deprecated names aren't supported.
*/
public T lookupReturningNullIfNotFound(String name, ParseFieldMatcher parseFieldMatcher) {
public T lookupReturningNullIfNotFound(String name) {
Tuple<ParseField, T> parseFieldAndValue = registry.get(name);
if (parseFieldAndValue == null) {
return null;

View File

@ -53,7 +53,7 @@ public class AggregatorParsers {
* @return The parser associated with the given aggregation type or null if it wasn't found.
*/
public Aggregator.Parser parser(String type, ParseFieldMatcher parseFieldMatcher) {
return aggregationParserRegistry.lookupReturningNullIfNotFound(type, parseFieldMatcher);
return aggregationParserRegistry.lookupReturningNullIfNotFound(type);
}
/**
@ -64,7 +64,7 @@ public class AggregatorParsers {
* @return The parser associated with the given pipeline aggregator type or null if it wasn't found.
*/
public PipelineAggregator.Parser pipelineParser(String type, ParseFieldMatcher parseFieldMatcher) {
return pipelineAggregationParserRegistry.lookupReturningNullIfNotFound(type, parseFieldMatcher);
return pipelineAggregationParserRegistry.lookupReturningNullIfNotFound(type);
}
/**

View File

@ -91,7 +91,7 @@ public class SignificantTermsAggregationBuilder extends ValuesSourceAggregationB
parser.declareObject(SignificantTermsAggregationBuilder::significanceHeuristic,
(p, context) -> {
SignificanceHeuristicParser significanceHeuristicParser = significanceHeuristicParserRegistry
.lookupReturningNullIfNotFound(name, context.getParseFieldMatcher());
.lookupReturningNullIfNotFound(name);
return significanceHeuristicParser.parse(context);
},
new ParseField(name));

View File

@ -403,8 +403,7 @@ public class MovAvgPipelineAggregationBuilder extends AbstractPipelineAggregatio
factory.predict(predict);
}
if (model != null) {
MovAvgModel.AbstractModelParser modelParser = movingAverageMdelParserRegistry.lookup(model, context.getParseFieldMatcher(),
parser.getTokenLocation());
MovAvgModel.AbstractModelParser modelParser = movingAverageMdelParserRegistry.lookup(model, parser.getTokenLocation());
MovAvgModel movAvgModel;
try {
movAvgModel = modelParser.parse(settings, pipelineAggregatorName, factory.window(), context.getParseFieldMatcher());

View File

@ -1008,8 +1008,7 @@ public final class SearchSourceBuilder extends ToXContentToBytes implements Writ
if (token == XContentParser.Token.FIELD_NAME) {
extSectionName = parser.currentName();
} else {
SearchExtParser searchExtParser = searchExtRegistry.lookup(extSectionName,
context.getParseFieldMatcher(), parser.getTokenLocation());
SearchExtParser searchExtParser = searchExtRegistry.lookup(extSectionName, parser.getTokenLocation());
SearchExtBuilder searchExtBuilder = searchExtParser.fromXContent(parser);
if (searchExtBuilder.getWriteableName().equals(extSectionName) == false) {
throw new IllegalStateException("The parsed [" + searchExtBuilder.getClass().getName() + "] object has a "