Minor refactoring and indentation fixes

This commit is contained in:
Konrad Beiske 2016-02-03 11:13:12 +01:00
parent a0d8d656fc
commit db4c6c96a3
4 changed files with 75 additions and 83 deletions

View File

@ -83,7 +83,7 @@ public final class XContentBuilder implements BytesStream, Releasable {
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);
}

View File

@ -68,8 +68,8 @@ public class SmileXContent implements XContent {
}
@Override
public XContentGenerator createGenerator(OutputStream os, String[] filters, boolean inclusiveFilters) throws IOException {
return new SmileXContentGenerator(smileFactory.createGenerator(os, JsonEncoding.UTF8), os, inclusiveFilters, filters);
public XContentGenerator createGenerator(OutputStream os, String[] filters, boolean inclusive) throws IOException {
return new SmileXContentGenerator(smileFactory.createGenerator(os, JsonEncoding.UTF8), os, inclusive, filters);
}
@Override

View File

@ -92,18 +92,11 @@ public class FilterPathBasedFilter extends TokenFilter {
@Override
public TokenFilter includeProperty(String name) {
TokenFilter filter = evaluate(name, filters);
if (inclusive) {
if (filter == MATCHING) {
return TokenFilter.INCLUDE_ALL;
} else if (filter == NO_MATCHING) {
return null;
}
} else {
if (filter == MATCHING) {
return null;
} else if (filter == NO_MATCHING) {
return TokenFilter.INCLUDE_ALL;
return inclusive ? TokenFilter.INCLUDE_ALL : null;
}
if (filter == NO_MATCHING) {
return inclusive ? null : TokenFilter.INCLUDE_ALL;
}
return filter;
}

View File

@ -84,7 +84,7 @@ public abstract class AbstractFilteringJsonGeneratorTestCase extends ESTestCase
}
private XContentBuilder newXContentBuilder(boolean inclusive, String... filters) throws IOException {
return XContentBuilder.builder(getXContentType().xContent(), inclusive, filters);
return XContentBuilder.builder(getXContentType().xContent(), filters, inclusive);
}
/**
@ -523,7 +523,6 @@ public abstract class AbstractFilteringJsonGeneratorTestCase extends ESTestCase
.endObject()
.endObject();
assertXContentBuilder(expected, sample(false, "tags"));
}