Java Code Examples for cz.jirutka.rsql.parser.ast.RSQLOperators#GREATER_THAN_OR_EQUAL

The following examples show how to use cz.jirutka.rsql.parser.ast.RSQLOperators#GREATER_THAN_OR_EQUAL . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SearchFilterToQueryConverter.java    From dremio-oss with Apache License 2.0 6 votes vote down vote up
private SearchQuery createRangeQuery(Class<?> cls, String name, Object value, ComparisonOperator type) {

    boolean minInclusive = type == RSQLOperators.GREATER_THAN_OR_EQUAL || type == RSQLOperators.EQUAL;
    boolean maxInclusive = type == RSQLOperators.LESS_THAN_OR_EQUAL || type == RSQLOperators.EQUAL;

    if (Number.class.isAssignableFrom(cls)) {
      if (Double.class.isAssignableFrom(cls)) {
        return createDoubleRangeQuery(name, value, type, minInclusive, maxInclusive);
      } else if (Float.class.isAssignableFrom(cls)) {
        return createFloatRangeQuery(name, value, type, minInclusive, maxInclusive);
      } else if (Long.class.isAssignableFrom(cls)) {
        return createLongRangeQuery(name, value, type, minInclusive, maxInclusive);
      } else {
        return createIntRangeQuery(name, value, type, minInclusive, maxInclusive);
      }
    } else if (String.class.isAssignableFrom(cls)) {
      return createStringRangeQuery(name, value, type, minInclusive, maxInclusive);
    } else {
      throw new IllegalArgumentException(format("%s: Can not do range query on field %s of type %s" +
        "only long, int, double, float types are supported", visitorName, name, cls.getName()));
    }
  }
 
Example 2
Source File: SearchFilterToQueryConverter.java    From dremio-oss with Apache License 2.0 5 votes vote down vote up
private SearchQuery createIntRangeQuery(final String name, final Object value,
                                  final ComparisonOperator type, final boolean minInclusive, final boolean maxInclusive) {
  final Integer intValue = (Integer) value;

  final Integer minValue = (type != RSQLOperators.LESS_THAN && type != RSQLOperators.LESS_THAN_OR_EQUAL)
      ? intValue : null;
  final Integer maxValue = (type != RSQLOperators.GREATER_THAN && type != RSQLOperators.GREATER_THAN_OR_EQUAL)
      ? intValue : null;

  return SearchQueryUtils.newRangeInt(name, minValue, maxValue, minInclusive, maxInclusive);
}
 
Example 3
Source File: SearchFilterToQueryConverter.java    From dremio-oss with Apache License 2.0 5 votes vote down vote up
private SearchQuery createLongRangeQuery(final String name, final Object value,
                                   final ComparisonOperator type, final boolean minInclusive, final boolean maxInclusive) {
  final Long longValue = (Long) value;

  final Long minValue = (type != RSQLOperators.LESS_THAN && type != RSQLOperators.LESS_THAN_OR_EQUAL)
      ? longValue : null;
  final Long maxValue = (type != RSQLOperators.GREATER_THAN && type != RSQLOperators.GREATER_THAN_OR_EQUAL)
      ? longValue : null;

  return SearchQueryUtils.newRangeLong(name, minValue, maxValue, minInclusive, maxInclusive);
}
 
Example 4
Source File: SearchFilterToQueryConverter.java    From dremio-oss with Apache License 2.0 5 votes vote down vote up
private SearchQuery createDoubleRangeQuery(final String name, final Object value,
                                     final ComparisonOperator type, final boolean minInclusive, final boolean maxInclusive) {
  final Double doubleValue = (Double) value;

  final Double minValue = (type != RSQLOperators.LESS_THAN && type != RSQLOperators.LESS_THAN_OR_EQUAL)
      ? doubleValue : null;
  final Double maxValue = (type != RSQLOperators.GREATER_THAN && type != RSQLOperators.GREATER_THAN_OR_EQUAL)
      ? doubleValue : null;

  return SearchQueryUtils.newRangeDouble(name, minValue, maxValue, minInclusive, maxInclusive);
}
 
Example 5
Source File: SearchFilterToQueryConverter.java    From dremio-oss with Apache License 2.0 5 votes vote down vote up
private SearchQuery createFloatRangeQuery(final String name, final Object value,
                                    final ComparisonOperator type, final boolean minInclusive, final boolean maxInclusive) {
  final Float floatValue = (Float) value;

  final Float minValue = (type != RSQLOperators.LESS_THAN && type != RSQLOperators.LESS_THAN_OR_EQUAL)
      ? floatValue : null;
  final Float maxValue = (type != RSQLOperators.GREATER_THAN && type != RSQLOperators.GREATER_THAN_OR_EQUAL)
      ? floatValue : null;

  return SearchQueryUtils.newRangeFloat(name, minValue, maxValue, minInclusive, maxInclusive);
}
 
Example 6
Source File: SearchFilterToQueryConverter.java    From dremio-oss with Apache License 2.0 5 votes vote down vote up
private SearchQuery createStringRangeQuery(final String name, final Object value,
                                     final ComparisonOperator type, final boolean minInclusive, final boolean maxInclusive) {
  final String stringValue = (String)value;

  final String minValue = (type != RSQLOperators.LESS_THAN && type != RSQLOperators.LESS_THAN_OR_EQUAL)
      ? stringValue : null;
  final String maxValue = (type != RSQLOperators.GREATER_THAN && type != RSQLOperators.GREATER_THAN_OR_EQUAL)
      ? stringValue : null;

  return SearchQueryUtils.newRangeTerm(name, minValue, maxValue, minInclusive, maxInclusive);
}