Skip to content

Commit

Permalink
Remove noop isFragment overrides in ToXContent implementations (#95105)
Browse files Browse the repository at this point in the history
Just removing some dead code I found while looking into xcontent chunking.
  • Loading branch information
original-brownbear committed Apr 9, 2023
1 parent 16af105 commit aa61557
Show file tree
Hide file tree
Showing 15 changed files with 17 additions and 95 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -270,11 +270,6 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
builder.endObject();
return builder;
}

@Override
public boolean isFragment() {
return true;
}
}

public static ParsedJavadoc clean(Javadoc javadoc) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import org.elasticsearch.snapshots.SnapshotFeatureInfo;
import org.elasticsearch.snapshots.SnapshotId;
import org.elasticsearch.xcontent.ToXContent;
import org.elasticsearch.xcontent.ToXContentObject;
import org.elasticsearch.xcontent.XContentBuilder;

import java.io.IOException;
Expand Down Expand Up @@ -648,7 +649,7 @@ public String toString() {
}
}

public static class Entry implements Writeable, ToXContent, RepositoryOperation, Diffable<Entry> {
public static class Entry implements Writeable, ToXContentObject, RepositoryOperation, Diffable<Entry> {
private final State state;
private final Snapshot snapshot;
private final boolean includeGlobalState;
Expand Down Expand Up @@ -1342,11 +1343,6 @@ public void writeTo(StreamOutput out) throws IOException {
out.writeList(featureStates);
}

@Override
public boolean isFragment() {
return false;
}

@Override
public Diff<Entry> diff(Entry previousState) {
return new EntryDiff(previousState, this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.core.Releasable;
import org.elasticsearch.xcontent.ToXContent;
import org.elasticsearch.xcontent.ToXContentObject;
import org.elasticsearch.xcontent.XContentBuilder;
import org.elasticsearch.xcontent.XContentFactory;
import org.elasticsearch.xcontent.XContentParser;
Expand Down Expand Up @@ -162,17 +163,11 @@ public CompressedXContent(byte[] data) throws IOException {
* @return compressed x-content normalized to not contain any whitespaces
*/
public static CompressedXContent fromJSON(String json) throws IOException {
return new CompressedXContent(new ToXContent() {
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
return builder.copyCurrentStructure(JsonXContent.jsonXContent.createParser(XContentParserConfiguration.EMPTY, json));
}

@Override
public boolean isFragment() {
return false;
}
});
return new CompressedXContent(
(ToXContentObject) (builder, params) -> builder.copyCurrentStructure(
JsonXContent.jsonXContent.createParser(XContentParserConfiguration.EMPTY, json)
)
);
}

public CompressedXContent(String str) throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,11 +251,6 @@ public void writeTo(StreamOutput out) throws IOException {
}
}

@Override
public boolean isFragment() {
return true;
}

@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
builder.field(HIGH_WATERMARK_FIELD.getPreferredName(), describeHighWatermark());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,11 +161,6 @@ public XContentBuilder toXContent(final XContentBuilder builder, final Params pa
return builder;
}

@Override
public boolean isFragment() {
return false;
}

/**
* Parses a retention lease from {@link org.elasticsearch.xcontent.XContent}. This method assumes that the retention lease was
* converted to {@link org.elasticsearch.xcontent.XContent} via {@link #toXContent(XContentBuilder, Params)}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -474,11 +474,6 @@ public XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params xPa
builder.endObject();
return builder;
}

@Override
public boolean isFragment() {
return false;
}
}

private static class TaskBuilder<Params extends PersistentTaskParams> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -365,11 +365,6 @@ public String toString() {
return Strings.toString(this);
}

@Override
public boolean isFragment() {
return false;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
package org.elasticsearch.script.field;

import org.elasticsearch.common.network.InetAddresses;
import org.elasticsearch.xcontent.ToXContent;
import org.elasticsearch.xcontent.ToXContentObject;
import org.elasticsearch.xcontent.XContentBuilder;

import java.io.IOException;
Expand All @@ -20,7 +20,7 @@
/**
* IP address for use in scripting.
*/
public class IPAddress implements ToXContent {
public class IPAddress implements ToXContentObject {
protected final InetAddress address;

IPAddress(InetAddress address) {
Expand Down Expand Up @@ -49,8 +49,4 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
return builder.value(this.toString());
}

@Override
public boolean isFragment() {
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import org.elasticsearch.core.Nullable;
import org.elasticsearch.xcontent.ConstructingObjectParser;
import org.elasticsearch.xcontent.ParseField;
import org.elasticsearch.xcontent.ToXContent;
import org.elasticsearch.xcontent.ToXContentObject;
import org.elasticsearch.xcontent.XContentBuilder;
import org.elasticsearch.xcontent.XContentParser;

Expand All @@ -26,7 +26,7 @@
/**
* Holds the results of migrating a single feature. See also {@link FeatureMigrationResults}.
*/
public class SingleFeatureMigrationResult implements SimpleDiffable<SingleFeatureMigrationResult>, Writeable, ToXContent {
public class SingleFeatureMigrationResult implements SimpleDiffable<SingleFeatureMigrationResult>, Writeable, ToXContentObject {
private static final String NAME = "feature_migration_status";
private static final ParseField SUCCESS_FIELD = new ParseField("successful");
private static final ParseField FAILED_INDEX_NAME_FIELD = new ParseField("failed_index");
Expand Down Expand Up @@ -145,11 +145,6 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
return builder;
}

@Override
public boolean isFragment() {
return false;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,11 +260,6 @@ public static PersistentTaskState fromXContent(XContentParser parser) throws IOE
return STATE_PARSER.parse(parser, null);
}

@Override
public boolean isFragment() {
return false;
}

@Override
public void writeTo(StreamOutput out) throws IOException {
out.writeString(phase);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import org.elasticsearch.common.unit.ByteSizeValue;
import org.elasticsearch.common.unit.Processors;
import org.elasticsearch.core.Nullable;
import org.elasticsearch.xcontent.ToXContent;
import org.elasticsearch.xcontent.ToXContentObject;
import org.elasticsearch.xcontent.XContentBuilder;

import java.io.IOException;
Expand All @@ -24,12 +24,12 @@
/**
* Represents current/required capacity of a single tier.
*/
public class AutoscalingCapacity implements ToXContent, Writeable {
public class AutoscalingCapacity implements ToXContentObject, Writeable {

private final AutoscalingResources total;
private final AutoscalingResources node;

public static class AutoscalingResources implements ToXContent, Writeable {
public static class AutoscalingResources implements ToXContentObject, Writeable {
private final ByteSizeValue storage;
private final ByteSizeValue memory;
private final Processors processors;
Expand Down Expand Up @@ -84,11 +84,6 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
return builder;
}

@Override
public boolean isFragment() {
return false;
}

@Override
public void writeTo(StreamOutput out) throws IOException {
out.writeOptionalWriteable(storage);
Expand Down Expand Up @@ -241,11 +236,6 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
return builder;
}

@Override
public boolean isFragment() {
return false;
}

public static AutoscalingCapacity upperBound(AutoscalingCapacity c1, AutoscalingCapacity c2) {
return new AutoscalingCapacity(AutoscalingResources.max(c1.total, c2.total), AutoscalingResources.max(c1.node, c2.node));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.io.stream.Writeable;
import org.elasticsearch.xcontent.ToXContent;
import org.elasticsearch.xcontent.ToXContentObject;
import org.elasticsearch.xcontent.XContentBuilder;

import java.io.IOException;
Expand All @@ -31,7 +31,7 @@
* Represents a collection of individual autoscaling decider results that can be aggregated into a single autoscaling capacity for a
* policy
*/
public class AutoscalingDeciderResults implements ToXContent, Writeable {
public class AutoscalingDeciderResults implements ToXContentObject, Writeable {

private final AutoscalingCapacity currentCapacity;
private final SortedSet<DiscoveryNode> currentNodes;
Expand Down Expand Up @@ -74,11 +74,6 @@ public void writeTo(final StreamOutput out) throws IOException {
out.writeMap(results, StreamOutput::writeString, (output, result) -> result.writeTo(output));
}

@Override
public boolean isFragment() {
return false;
}

@Override
public XContentBuilder toXContent(final XContentBuilder builder, final Params params) throws IOException {
builder.startObject();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,6 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
return builder;
}

@Override
public boolean isFragment() {
return false;
}

public static DatafeedState fromXContent(XContentParser parser) throws IOException {
return PARSER.parse(parser, null);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,6 @@ public void writeTo(StreamOutput out) throws IOException {
out.writeOptionalString(reason);
}

@Override
public boolean isFragment() {
return false;
}

@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
builder.startObject();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,11 +171,6 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
.endObject();
}

@Override
public boolean isFragment() {
return false;
}

@Override
public boolean equals(Object o) {
if (this == o) {
Expand Down

0 comments on commit aa61557

Please sign in to comment.