/** * */ public boolean isOneOf(ComparisonOperator... these) { for (ComparisonOperator candidate : these) { if (this.equals(candidate)) { return true; } } return false; }
@Override public String expression(String nodeIdentifier) { String latitude = nodeIdentifier + LATITUDE_PROPERTY_SUFFIX; String longitude = nodeIdentifier + LONGITUDE_PROPERTY_SUFFIX; return String.format("distance(point({latitude: %s, longitude: %s}),point({latitude:{lat}, longitude:{lon}})) " + "%s {distance} ", latitude, longitude, filter.getComparisonOperator().getValue()); }
@Override public String expression(String nodeIdentifier) { if (filter.getComparisonOperator().equals(IS_NULL)) { return String.format("%s.`%s` IS NULL ", nodeIdentifier, filter.getPropertyName()); } else if (filter.getComparisonOperator().equals(EXISTS)) { return String.format("EXISTS(%s.`%s`) ", nodeIdentifier, filter.getPropertyName()); } else if (filter.getComparisonOperator().equals(IS_TRUE)) { return String.format("%s.`%s` = true ", nodeIdentifier, filter.getPropertyName()); } else { return String.format("%s.`%s` %s { `%s` } ", nodeIdentifier, filter.getPropertyName(), filter.getComparisonOperator().getValue(), filter.uniqueParameterName()); } }
/** * Sets this filter to ignore the case in a property comparison when using the EQUALS operator. * * @return the same filter instance * @throws IllegalStateException if the filters function is null, not a property comparison or the operator of the * is not an EQUALS-operator. * @since 3.1.1 */ public Filter ignoreCase() { if (!(this.function instanceof PropertyComparison)) { throw new IllegalStateException("ignoreCase is only supported for a filter based on property comparison"); } else if (this.getComparisonOperator() != EQUALS) { throw new IllegalStateException( String.format("ignoreCase is only supported for %s comparison", ComparisonOperator.EQUALS.name())); } this.function = new CaseInsensitiveEqualsComparison((PropertyComparison) this.function); return this; }
@Override public Map<String, Object> parameters() { Map<String, Object> map = new HashMap<>(); if (!filter.getComparisonOperator().isOneOf(IS_NULL, EXISTS, IS_TRUE)) { map.put(filter.uniqueParameterName(), filter.getTransformedPropertyValue()); } return map; } }
private Object transformPropertyValue(Object value) { if (this.comparisonOperator != null) { return this.comparisonOperator.getPropertyValueTransformer().transformPropertyValue(value); } return new NoOpPropertyValueTransformer().transformPropertyValue(value); }
@Override public String expression(final String nodeIdentifier) { final Filter filter = this.getFilter(); return String.format("toLower(%s.`%s`) %s toLower({ `%s` }) ", nodeIdentifier, filter.getPropertyName(), ComparisonOperator.EQUALS.getValue(), filter.uniqueParameterName()); } }
@Override public String expression(String nodeIdentifier) { String pointPropertyOfEntity = nodeIdentifier + "." + getFilter().getPropertyName(); String comparisonOperator = getFilter().getComparisonOperator().getValue(); return String.format( "distance({%s},%s) %s {%s} ", OGM_POINT_PARAMETER, pointPropertyOfEntity, comparisonOperator, DISTANCE_VALUE_PARAMETER); }