Remove FromXContentBuilder from RatedDocumentKey
This commit is contained in:
parent
9d8bb720dc
commit
ba9956a468
|
@ -21,20 +21,18 @@ package org.elasticsearch.index.rankeval;
|
||||||
|
|
||||||
import org.elasticsearch.action.support.ToXContentToBytes;
|
import org.elasticsearch.action.support.ToXContentToBytes;
|
||||||
import org.elasticsearch.common.ParseField;
|
import org.elasticsearch.common.ParseField;
|
||||||
import org.elasticsearch.common.ParseFieldMatcher;
|
|
||||||
import org.elasticsearch.common.ParseFieldMatcherSupplier;
|
import org.elasticsearch.common.ParseFieldMatcherSupplier;
|
||||||
import org.elasticsearch.common.io.stream.StreamInput;
|
import org.elasticsearch.common.io.stream.StreamInput;
|
||||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||||
import org.elasticsearch.common.io.stream.Writeable;
|
import org.elasticsearch.common.io.stream.Writeable;
|
||||||
import org.elasticsearch.common.xcontent.ConstructingObjectParser;
|
import org.elasticsearch.common.xcontent.ConstructingObjectParser;
|
||||||
import org.elasticsearch.common.xcontent.FromXContentBuilder;
|
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
import org.elasticsearch.common.xcontent.XContentParser;
|
import org.elasticsearch.common.xcontent.XContentParser;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
public class RatedDocumentKey extends ToXContentToBytes implements Writeable, FromXContentBuilder<RatedDocumentKey> {
|
public class RatedDocumentKey extends ToXContentToBytes implements Writeable {
|
||||||
public static final ParseField DOC_ID_FIELD = new ParseField("doc_id");
|
public static final ParseField DOC_ID_FIELD = new ParseField("doc_id");
|
||||||
public static final ParseField TYPE_FIELD = new ParseField("type");
|
public static final ParseField TYPE_FIELD = new ParseField("type");
|
||||||
public static final ParseField INDEX_FIELD = new ParseField("index");
|
public static final ParseField INDEX_FIELD = new ParseField("index");
|
||||||
|
@ -107,17 +105,6 @@ public class RatedDocumentKey extends ToXContentToBytes implements Writeable, Fr
|
||||||
out.writeString(docId);
|
out.writeString(docId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public RatedDocumentKey fromXContent(XContentParser parser, ParseFieldMatcher matcher) throws IOException {
|
|
||||||
return RatedDocumentKey.fromXContent(parser, new ParseFieldMatcherSupplier() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ParseFieldMatcher getParseFieldMatcher() {
|
|
||||||
return matcher;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public static RatedDocumentKey fromXContent(
|
public static RatedDocumentKey fromXContent(
|
||||||
XContentParser parser, ParseFieldMatcherSupplier context) throws IOException {
|
XContentParser parser, ParseFieldMatcherSupplier context) throws IOException {
|
||||||
return PARSER.apply(parser, context);
|
return PARSER.apply(parser, context);
|
||||||
|
|
|
@ -34,7 +34,7 @@ public class RatedDocumentKeyTests extends ESTestCase {
|
||||||
|
|
||||||
RatedDocumentKey testItem = new RatedDocumentKey(index, type, docId);
|
RatedDocumentKey testItem = new RatedDocumentKey(index, type, docId);
|
||||||
XContentParser itemParser = XContentTestHelper.roundtrip(testItem);
|
XContentParser itemParser = XContentTestHelper.roundtrip(testItem);
|
||||||
RatedDocumentKey parsedItem = testItem.fromXContent(itemParser, ParseFieldMatcher.STRICT);
|
RatedDocumentKey parsedItem = RatedDocumentKey.fromXContent(itemParser, () -> ParseFieldMatcher.STRICT);
|
||||||
assertNotSame(testItem, parsedItem);
|
assertNotSame(testItem, parsedItem);
|
||||||
assertEquals(testItem, parsedItem);
|
assertEquals(testItem, parsedItem);
|
||||||
assertEquals(testItem.hashCode(), parsedItem.hashCode());
|
assertEquals(testItem.hashCode(), parsedItem.hashCode());
|
||||||
|
|
Loading…
Reference in New Issue