Skip to content

Commit

Permalink
Removing unneeded class name prefix when using NAME in builders
Browse files Browse the repository at this point in the history
  • Loading branch information
cbuescher committed May 21, 2015
1 parent 2f77013 commit a9d4fc4
Show file tree
Hide file tree
Showing 50 changed files with 96 additions and 148 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
public class BoolQueryBuilder extends QueryBuilder implements BoostableQueryBuilder<BoolQueryBuilder> {

public static final String NAME = "bool";

private final List<QueryBuilder> mustClauses = new ArrayList<>();

private final List<QueryBuilder> mustNotClauses = new ArrayList<>();
Expand Down Expand Up @@ -162,7 +162,7 @@ public BoolQueryBuilder queryName(String queryName) {

@Override
protected void doXContent(XContentBuilder builder, Params params) throws IOException {
builder.startObject("bool");
builder.startObject(NAME);
doXArrayContent("must", mustClauses, builder, params);
doXArrayContent("filter", filterClauses, builder, params);
doXArrayContent("must_not", mustNotClauses, builder, params);
Expand Down Expand Up @@ -203,6 +203,6 @@ private void doXArrayContent(String field, List<QueryBuilder> clauses, XContentB

@Override
public String queryId() {
return BoolQueryBuilder.NAME;
return NAME;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ protected void doXContent(XContentBuilder builder, Params params) throws IOExcep
if (negativeBoost == -1) {
throw new IllegalArgumentException("boosting query requires negativeBoost to be set");
}
builder.startObject(BoostingQueryBuilder.NAME);
builder.startObject(NAME);
builder.field("positive");
positiveQuery.toXContent(builder, params);
builder.field("negative");
Expand All @@ -99,6 +99,6 @@ protected void doXContent(XContentBuilder builder, Params params) throws IOExcep

@Override
public String queryId() {
return BoostingQueryBuilder.NAME;
return NAME;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ public CommonTermsQueryBuilder queryName(String queryName) {

@Override
public void doXContent(XContentBuilder builder, Params params) throws IOException {
builder.startObject(CommonTermsQueryBuilder.NAME);
builder.startObject(NAME);
builder.startObject(name);

builder.field("query", text);
Expand Down Expand Up @@ -205,6 +205,6 @@ public void doXContent(XContentBuilder builder, Params params) throws IOExceptio

@Override
public String queryId() {
return CommonTermsQueryBuilder.NAME;
return NAME;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public ConstantScoreQueryBuilder boost(float boost) {

@Override
protected void doXContent(XContentBuilder builder, Params params) throws IOException {
builder.startObject(ConstantScoreQueryBuilder.NAME);
builder.startObject(NAME);
builder.field("filter");
filterBuilder.toXContent(builder, params);

Expand All @@ -71,6 +71,6 @@ protected void doXContent(XContentBuilder builder, Params params) throws IOExcep

@Override
public String queryId() {
return ConstantScoreQueryBuilder.NAME;
return NAME;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public DisMaxQueryBuilder queryName(String queryName) {

@Override
protected void doXContent(XContentBuilder builder, Params params) throws IOException {
builder.startObject(DisMaxQueryBuilder.NAME);
builder.startObject(NAME);
if (tieBreaker != -1) {
builder.field("tie_breaker", tieBreaker);
}
Expand All @@ -102,6 +102,6 @@ protected void doXContent(XContentBuilder builder, Params params) throws IOExcep

@Override
public String queryId() {
return DisMaxQueryBuilder.NAME;
return NAME;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public ExistsQueryBuilder queryName(String queryName) {

@Override
protected void doXContent(XContentBuilder builder, Params params) throws IOException {
builder.startObject(ExistsQueryBuilder.NAME);
builder.startObject(NAME);
builder.field("field", name);
if (queryName != null) {
builder.field("_name", queryName);
Expand All @@ -58,6 +58,6 @@ protected void doXContent(XContentBuilder builder, Params params) throws IOExcep

@Override
public String queryId() {
return ExistsQueryBuilder.NAME;
return NAME;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public FieldMaskingSpanQueryBuilder queryName(String queryName) {

@Override
protected void doXContent(XContentBuilder builder, Params params) throws IOException {
builder.startObject(FieldMaskingSpanQueryBuilder.NAME);
builder.startObject(NAME);
builder.field("query");
queryBuilder.toXContent(builder, params);
builder.field("field", field);
Expand All @@ -71,6 +71,6 @@ protected void doXContent(XContentBuilder builder, Params params) throws IOExcep

@Override
public String queryId() {
return FieldMaskingSpanQueryBuilder.NAME;
return NAME;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public FilteredQueryBuilder queryName(String queryName) {

@Override
protected void doXContent(XContentBuilder builder, Params params) throws IOException {
builder.startObject(FilteredQueryBuilder.NAME);
builder.startObject(NAME);
if (queryBuilder != null) {
builder.field("query");
queryBuilder.toXContent(builder, params);
Expand All @@ -92,6 +92,6 @@ protected void doXContent(XContentBuilder builder, Params params) throws IOExcep

@Override
public String queryId() {
return FilteredQueryBuilder.NAME;
return NAME;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public FuzzyQueryBuilder queryName(String queryName) {

@Override
public void doXContent(XContentBuilder builder, Params params) throws IOException {
builder.startObject(FuzzyQueryBuilder.NAME);
builder.startObject(NAME);
if (boost == -1 && fuzziness == null && prefixLength == null && queryName != null) {
builder.field(name, value);
} else {
Expand Down Expand Up @@ -140,6 +140,6 @@ public void doXContent(XContentBuilder builder, Params params) throws IOExceptio

@Override
public String queryId() {
return FuzzyQueryBuilder.NAME;
return NAME;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ protected void doXContent(XContentBuilder builder, Params params) throws IOExcep
throw new IllegalArgumentException("geo_bounding_box requires left longitude to be set");
}

builder.startObject(GeoBoundingBoxQueryBuilder.NAME);
builder.startObject(NAME);

builder.startObject(name);
builder.array(TOP_LEFT, box[LEFT], box[TOP]);
Expand All @@ -177,6 +177,6 @@ protected void doXContent(XContentBuilder builder, Params params) throws IOExcep

@Override
public String queryId() {
return GeoBoundingBoxQueryBuilder.NAME;
return NAME;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public GeoDistanceQueryBuilder queryName(String queryName) {

@Override
protected void doXContent(XContentBuilder builder, Params params) throws IOException {
builder.startObject(GeoDistanceQueryBuilder.NAME);
builder.startObject(NAME);
if (geohash != null) {
builder.field(name, geohash);
} else {
Expand All @@ -122,6 +122,6 @@ protected void doXContent(XContentBuilder builder, Params params) throws IOExcep

@Override
public String queryId() {
return GeoDistanceQueryBuilder.NAME;
return NAME;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public GeoDistanceRangeQueryBuilder queryName(String queryName) {

@Override
protected void doXContent(XContentBuilder builder, Params params) throws IOException {
builder.startObject(GeoDistanceRangeQueryBuilder.NAME);
builder.startObject(NAME);
if (geohash != null) {
builder.field(name, geohash);
} else {
Expand All @@ -161,6 +161,6 @@ protected void doXContent(XContentBuilder builder, Params params) throws IOExcep

@Override
public String queryId() {
return GeoDistanceQueryBuilder.NAME;
return NAME;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public GeoPolygonQueryBuilder queryName(String queryName) {

@Override
protected void doXContent(XContentBuilder builder, Params params) throws IOException {
builder.startObject(GeoPolygonQueryBuilder.NAME);
builder.startObject(NAME);

builder.startObject(name);
builder.startArray(POINTS);
Expand All @@ -93,6 +93,6 @@ protected void doXContent(XContentBuilder builder, Params params) throws IOExcep

@Override
public String queryId() {
return GeoPolygonQueryBuilder.NAME;
return NAME;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public GeoShapeQueryBuilder relation(ShapeRelation relation) {

@Override
protected void doXContent(XContentBuilder builder, Params params) throws IOException {
builder.startObject(GeoShapeQueryBuilder.NAME);
builder.startObject(NAME);

builder.startObject(name);

Expand Down Expand Up @@ -188,6 +188,6 @@ protected void doXContent(XContentBuilder builder, Params params) throws IOExcep

@Override
public String queryId() {
return GeoShapeQueryBuilder.NAME;
return NAME;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public HasChildQueryBuilder innerHit(QueryInnerHitBuilder innerHit) {

@Override
protected void doXContent(XContentBuilder builder, Params params) throws IOException {
builder.startObject(HasChildQueryBuilder.NAME);
builder.startObject(NAME);
builder.field("query");
queryBuilder.toXContent(builder, params);
builder.field("child_type", childType);
Expand Down Expand Up @@ -143,6 +143,6 @@ protected void doXContent(XContentBuilder builder, Params params) throws IOExcep

@Override
public String queryId() {
return HasChildQueryBuilder.NAME;
return NAME;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public HasParentQueryBuilder innerHit(QueryInnerHitBuilder innerHit) {

@Override
protected void doXContent(XContentBuilder builder, Params params) throws IOException {
builder.startObject(HasParentQueryBuilder.NAME);
builder.startObject(NAME);
builder.field("query");
queryBuilder.toXContent(builder, params);
builder.field("parent_type", parentType);
Expand All @@ -100,7 +100,7 @@ protected void doXContent(XContentBuilder builder, Params params) throws IOExcep

@Override
public String queryId() {
return HasParentQueryBuilder.NAME;
return NAME;
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public String queryName() {

@Override
protected void doXContent(XContentBuilder builder, Params params) throws IOException {
builder.startObject(IdsQueryBuilder.NAME);
builder.startObject(NAME);
if (types != null) {
if (types.length == 1) {
builder.field("type", types[0]);
Expand All @@ -143,7 +143,7 @@ protected void doXContent(XContentBuilder builder, Params params) throws IOExcep

@Override
public String queryId() {
return IdsQueryBuilder.NAME;
return NAME;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public IndicesQueryBuilder queryName(String queryName) {

@Override
protected void doXContent(XContentBuilder builder, Params params) throws IOException {
builder.startObject(IndicesQueryBuilder.NAME);
builder.startObject(NAME);
builder.field("indices", indices);
builder.field("query");
queryBuilder.toXContent(builder, params);
Expand All @@ -89,6 +89,6 @@ protected void doXContent(XContentBuilder builder, Params params) throws IOExcep

@Override
public String queryId() {
return IndicesQueryBuilder.NAME;
return NAME;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ public LimitQueryBuilder(int limit) {

@Override
protected void doXContent(XContentBuilder builder, Params params) throws IOException {
builder.startObject(LimitQueryBuilder.NAME);
builder.startObject(NAME);
builder.field("value", limit);
builder.endObject();
}

@Override
public String queryId() {
return LimitQueryBuilder.NAME;
return NAME;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public float boost() {

@Override
public void doXContent(XContentBuilder builder, Params params) throws IOException {
builder.startObject(MatchAllQueryBuilder.NAME);
builder.startObject(NAME);
if (boost != 1.0f) {
builder.field("boost", boost);
}
Expand Down Expand Up @@ -104,6 +104,6 @@ public void writeTo(StreamOutput out) throws IOException {

@Override
public String queryId() {
return MatchAllQueryBuilder.NAME;
return NAME;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ public MatchQueryBuilder queryName(String queryName) {

@Override
public void doXContent(XContentBuilder builder, Params params) throws IOException {
builder.startObject(MatchQueryBuilder.NAME);
builder.startObject(NAME);
builder.startObject(name);

builder.field("query", text);
Expand Down Expand Up @@ -281,6 +281,6 @@ public void doXContent(XContentBuilder builder, Params params) throws IOExceptio

@Override
public String queryId() {
return MatchQueryBuilder.NAME;
return NAME;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public MissingQueryBuilder queryName(String queryName) {

@Override
protected void doXContent(XContentBuilder builder, Params params) throws IOException {
builder.startObject(MissingQueryBuilder.NAME);
builder.startObject(NAME);
builder.field("field", name);
if (nullValue != null) {
builder.field("null_value", nullValue);
Expand All @@ -86,6 +86,6 @@ protected void doXContent(XContentBuilder builder, Params params) throws IOExcep

@Override
public String queryId() {
return MissingQueryBuilder.NAME;
return NAME;
}
}
Loading

0 comments on commit a9d4fc4

Please sign in to comment.