Remove FromXContentBuilder from RatedDocumentKey

This commit is contained in:
Isabel Drost-Fromm 2016-09-07 12:52:30 +02:00
parent 9d8bb720dc
commit ba9956a468
2 changed files with 2 additions and 15 deletions

View File

@ -21,20 +21,18 @@ package org.elasticsearch.index.rankeval;
import org.elasticsearch.action.support.ToXContentToBytes;
import org.elasticsearch.common.ParseField;
import org.elasticsearch.common.ParseFieldMatcher;
import org.elasticsearch.common.ParseFieldMatcherSupplier;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.io.stream.Writeable;
import org.elasticsearch.common.xcontent.ConstructingObjectParser;
import org.elasticsearch.common.xcontent.FromXContentBuilder;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentParser;
import java.io.IOException;
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 TYPE_FIELD = new ParseField("type");
public static final ParseField INDEX_FIELD = new ParseField("index");
@ -107,17 +105,6 @@ public class RatedDocumentKey extends ToXContentToBytes implements Writeable, Fr
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(
XContentParser parser, ParseFieldMatcherSupplier context) throws IOException {
return PARSER.apply(parser, context);

View File

@ -34,7 +34,7 @@ public class RatedDocumentKeyTests extends ESTestCase {
RatedDocumentKey testItem = new RatedDocumentKey(index, type, docId);
XContentParser itemParser = XContentTestHelper.roundtrip(testItem);
RatedDocumentKey parsedItem = testItem.fromXContent(itemParser, ParseFieldMatcher.STRICT);
RatedDocumentKey parsedItem = RatedDocumentKey.fromXContent(itemParser, () -> ParseFieldMatcher.STRICT);
assertNotSame(testItem, parsedItem);
assertEquals(testItem, parsedItem);
assertEquals(testItem.hashCode(), parsedItem.hashCode());