Moves more classes over to ToXContentObject/Fragment (elastic/x-pack-elasticsearch#2283)

Original commit: elastic/x-pack-elasticsearch@73c6802523
This commit is contained in:
Colin Goodheart-Smithe 2017-08-17 11:16:56 +01:00 committed by GitHub
parent 6d30806996
commit 751680e7b2
27 changed files with 54 additions and 53 deletions

View File

@ -8,17 +8,17 @@ package org.elasticsearch.license;
import org.elasticsearch.action.support.master.AcknowledgedResponse;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.xcontent.ToXContent;
import org.elasticsearch.common.xcontent.ToXContent.Params;
import org.elasticsearch.common.xcontent.ToXContentFragment;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.license.LicensesStatus;
import java.io.IOException;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
public class PutLicenseResponse extends AcknowledgedResponse implements ToXContent {
public class PutLicenseResponse extends AcknowledgedResponse implements ToXContentFragment {
private LicensesStatus status;
private Map<String, String[]> acknowledgeMessages;

View File

@ -7,7 +7,8 @@ package org.elasticsearch.xpack.graph.action;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.xcontent.ToXContent;
import org.elasticsearch.common.xcontent.ToXContent.Params;
import org.elasticsearch.common.xcontent.ToXContentFragment;
import org.elasticsearch.common.xcontent.XContentBuilder;
import java.io.IOException;
@ -19,7 +20,7 @@ import java.io.IOException;
* A vertex term could be a bank account number, an email address, a hashtag or any
* other term that appears in documents and is interesting to represent in a network.
*/
public class Vertex implements ToXContent {
public class Vertex implements ToXContentFragment {
final String field;
final String term;
double weight;

View File

@ -28,7 +28,8 @@ import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.ToXContent;
import org.elasticsearch.common.xcontent.ToXContent.Params;
import org.elasticsearch.common.xcontent.ToXContentFragment;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.transport.TransportService;
@ -62,7 +63,7 @@ public class DeleteDatafeedAction extends Action<DeleteDatafeedAction.Request, D
return new Response();
}
public static class Request extends AcknowledgedRequest<Request> implements ToXContent {
public static class Request extends AcknowledgedRequest<Request> implements ToXContentFragment {
public static final ParseField FORCE = new ParseField("force");

View File

@ -22,7 +22,6 @@ import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.io.stream.Writeable;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.ObjectParser;
import org.elasticsearch.common.xcontent.ToXContent;
import org.elasticsearch.common.xcontent.ToXContentObject;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentParser;
@ -57,7 +56,7 @@ public class FlushJobAction extends Action<FlushJobAction.Request, FlushJobActio
return new Response();
}
public static class Request extends TransportJobTaskAction.JobTaskRequest<Request> implements ToXContent {
public static class Request extends TransportJobTaskAction.JobTaskRequest<Request> implements ToXContentObject {
public static final ParseField CALC_INTERIM = new ParseField("calc_interim");
public static final ParseField START = new ParseField("start");

View File

@ -28,7 +28,8 @@ import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.io.stream.Writeable;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.ObjectParser;
import org.elasticsearch.common.xcontent.ToXContent;
import org.elasticsearch.common.xcontent.ToXContent.Params;
import org.elasticsearch.common.xcontent.ToXContentObject;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.tasks.Task;
@ -73,7 +74,7 @@ public class IsolateDatafeedAction
return new Response();
}
public static class Request extends BaseTasksRequest<Request> implements ToXContent {
public static class Request extends BaseTasksRequest<Request> implements ToXContentObject {
public static ObjectParser<Request, Void> PARSER = new ObjectParser<>(NAME, Request::new);

View File

@ -24,7 +24,6 @@ import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.ToXContent;
import org.elasticsearch.common.xcontent.ToXContentObject;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentType;
@ -67,7 +66,7 @@ public class PreviewDatafeedAction extends Action<PreviewDatafeedAction.Request,
return new Response();
}
public static class Request extends ActionRequest implements ToXContent {
public static class Request extends ActionRequest implements ToXContentObject {
private String datafeedId;

View File

@ -24,7 +24,8 @@ import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.ToXContent;
import org.elasticsearch.common.xcontent.ToXContent.Params;
import org.elasticsearch.common.xcontent.ToXContentObject;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.threadpool.ThreadPool;
@ -53,7 +54,7 @@ public class UpdateJobAction extends Action<UpdateJobAction.Request, PutJobActio
return new PutJobAction.Response();
}
public static class Request extends AcknowledgedRequest<UpdateJobAction.Request> implements ToXContent {
public static class Request extends AcknowledgedRequest<UpdateJobAction.Request> implements ToXContentObject {
public static UpdateJobAction.Request parseRequest(String jobId, XContentParser parser) {
JobUpdate update = JobUpdate.PARSER.apply(parser, null).setJobId(jobId).build();

View File

@ -5,12 +5,12 @@
*/
package org.elasticsearch.xpack.ml.job.process.normalizer;
import org.elasticsearch.common.xcontent.ToXContent;
import org.elasticsearch.common.xcontent.ToXContentObject;
import java.util.List;
import java.util.Objects;
public abstract class Normalizable implements ToXContent {
public abstract class Normalizable implements ToXContentObject {
public enum ChildType {BUCKET_INFLUENCER, RECORD, PARTITION_SCORE};
private final String indexName;

View File

@ -12,7 +12,8 @@ import org.elasticsearch.common.inject.internal.Nullable;
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.ToXContent;
import org.elasticsearch.common.xcontent.ToXContent.Params;
import org.elasticsearch.common.xcontent.ToXContentObject;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentType;
@ -136,7 +137,7 @@ public class MonitoringDoc {
* {@link Node} represents the node of the cluster from which the monitoring document
* has been collected.
*/
public static class Node implements Writeable,ToXContent {
public static class Node implements Writeable, ToXContentObject {
private String uuid;
private String host;

View File

@ -135,7 +135,7 @@ public class HipChatMessage implements ToXContentObject {
return builder.endObject();
}
public static class Template implements ToXContent {
public static class Template implements ToXContentObject {
final TextTemplate body;
@Nullable final TextTemplate[] rooms;

View File

@ -6,10 +6,8 @@
package org.elasticsearch.xpack.notification.hipchat;
import org.elasticsearch.ElasticsearchException;
import org.elasticsearch.ExceptionsHelper;
import org.elasticsearch.common.Nullable;
import org.elasticsearch.common.ParseField;
import org.elasticsearch.common.xcontent.ToXContent;
import org.elasticsearch.common.xcontent.ToXContentObject;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.xpack.common.http.HttpRequest;
@ -63,7 +61,7 @@ public class SentMessages implements ToXContentObject, Iterable<SentMessages.Sen
return builder.endObject();
}
public static class SentMessage implements ToXContent {
public static class SentMessage implements ToXContentObject {
private static final ParseField STATUS = new ParseField("status");
private static final ParseField REQUEST = new ParseField("request");

View File

@ -170,7 +170,7 @@ public class IncidentEvent implements ToXContentObject {
return new Template.Builder(description);
}
public static class Template implements ToXContent {
public static class Template implements ToXContentObject {
final TextTemplate description;
final TextTemplate incidentKey;

View File

@ -9,7 +9,6 @@ import org.elasticsearch.ElasticsearchParseException;
import org.elasticsearch.common.Nullable;
import org.elasticsearch.common.ParseField;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.xcontent.ToXContent;
import org.elasticsearch.common.xcontent.ToXContentObject;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentParser;
@ -93,7 +92,7 @@ public class IncidentEventContext implements ToXContentObject {
return builder.endObject();
}
public static class Template implements ToXContent {
public static class Template implements ToXContentObject {
final Type type;
final TextTemplate href;

View File

@ -6,10 +6,8 @@
package org.elasticsearch.xpack.notification.slack;
import org.elasticsearch.ElasticsearchException;
import org.elasticsearch.ExceptionsHelper;
import org.elasticsearch.common.Nullable;
import org.elasticsearch.common.ParseField;
import org.elasticsearch.common.xcontent.ToXContent;
import org.elasticsearch.common.xcontent.ToXContentObject;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.xpack.common.http.HttpRequest;
@ -63,7 +61,7 @@ public class SentMessages implements ToXContentObject, Iterable<SentMessages.Sen
return builder.endObject();
}
public static class SentMessage implements ToXContent {
public static class SentMessage implements ToXContentObject {
private static final ParseField STATUS = new ParseField("status");
private static final ParseField REQUEST = new ParseField("request");

View File

@ -7,7 +7,7 @@ package org.elasticsearch.xpack.notification.slack.message;
import org.elasticsearch.ElasticsearchParseException;
import org.elasticsearch.common.ParseField;
import org.elasticsearch.common.xcontent.ToXContent;
import org.elasticsearch.common.xcontent.ToXContentObject;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.xpack.common.text.TextTemplate;
@ -55,7 +55,7 @@ class Field implements MessageElement {
.endObject();
}
static class Template implements ToXContent {
static class Template implements ToXContentObject {
final TextTemplate title;
final TextTemplate value;

View File

@ -7,7 +7,7 @@ package org.elasticsearch.xpack.notification.slack.message;
import org.elasticsearch.ElasticsearchParseException;
import org.elasticsearch.common.ParseField;
import org.elasticsearch.common.xcontent.ToXContent;
import org.elasticsearch.common.xcontent.ToXContentObject;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.xpack.common.text.TextTemplate;
@ -112,7 +112,7 @@ public class SlackMessage implements MessageElement {
return builder.endObject();
}
public static class Template implements ToXContent {
public static class Template implements ToXContentObject {
final TextTemplate from;
final TextTemplate[] to;

View File

@ -23,6 +23,7 @@ import org.elasticsearch.common.xcontent.ConstructingObjectParser;
import org.elasticsearch.common.xcontent.ObjectParser;
import org.elasticsearch.common.xcontent.ObjectParser.NamedObjectParser;
import org.elasticsearch.common.xcontent.ToXContent;
import org.elasticsearch.common.xcontent.ToXContentObject;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.tasks.Task;
@ -253,7 +254,7 @@ public final class PersistentTasksCustomMetaData extends AbstractNamedDiffable<M
/**
* A record that represents a single running persistent task
*/
public static class PersistentTask<P extends PersistentTaskParams> implements Writeable, ToXContent {
public static class PersistentTask<P extends PersistentTaskParams> implements Writeable, ToXContentObject {
private final String id;
private final long allocationId;
private final String taskName;

View File

@ -8,7 +8,8 @@ package org.elasticsearch.xpack.security.action.role;
import org.elasticsearch.action.ActionResponse;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.xcontent.ToXContent;
import org.elasticsearch.common.xcontent.ToXContent.Params;
import org.elasticsearch.common.xcontent.ToXContentObject;
import org.elasticsearch.common.xcontent.XContentBuilder;
import java.io.IOException;
@ -17,7 +18,7 @@ import java.io.IOException;
* Response when adding a role, includes a boolean for whether the role was
* created or updated.
*/
public class PutRoleResponse extends ActionResponse implements ToXContent {
public class PutRoleResponse extends ActionResponse implements ToXContentObject {
private boolean created;

View File

@ -5,20 +5,21 @@
*/
package org.elasticsearch.xpack.security.action.rolemapping;
import java.io.IOException;
import org.elasticsearch.action.ActionResponse;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.xcontent.ToXContent;
import org.elasticsearch.common.xcontent.ToXContent.Params;
import org.elasticsearch.common.xcontent.ToXContentObject;
import org.elasticsearch.common.xcontent.XContentBuilder;
import java.io.IOException;
/**
* Response when adding/updating a role-mapping.
*
* @see org.elasticsearch.xpack.security.authc.support.mapper.NativeRoleMappingStore
*/
public class PutRoleMappingResponse extends ActionResponse implements ToXContent {
public class PutRoleMappingResponse extends ActionResponse implements ToXContentObject {
private boolean created;

View File

@ -9,6 +9,7 @@ import org.elasticsearch.ElasticsearchException;
import org.elasticsearch.common.ParseField;
import org.elasticsearch.common.logging.LoggerMessageFormat;
import org.elasticsearch.common.xcontent.ToXContent;
import org.elasticsearch.common.xcontent.ToXContentFragment;
import org.elasticsearch.common.xcontent.ToXContentObject;
import org.elasticsearch.common.xcontent.XContentBuilder;
@ -19,7 +20,7 @@ public interface Action extends ToXContentObject {
String type();
abstract class Result implements ToXContent {
abstract class Result implements ToXContentFragment {
public enum Status implements ToXContent {
SUCCESS,

View File

@ -10,7 +10,6 @@ import org.elasticsearch.common.Nullable;
import org.elasticsearch.common.ParseField;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.xcontent.ToXContent;
import org.elasticsearch.common.xcontent.ToXContentObject;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentParser;
@ -408,7 +407,7 @@ public class ActionStatus implements ToXContentObject {
}
}
public static class Throttle implements ToXContent {
public static class Throttle implements ToXContentObject {
private final DateTime timestamp;
private final String reason;

View File

@ -11,7 +11,6 @@ import org.elasticsearch.ElasticsearchParseException;
import org.elasticsearch.common.Nullable;
import org.elasticsearch.common.ParseField;
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.common.xcontent.ToXContent;
import org.elasticsearch.common.xcontent.ToXContentObject;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentParser;
@ -238,7 +237,7 @@ public class ActionWrapper implements ToXContentObject {
return new ActionWrapper(actionId, throttler, condition, transform, action);
}
public static class Result implements ToXContent {
public static class Result implements ToXContentObject {
private final String id;
@Nullable

View File

@ -29,7 +29,7 @@ import java.util.Map;
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
public class WatchSourceBuilder extends ToXContentToBytes implements ToXContent {
public class WatchSourceBuilder extends ToXContentToBytes implements ToXContentObject {
private Trigger trigger;
private Input input = NoneInput.INSTANCE;

View File

@ -40,7 +40,7 @@ public abstract class Condition implements ToXContentObject {
return builder.startObject().endObject();
}
public static class Result implements ToXContent { // don't make this final - we can't mock final classes :(
public static class Result implements ToXContentObject { // don't make this final - we can't mock final classes :(
public Map<String,Object> getResolvedValues() {
return resolveValues;

View File

@ -8,14 +8,15 @@ package org.elasticsearch.xpack.watcher.execution;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.io.stream.Streamable;
import org.elasticsearch.common.xcontent.ToXContent;
import org.elasticsearch.common.xcontent.ToXContent.Params;
import org.elasticsearch.common.xcontent.ToXContentObject;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
import java.io.IOException;
public class QueuedWatch implements Streamable, ToXContent {
public class QueuedWatch implements Streamable, ToXContentObject {
private String watchId;
private String watchRecordId;

View File

@ -11,7 +11,8 @@ import org.elasticsearch.common.bytes.BytesReference;
import org.elasticsearch.common.component.AbstractComponent;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.NamedXContentRegistry;
import org.elasticsearch.common.xcontent.ToXContent;
import org.elasticsearch.common.xcontent.ToXContent.Params;
import org.elasticsearch.common.xcontent.ToXContentObject;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentHelper;
import org.elasticsearch.common.xcontent.XContentParser;
@ -20,7 +21,7 @@ import org.elasticsearch.xpack.watcher.trigger.TriggerService;
import java.io.IOException;
public class TriggeredWatch implements ToXContent {
public class TriggeredWatch implements ToXContentObject {
private final Wid id;
private final TriggerEvent triggerEvent;

View File

@ -11,7 +11,6 @@ import org.elasticsearch.common.ParseField;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.io.stream.Streamable;
import org.elasticsearch.common.xcontent.ToXContent;
import org.elasticsearch.common.xcontent.ToXContentObject;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentParser;
@ -300,7 +299,7 @@ public class WatchStatus implements ToXContentObject, Streamable {
return new WatchStatus(version, state, lastChecked, lastMetCondition, actions);
}
public static class State implements ToXContent {
public static class State implements ToXContentObject {
final boolean active;
final DateTime timestamp;