avoid null values in simulate serialization prototypes, use empty maps instead

This commit is contained in:
javanna 2015-12-09 10:54:30 +01:00 committed by Luca Cavanna
parent 6b7446beb9
commit 744d2908a8
3 changed files with 6 additions and 16 deletions

View File

@ -25,18 +25,15 @@ import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.ingest.IngestDocument;
import java.io.IOException;
import java.util.Collections;
public class SimulateDocumentSimpleResult implements SimulateDocumentResult<SimulateDocumentSimpleResult> {
private static final SimulateDocumentSimpleResult PROTOTYPE = new SimulateDocumentSimpleResult();
private static final SimulateDocumentSimpleResult PROTOTYPE = new SimulateDocumentSimpleResult(new WriteableIngestDocument(new IngestDocument(Collections.emptyMap(), Collections.emptyMap(), Collections.emptyMap())));
private WriteableIngestDocument ingestDocument;
private Exception failure;
private SimulateDocumentSimpleResult() {
this.ingestDocument = null;
}
public SimulateDocumentSimpleResult(IngestDocument ingestDocument) {
this.ingestDocument = new WriteableIngestDocument(ingestDocument);
}

View File

@ -28,20 +28,16 @@ import org.elasticsearch.common.xcontent.XContentBuilderString;
import org.elasticsearch.ingest.IngestDocument;
import java.io.IOException;
import java.util.Collections;
public class SimulateProcessorResult implements Writeable<SimulateProcessorResult>, ToXContent {
private static final SimulateProcessorResult PROTOTYPE = new SimulateProcessorResult();
private static final SimulateProcessorResult PROTOTYPE = new SimulateProcessorResult("_na", new WriteableIngestDocument(new IngestDocument(Collections.emptyMap(), Collections.emptyMap(), Collections.emptyMap())));
private String processorId;
private WriteableIngestDocument ingestDocument;
private Exception failure;
private SimulateProcessorResult() {
this.processorId = null;
this.ingestDocument = null;
}
public SimulateProcessorResult(String processorId, IngestDocument ingestDocument) {
this.processorId = processorId;
this.ingestDocument = new WriteableIngestDocument(ingestDocument);

View File

@ -28,19 +28,16 @@ import org.elasticsearch.common.xcontent.XContentBuilderString;
import org.elasticsearch.ingest.IngestDocument;
import java.io.IOException;
import java.util.Collections;
import java.util.Map;
import java.util.Objects;
final class WriteableIngestDocument implements Writeable<WriteableIngestDocument>, ToXContent {
private static final WriteableIngestDocument PROTOTYPE = new WriteableIngestDocument();
private static final WriteableIngestDocument PROTOTYPE = new WriteableIngestDocument(new IngestDocument(Collections.emptyMap(), Collections.emptyMap(), Collections.emptyMap()));
private final IngestDocument ingestDocument;
private WriteableIngestDocument() {
this.ingestDocument = null;
}
WriteableIngestDocument(IngestDocument ingestDocument) {
assert ingestDocument != null;
this.ingestDocument = ingestDocument;