public FilterPredicate(Path path, Operator op, List<Object> values) { this.operator = op; this.path = new Path(path); this.values = ImmutableList.copyOf(values); this.field = path.lastElement() .map(PathElement::getFieldName) .orElse(null); this.fieldPath = path.getPathElements().stream() .map(PathElement::getFieldName) .collect(Collectors.joining(PERIOD)); }
public FilterPredicate(Path path, Operator op, List<Object> values) { this.operator = op; this.path = new Path(path); this.values = ImmutableList.copyOf(values); this.field = path.lastElement() .map(PathElement::getFieldName) .orElse(null); this.fieldPath = path.getPathElements().stream() .map(PathElement::getFieldName) .collect(Collectors.joining(PERIOD)); }
/** * Returns an alias that uniquely identifies the last collection of entities in the path. * @return An alias for the path. */ public String getAlias() { if (pathElements.size() < 2) { return lastElement() .map(e -> getTypeAlias(e.getType())) .orElse(null); } PathElement previous = pathElements.get(pathElements.size() - 2); return getTypeAlias(previous.getType()) + UNDERSCORE + previous.getFieldName(); }
/** * Returns an alias that uniquely identifies the last collection of entities in the path. * @return An alias for the path. */ public String getAlias() { if (pathElements.size() < 2) { return lastElement() .map(e -> getTypeAlias(e.getType())) .orElse(null); } PathElement previous = pathElements.get(pathElements.size() - 2); return getTypeAlias(previous.getType()) + UNDERSCORE + previous.getFieldName(); }
private FilterExpression equalityExpression(String argument, Path path, List<Object> values) { boolean startsWith = argument.startsWith("*"); boolean endsWith = argument.endsWith("*"); if (startsWith && endsWith && argument.length() > 2) { String value = argument.substring(1, argument.length() - 1); return new FilterPredicate(path, caseSensitivityStrategy.mapOperator(Operator.INFIX), Collections.singletonList(value)); } if (startsWith && argument.length() > 1) { String value = argument.substring(1, argument.length()); return new FilterPredicate(path, caseSensitivityStrategy.mapOperator(Operator.POSTFIX), Collections.singletonList(value)); } if (endsWith && argument.length() > 1) { String value = argument.substring(0, argument.length() - 1); return new FilterPredicate(path, caseSensitivityStrategy.mapOperator(Operator.PREFIX), Collections.singletonList(value)); } Boolean isStringLike = path.lastElement() .map(e -> e.getFieldType().isAssignableFrom(String.class)) .orElse(false); if (isStringLike) { return new FilterPredicate(path, caseSensitivityStrategy.mapOperator(Operator.IN), values); } return new InPredicate(path, values); }
private FilterExpression equalityExpression(String argument, Path path, List<Object> values) { boolean startsWith = argument.startsWith("*"); boolean endsWith = argument.endsWith("*"); if (startsWith && endsWith && argument.length() > 2) { String value = argument.substring(1, argument.length() - 1); return new FilterPredicate(path, caseSensitivityStrategy.mapOperator(Operator.INFIX), Collections.singletonList(value)); } if (startsWith && argument.length() > 1) { String value = argument.substring(1, argument.length()); return new FilterPredicate(path, caseSensitivityStrategy.mapOperator(Operator.POSTFIX), Collections.singletonList(value)); } if (endsWith && argument.length() > 1) { String value = argument.substring(0, argument.length() - 1); return new FilterPredicate(path, caseSensitivityStrategy.mapOperator(Operator.PREFIX), Collections.singletonList(value)); } Boolean isStringLike = path.lastElement() .map(e -> e.getFieldType().isAssignableFrom(String.class)) .orElse(false); if (isStringLike) { return new FilterPredicate(path, caseSensitivityStrategy.mapOperator(Operator.IN), values); } return new InPredicate(path, values); }
Class<?> relationshipType = path.lastElement() .map(Path.PathElement::getFieldType) .orElseThrow(() -> new IllegalStateException("Path must not be empty"));
Class<?> relationshipType = path.lastElement() .map(Path.PathElement::getFieldType) .orElseThrow(() -> new IllegalStateException("Path must not be empty"));