Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@

import org.elasticsearch.action.ShardOperationFailedException;
import org.elasticsearch.action.support.broadcast.BroadcastResponse;
import org.elasticsearch.common.Strings;
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.ToXContentFragment;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.indices.recovery.RecoveryState;

Expand All @@ -36,7 +37,7 @@
/**
* Information regarding the recovery state of indices and their associated shards.
*/
public class RecoveryResponse extends BroadcastResponse implements ToXContent {
public class RecoveryResponse extends BroadcastResponse implements ToXContentFragment {

private boolean detailed = false;
private Map<String, List<RecoveryState>> shardRecoveryStates = new HashMap<>();
Expand Down Expand Up @@ -126,4 +127,9 @@ public void readFrom(StreamInput in) throws IOException {
shardRecoveryStates.put(s, list);
}
}

@Override
public String toString() {
return Strings.toString(this, true, true);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
package org.elasticsearch.action.ingest;

import org.elasticsearch.common.io.stream.Writeable;
import org.elasticsearch.common.xcontent.ToXContent;
import org.elasticsearch.common.xcontent.ToXContentObject;

public interface SimulateDocumentResult extends Writeable, ToXContent {
public interface SimulateDocumentResult extends Writeable, ToXContentObject {

}
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,7 @@ public String getDescription() {
sb.append("], ");
sb.append("search_type[").append(searchType).append("], ");
if (source != null) {

sb.append("source[").append(source.toString(FORMAT_PARAMS)).append("]");
} else {
sb.append("source[]");
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
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.ToXContentFragment;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentHelper;
Expand Down Expand Up @@ -91,7 +90,7 @@ public class ClusterState implements ToXContentFragment, Diffable<ClusterState>

public static final ClusterState EMPTY_STATE = builder(ClusterName.CLUSTER_NAME_SETTING.getDefault(Settings.EMPTY)).build();

public interface Custom extends NamedDiffable<Custom>, ToXContent {
public interface Custom extends NamedDiffable<Custom>, ToXContentFragment {

/**
* Returns <code>true</code> iff this {@link Custom} is private to the cluster and should never be send to a client.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public enum XContentContext {
*/
public static EnumSet<XContentContext> ALL_CONTEXTS = EnumSet.allOf(XContentContext.class);

public interface Custom extends NamedDiffable<Custom>, ToXContent {
public interface Custom extends NamedDiffable<Custom>, ToXContentFragment {

EnumSet<XContentContext> context();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import org.elasticsearch.cluster.routing.allocation.RoutingAllocation;
import org.elasticsearch.common.io.stream.NamedWriteable;
import org.elasticsearch.common.network.NetworkModule;
import org.elasticsearch.common.xcontent.ToXContent;
import org.elasticsearch.common.xcontent.ToXContentObject;
import org.elasticsearch.common.xcontent.XContentParser;

import java.io.IOException;
Expand All @@ -34,7 +34,7 @@
*
* Commands are registered in {@link NetworkModule}.
*/
public interface AllocationCommand extends NamedWriteable, ToXContent {
public interface AllocationCommand extends NamedWriteable, ToXContentObject {
interface Parser<T extends AllocationCommand> {
/**
* Reads an {@link AllocationCommand} of type <code>T</code> from a {@link XContentParser}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@
package org.elasticsearch.cluster.routing.allocation.command;

import org.elasticsearch.ElasticsearchParseException;
import org.elasticsearch.action.support.ToXContentToBytes;
import org.elasticsearch.cluster.routing.allocation.RoutingAllocation;
import org.elasticsearch.cluster.routing.allocation.RoutingExplanations;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.xcontent.ToXContentFragment;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentParser;

Expand All @@ -38,7 +39,7 @@
* A simple {@link AllocationCommand} composite managing several
* {@link AllocationCommand} implementations
*/
public class AllocationCommands extends ToXContentToBytes {
public class AllocationCommands implements ToXContentFragment {
private final List<AllocationCommand> commands = new ArrayList<>();

/**
Expand Down Expand Up @@ -196,4 +197,9 @@ public int hashCode() {
// Override equals and hashCode for testing
return Objects.hashCode(commands);
}

@Override
public String toString() {
return Strings.toString(this, true, true);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import org.apache.logging.log4j.Logger;
import org.elasticsearch.Assertions;
import org.elasticsearch.ElasticsearchParseException;
import org.elasticsearch.action.support.ToXContentToBytes;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.io.stream.NamedWriteable;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
Expand All @@ -52,7 +52,7 @@
/**
* Basic class for building GeoJSON shapes like Polygons, Linestrings, etc
*/
public abstract class ShapeBuilder extends ToXContentToBytes implements NamedWriteable {
public abstract class ShapeBuilder implements NamedWriteable, ToXContentObject {

protected static final Logger LOGGER = ESLoggerFactory.getLogger(ShapeBuilder.class.getName());

Expand Down Expand Up @@ -708,4 +708,9 @@ protected static GeometryCollectionBuilder parseGeometries(XContentParser parser
public String getWriteableName() {
return type().shapeName();
}

@Override
public String toString() {
return Strings.toString(this, true, true);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import org.apache.logging.log4j.Logger;
import org.elasticsearch.ElasticsearchException;
import org.elasticsearch.ElasticsearchParseException;
import org.elasticsearch.action.support.ToXContentToBytes;
import org.elasticsearch.common.Booleans;
import org.elasticsearch.common.Nullable;
import org.elasticsearch.common.Strings;
Expand All @@ -31,6 +30,7 @@
import org.elasticsearch.common.unit.MemorySizeValue;
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.common.xcontent.NamedXContentRegistry;
import org.elasticsearch.common.xcontent.ToXContentObject;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.common.xcontent.XContentParser;
Expand Down Expand Up @@ -78,7 +78,7 @@
* }
* </pre>
*/
public class Setting<T> extends ToXContentToBytes {
public class Setting<T> implements ToXContentObject {

public enum Property {
/**
Expand Down Expand Up @@ -425,6 +425,11 @@ public final XContentBuilder toXContent(XContentBuilder builder, Params params)
return builder;
}

@Override
public String toString() {
return Strings.toString(this, true, true);
}

/**
* Returns the value for this setting but falls back to the second provided settings object
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,14 @@
package org.elasticsearch.index.query;

import org.elasticsearch.Version;
import org.elasticsearch.action.support.ToXContentToBytes;
import org.elasticsearch.common.ParseField;
import org.elasticsearch.common.ParsingException;
import org.elasticsearch.common.Strings;
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.ObjectParser;
import org.elasticsearch.common.xcontent.ToXContentObject;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.script.Script;
Expand All @@ -47,7 +48,7 @@

import static org.elasticsearch.common.xcontent.XContentParser.Token.END_OBJECT;

public final class InnerHitBuilder extends ToXContentToBytes implements Writeable {
public final class InnerHitBuilder implements Writeable, ToXContentObject {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we add toString impl to this class now that it doesn't inherit anymore from ToXContentToBytes?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this applies to all the classes that don't extend from ToXCOntentToBytes anymore and don't declare their own toString .


public static final ParseField NAME_FIELD = new ParseField("name");
public static final ParseField IGNORE_UNMAPPED = new ParseField("ignore_unmapped");
Expand Down Expand Up @@ -544,4 +545,9 @@ public int hashCode() {
public static InnerHitBuilder fromXContent(XContentParser parser) throws IOException {
return PARSER.parse(parser, new InnerHitBuilder(), null);
}

@Override
public String toString() {
return Strings.toString(this, true, true);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@

package org.elasticsearch.index.search.stats;

import org.elasticsearch.action.support.ToXContentToBytes;
import org.elasticsearch.common.Nullable;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.io.stream.Streamable;
Expand All @@ -33,7 +33,7 @@
import java.util.HashMap;
import java.util.Map;

public class SearchStats extends ToXContentToBytes implements Streamable {
public class SearchStats implements Streamable, ToXContentFragment {

public static class Stats implements Streamable, ToXContentFragment {

Expand Down Expand Up @@ -317,6 +317,11 @@ public XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params par
return builder;
}

@Override
public String toString() {
return Strings.toString(this, true, true);
}

static final class Fields {
static final String SEARCH = "search";
static final String OPEN_CONTEXTS = "open_contexts";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,16 @@
package org.elasticsearch.index.translog;

import org.elasticsearch.Version;
import org.elasticsearch.action.support.ToXContentToBytes;
import org.elasticsearch.common.Strings;
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.ToXContentFragment;
import org.elasticsearch.common.xcontent.XContentBuilder;

import java.io.IOException;

public class TranslogStats extends ToXContentToBytes implements Streamable {
public class TranslogStats implements Streamable, ToXContentFragment {

private long translogSizeInBytes;
private int numberOfOperations;
Expand Down Expand Up @@ -96,6 +97,11 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
return builder;
}

@Override
public String toString() {
return Strings.toString(this, true, true);
}

@Override
public void readFrom(StreamInput in) throws IOException {
numberOfOperations = in.readVInt();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,14 @@

import org.elasticsearch.common.ParseField;
import org.elasticsearch.common.xcontent.ToXContent;
import org.elasticsearch.common.xcontent.ToXContentFragment;

import java.util.Map;

/**
* An aggregation. Extends {@link ToXContent} as it makes it easier to print out its content.
*/
public interface Aggregation extends ToXContent {
public interface Aggregation extends ToXContentFragment {

/**
* Delimiter used when prefixing aggregation names with their type
Expand Down
Loading