Replace writeOptionalQuery with writeOptionalNamedWriteable

This commit is contained in:
Nik Everett 2016-04-18 14:36:24 -04:00
parent 8cffe0fc28
commit 70d55b36e1
5 changed files with 16 additions and 16 deletions

View File

@ -730,7 +730,7 @@ public abstract class StreamInput extends InputStream {
} }
/** /**
* Reads an optional {@link QueryBuilder}. * Reads an optional {@link NamedWriteable}.
*/ */
public <C extends NamedWriteable<?>> C readOptionalNamedWriteable(Class<C> categoryClass) throws IOException { public <C extends NamedWriteable<?>> C readOptionalNamedWriteable(Class<C> categoryClass) throws IOException {
if (readBoolean()) { if (readBoolean()) {

View File

@ -692,6 +692,18 @@ public abstract class StreamOutput extends OutputStream {
namedWriteable.writeTo(this); namedWriteable.writeTo(this);
} }
/**
* Write an optional {@link QueryBuilder} to the stream.
*/
public void writeOptionalNamedWriteable(@Nullable NamedWriteable<?> namedWriteable) throws IOException {
if (namedWriteable == null) {
writeBoolean(false);
} else {
writeBoolean(true);
writeNamedWriteable(namedWriteable);
}
}
/** /**
* Writes a {@link AggregatorBuilder} to the current stream * Writes a {@link AggregatorBuilder} to the current stream
*/ */
@ -713,18 +725,6 @@ public abstract class StreamOutput extends OutputStream {
writeNamedWriteable(queryBuilder); writeNamedWriteable(queryBuilder);
} }
/**
* Write an optional {@link QueryBuilder} to the stream.
*/
public void writeOptionalQuery(@Nullable QueryBuilder<?> queryBuilder) throws IOException {
if (queryBuilder == null) {
writeBoolean(false);
} else {
writeBoolean(true);
writeQuery(queryBuilder);
}
}
/** /**
* Writes a {@link ShapeBuilder} to the current stream * Writes a {@link ShapeBuilder} to the current stream
*/ */

View File

@ -112,7 +112,7 @@ public class FieldSortBuilder extends SortBuilder<FieldSortBuilder> {
@Override @Override
public void writeTo(StreamOutput out) throws IOException { public void writeTo(StreamOutput out) throws IOException {
out.writeString(fieldName); out.writeString(fieldName);
out.writeOptionalQuery(nestedFilter); out.writeOptionalNamedWriteable(nestedFilter);
out.writeOptionalString(nestedPath); out.writeOptionalString(nestedPath);
out.writeGenericValue(missing); out.writeGenericValue(missing);
out.writeOptionalWriteable(order); out.writeOptionalWriteable(order);

View File

@ -173,7 +173,7 @@ public class GeoDistanceSortBuilder extends SortBuilder<GeoDistanceSortBuilder>
unit.writeTo(out); unit.writeTo(out);
order.writeTo(out); order.writeTo(out);
out.writeOptionalWriteable(sortMode); out.writeOptionalWriteable(sortMode);
out.writeOptionalQuery(nestedFilter); out.writeOptionalNamedWriteable(nestedFilter);
out.writeOptionalString(nestedPath); out.writeOptionalString(nestedPath);
out.writeBoolean(coerce); out.writeBoolean(coerce);
out.writeBoolean(ignoreMalformed); out.writeBoolean(ignoreMalformed);

View File

@ -128,7 +128,7 @@ public class ScriptSortBuilder extends SortBuilder<ScriptSortBuilder> {
order.writeTo(out); order.writeTo(out);
out.writeOptionalWriteable(sortMode); out.writeOptionalWriteable(sortMode);
out.writeOptionalString(nestedPath); out.writeOptionalString(nestedPath);
out.writeOptionalQuery(nestedFilter); out.writeOptionalNamedWriteable(nestedFilter);
} }
/** /**