mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-09 06:25:07 +00:00
Minor refactoring and indentation fixes
This commit is contained in:
parent
a0d8d656fc
commit
db4c6c96a3
@ -83,7 +83,7 @@ public final class XContentBuilder implements BytesStream, Releasable {
|
|||||||
return new XContentBuilder(xContent, new BytesStreamOutput(), filters);
|
return new XContentBuilder(xContent, new BytesStreamOutput(), filters);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static XContentBuilder builder(XContent xContent, boolean inclusive, String[] filters) throws IOException {
|
public static XContentBuilder builder(XContent xContent, String[] filters, boolean inclusive) throws IOException {
|
||||||
return new XContentBuilder(xContent, new BytesStreamOutput(), inclusive, filters);
|
return new XContentBuilder(xContent, new BytesStreamOutput(), inclusive, filters);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,8 +68,8 @@ public class SmileXContent implements XContent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public XContentGenerator createGenerator(OutputStream os, String[] filters, boolean inclusiveFilters) throws IOException {
|
public XContentGenerator createGenerator(OutputStream os, String[] filters, boolean inclusive) throws IOException {
|
||||||
return new SmileXContentGenerator(smileFactory.createGenerator(os, JsonEncoding.UTF8), os, inclusiveFilters, filters);
|
return new SmileXContentGenerator(smileFactory.createGenerator(os, JsonEncoding.UTF8), os, inclusive, filters);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -92,18 +92,11 @@ public class FilterPathBasedFilter extends TokenFilter {
|
|||||||
@Override
|
@Override
|
||||||
public TokenFilter includeProperty(String name) {
|
public TokenFilter includeProperty(String name) {
|
||||||
TokenFilter filter = evaluate(name, filters);
|
TokenFilter filter = evaluate(name, filters);
|
||||||
if (inclusive) {
|
if (filter == MATCHING) {
|
||||||
if (filter == MATCHING) {
|
return inclusive ? TokenFilter.INCLUDE_ALL : null;
|
||||||
return TokenFilter.INCLUDE_ALL;
|
}
|
||||||
} else if (filter == NO_MATCHING) {
|
if (filter == NO_MATCHING) {
|
||||||
return null;
|
return inclusive ? null : TokenFilter.INCLUDE_ALL;
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (filter == MATCHING) {
|
|
||||||
return null;
|
|
||||||
} else if (filter == NO_MATCHING) {
|
|
||||||
return TokenFilter.INCLUDE_ALL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return filter;
|
return filter;
|
||||||
}
|
}
|
||||||
|
@ -84,7 +84,7 @@ public abstract class AbstractFilteringJsonGeneratorTestCase extends ESTestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
private XContentBuilder newXContentBuilder(boolean inclusive, String... filters) throws IOException {
|
private XContentBuilder newXContentBuilder(boolean inclusive, String... filters) throws IOException {
|
||||||
return XContentBuilder.builder(getXContentType().xContent(), inclusive, filters);
|
return XContentBuilder.builder(getXContentType().xContent(), filters, inclusive);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -456,73 +456,72 @@ public abstract class AbstractFilteringJsonGeneratorTestCase extends ESTestCase
|
|||||||
|
|
||||||
public void testSimpleArrayExclusive() throws Exception {
|
public void testSimpleArrayExclusive() throws Exception {
|
||||||
XContentBuilder expected = newXContentBuilder(true).startObject()
|
XContentBuilder expected = newXContentBuilder(true).startObject()
|
||||||
.field("title", "My awesome book")
|
.field("title", "My awesome book")
|
||||||
.field("pages", 456)
|
.field("pages", 456)
|
||||||
.field("price", 27.99)
|
.field("price", 27.99)
|
||||||
.field("timestamp", 1428582942867L)
|
.field("timestamp", 1428582942867L)
|
||||||
.nullField("default")
|
.nullField("default")
|
||||||
.startArray("authors")
|
.startArray("authors")
|
||||||
.startObject()
|
.startObject()
|
||||||
.field("name", "John Doe")
|
.field("name", "John Doe")
|
||||||
.field("lastname", "John")
|
.field("lastname", "John")
|
||||||
.field("firstname", "Doe")
|
.field("firstname", "Doe")
|
||||||
.endObject()
|
.endObject()
|
||||||
.startObject()
|
.startObject()
|
||||||
.field("name", "William Smith")
|
.field("name", "William Smith")
|
||||||
.field("lastname", "William")
|
.field("lastname", "William")
|
||||||
.field("firstname", "Smith")
|
.field("firstname", "Smith")
|
||||||
.endObject()
|
.endObject()
|
||||||
.endArray()
|
.endArray()
|
||||||
.startObject("properties")
|
.startObject("properties")
|
||||||
.field("weight", 0.8d)
|
.field("weight", 0.8d)
|
||||||
.startObject("language")
|
.startObject("language")
|
||||||
.startObject("en")
|
.startObject("en")
|
||||||
.field("lang", "English")
|
.field("lang", "English")
|
||||||
.field("available", true)
|
.field("available", true)
|
||||||
.startArray("distributors")
|
.startArray("distributors")
|
||||||
.startObject()
|
.startObject()
|
||||||
.field("name", "The Book Shop")
|
.field("name", "The Book Shop")
|
||||||
.startArray("addresses")
|
.startArray("addresses")
|
||||||
.startObject()
|
.startObject()
|
||||||
.field("name", "address #1")
|
.field("name", "address #1")
|
||||||
.field("street", "Hampton St")
|
.field("street", "Hampton St")
|
||||||
.field("city", "London")
|
.field("city", "London")
|
||||||
.endObject()
|
.endObject()
|
||||||
.startObject()
|
.startObject()
|
||||||
.field("name", "address #2")
|
.field("name", "address #2")
|
||||||
.field("street", "Queen St")
|
.field("street", "Queen St")
|
||||||
.field("city", "Stornoway")
|
.field("city", "Stornoway")
|
||||||
.endObject()
|
.endObject()
|
||||||
.endArray()
|
.endArray()
|
||||||
.endObject()
|
.endObject()
|
||||||
.startObject()
|
.startObject()
|
||||||
.field("name", "Sussex Books House")
|
.field("name", "Sussex Books House")
|
||||||
.endObject()
|
.endObject()
|
||||||
.endArray()
|
.endArray()
|
||||||
.endObject()
|
.endObject()
|
||||||
.startObject("fr")
|
.startObject("fr")
|
||||||
.field("lang", "French")
|
.field("lang", "French")
|
||||||
.field("available", false)
|
.field("available", false)
|
||||||
.startArray("distributors")
|
.startArray("distributors")
|
||||||
.startObject()
|
.startObject()
|
||||||
.field("name", "La Maison du Livre")
|
.field("name", "La Maison du Livre")
|
||||||
.startArray("addresses")
|
.startArray("addresses")
|
||||||
.startObject()
|
.startObject()
|
||||||
.field("name", "address #1")
|
.field("name", "address #1")
|
||||||
.field("street", "Rue Mouffetard")
|
.field("street", "Rue Mouffetard")
|
||||||
.field("city", "Paris")
|
.field("city", "Paris")
|
||||||
.endObject()
|
.endObject()
|
||||||
.endArray()
|
.endArray()
|
||||||
.endObject()
|
.endObject()
|
||||||
.startObject()
|
.startObject()
|
||||||
.field("name", "Thetra")
|
.field("name", "Thetra")
|
||||||
.endObject()
|
.endObject()
|
||||||
.endArray()
|
.endArray()
|
||||||
.endObject()
|
.endObject()
|
||||||
.endObject()
|
.endObject()
|
||||||
.endObject()
|
.endObject()
|
||||||
.endObject();
|
.endObject();
|
||||||
|
|
||||||
|
|
||||||
assertXContentBuilder(expected, sample(false, "tags"));
|
assertXContentBuilder(expected, sample(false, "tags"));
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user