Skip to content

Commit

Permalink
added convenience methods for working with filter expressions
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjamin Kastelic committed Mar 19, 2021
1 parent f464d06 commit 8561656
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,18 @@ public QueryFilterExpression(QueryFilter value) {
right = null;
}

public QueryFilterExpression(FilterExpressionOperation operation, QueryFilter left, QueryFilter right) {
this(operation, new QueryFilterExpression(left), new QueryFilterExpression(right));
}

public QueryFilterExpression(FilterExpressionOperation operation, QueryFilterExpression left, QueryFilter right) {
this(operation, left, new QueryFilterExpression(right));
}

public QueryFilterExpression(FilterExpressionOperation operation, QueryFilter left, QueryFilterExpression right) {
this(operation, new QueryFilterExpression(left), right);
}

public QueryFilterExpression(FilterExpressionOperation operation, QueryFilterExpression left, QueryFilterExpression right) {
value = null;
this.operation = operation;
Expand Down
13 changes: 10 additions & 3 deletions core/src/main/java/com/kumuluz/ee/rest/beans/QueryParameters.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
*/
package com.kumuluz.ee.rest.beans;

import com.kumuluz.ee.rest.enums.FilterExpressionOperation;
import com.kumuluz.ee.rest.utils.QueryStringBuilder;

import java.io.Serializable;
Expand Down Expand Up @@ -105,8 +106,8 @@ public void setFields(List<String> fields) {
}

/**
* @deprecated Will be removed in future releases. Use {@link #getFilterExpression()} ()} and
* {@link #setFilterExpression(QueryFilterExpression)} ()} instead.
* @deprecated Will be removed in future releases. Use
* {@link #addFilterExpression(FilterExpressionOperation, QueryFilterExpression)} ()} instead.
*/
public void addFilter(QueryFilter filter) {
if(filter != null) {
Expand All @@ -115,7 +116,8 @@ public void addFilter(QueryFilter filter) {
}

/**
* @deprecated Will be removed in future releases. Use {@link #setFilterExpression(QueryFilterExpression)} ()} instead.
* @deprecated Will be removed in future releases. Use {@link #setFilterExpression(QueryFilterExpression)} ()}
* instead.
*/
@Deprecated
public void setFilters(List<QueryFilter> filters) {
Expand All @@ -134,6 +136,11 @@ public List<QueryFilter> getFilters() {
return filters;
}

public QueryFilterExpression addFilterExpression(FilterExpressionOperation operation, QueryFilterExpression queryFilterExpression) {
filterExpression = new QueryFilterExpression(operation, filterExpression, queryFilterExpression);
return filterExpression;
}

public QueryFilterExpression getFilterExpression() {
return filterExpression;
}
Expand Down

0 comments on commit 8561656

Please sign in to comment.