mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-17 10:25:15 +00:00
ObjectParser to no longer require ParseFieldMatcherSupplier as its Context
ParseFieldMatcher as well as ParseFieldMatcherSupplier will be soon removed, hence the ObjectParser's context doesn't need to be a ParseFieldMatcherSupplier anymore. That will allow to remove ParseFieldMatcherSupplier's implementations, little by little.
This commit is contained in:
parent
9394792392
commit
1f7960aa52
@ -20,7 +20,6 @@
|
||||
package org.elasticsearch.common.xcontent;
|
||||
|
||||
import org.elasticsearch.common.ParseField;
|
||||
import org.elasticsearch.common.ParseFieldMatcherSupplier;
|
||||
import org.elasticsearch.common.bytes.BytesReference;
|
||||
import org.elasticsearch.common.xcontent.ObjectParser.ValueType;
|
||||
import org.elasticsearch.common.xcontent.json.JsonXContent;
|
||||
@ -34,7 +33,7 @@ import java.util.function.BiFunction;
|
||||
/**
|
||||
* Superclass for {@link ObjectParser} and {@link ConstructingObjectParser}. Defines most of the "declare" methods so they can be shared.
|
||||
*/
|
||||
public abstract class AbstractObjectParser<Value, Context extends ParseFieldMatcherSupplier>
|
||||
public abstract class AbstractObjectParser<Value, Context>
|
||||
implements BiFunction<XContentParser, Context, Value>, ContextParser<Context, Value> {
|
||||
|
||||
/**
|
||||
|
@ -20,7 +20,6 @@
|
||||
package org.elasticsearch.common.xcontent;
|
||||
|
||||
import org.elasticsearch.common.ParseField;
|
||||
import org.elasticsearch.common.ParseFieldMatcherSupplier;
|
||||
import org.elasticsearch.common.ParsingException;
|
||||
import org.elasticsearch.common.xcontent.ObjectParser.ValueType;
|
||||
|
||||
@ -74,7 +73,7 @@ import java.util.function.Function;
|
||||
* Note: if optional constructor arguments aren't specified then the number of allocations is always the worst case.
|
||||
* </p>
|
||||
*/
|
||||
public final class ConstructingObjectParser<Value, Context extends ParseFieldMatcherSupplier> extends AbstractObjectParser<Value, Context> {
|
||||
public final class ConstructingObjectParser<Value, Context> extends AbstractObjectParser<Value, Context> {
|
||||
/**
|
||||
* Consumer that marks a field as a required constructor argument instead of a real object field.
|
||||
*/
|
||||
@ -236,7 +235,7 @@ public final class ConstructingObjectParser<Value, Context extends ParseFieldMat
|
||||
|
||||
/**
|
||||
* The target of the {@linkplain ConstructingObjectParser}. One of these is built every time you call
|
||||
* {@linkplain ConstructingObjectParser#apply(XContentParser, ParseFieldMatcherSupplier)} Note that it is not static so it inherits
|
||||
* {@linkplain ConstructingObjectParser#apply(XContentParser, Object)} Note that it is not static so it inherits
|
||||
* {@linkplain ConstructingObjectParser}'s type parameters.
|
||||
*/
|
||||
private class Target {
|
||||
|
@ -21,7 +21,6 @@ package org.elasticsearch.common.xcontent;
|
||||
import org.elasticsearch.common.Nullable;
|
||||
import org.elasticsearch.common.ParseField;
|
||||
import org.elasticsearch.common.ParseFieldMatcher;
|
||||
import org.elasticsearch.common.ParseFieldMatcherSupplier;
|
||||
import org.elasticsearch.common.ParsingException;
|
||||
|
||||
import java.io.IOException;
|
||||
@ -68,7 +67,7 @@ import static org.elasticsearch.common.xcontent.XContentParser.Token.VALUE_STRIN
|
||||
* It's highly recommended to use the high level declare methods like {@link #declareString(BiConsumer, ParseField)} instead of
|
||||
* {@link #declareField} which can be used to implement exceptional parsing operations not covered by the high level methods.
|
||||
*/
|
||||
public final class ObjectParser<Value, Context extends ParseFieldMatcherSupplier> extends AbstractObjectParser<Value, Context> {
|
||||
public final class ObjectParser<Value, Context> extends AbstractObjectParser<Value, Context> {
|
||||
/**
|
||||
* Adapts an array (or varags) setter into a list setter.
|
||||
*/
|
||||
@ -167,7 +166,7 @@ public final class ObjectParser<Value, Context extends ParseFieldMatcherSupplier
|
||||
assert ignoreUnknownFields : "this should only be possible if configured to ignore known fields";
|
||||
parser.skipChildren(); // noop if parser points to a value, skips children if parser is start object or start array
|
||||
} else {
|
||||
fieldParser.assertSupports(name, token, currentFieldName, context.getParseFieldMatcher());
|
||||
fieldParser.assertSupports(name, token, currentFieldName);
|
||||
parseSub(parser, fieldParser, currentFieldName, value, context);
|
||||
}
|
||||
fieldParser = null;
|
||||
@ -416,7 +415,7 @@ public final class ObjectParser<Value, Context extends ParseFieldMatcherSupplier
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public void assertSupports(String parserName, XContentParser.Token token, String currentFieldName, ParseFieldMatcher matcher) {
|
||||
public void assertSupports(String parserName, XContentParser.Token token, String currentFieldName) {
|
||||
if (parseField.match(currentFieldName) == false) {
|
||||
throw new IllegalStateException("[" + parserName + "] parsefield doesn't accept: " + currentFieldName);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user