@Override default Optional<R> resolve(E expression, ResolutionContext context) throws InvalidExpressionException { if (!(context instanceof MongoResolutionContext)) { throw new InvalidExpressionException("Invalid context type: expected a [" + MongoResolutionContext.class.getName() + ", got a [" + context.getClass().getName() + "]"); } return resolve(expression, (MongoResolutionContext<?>) context); }
private static Predicate[] resolveFilterList(List<QueryFilter> filters, QueryDslResolutionContext context) throws InvalidExpressionException { List<Predicate> resolved = new LinkedList<>(); filters.forEach(f -> { PredicateExpression prd = context.resolve(f, PredicateExpression.class, context) .orElseThrow(() -> new InvalidExpressionException("Failed to resolve QueryFilter [" + f + "]")); prd.validate(); resolved.add(prd.getPredicate()); }); return resolved.toArray(new Predicate[resolved.size()]); }
@Override public PredicateExpression visit(NotFilter filter, QueryDslResolutionContext context) { PredicateExpression prd = context.resolve(filter.getComposition().get(0), PredicateExpression.class, context) .orElseThrow(() -> new InvalidExpressionException( "Failed to resolve QueryFilter [" + filter.getComposition().get(0) + "]")); prd.validate(); return PredicateExpression.create(prd.getPredicate().not()); }
@Override public <T> PredicateExpression visit(LessFilter<T> filter, QueryDslResolutionContext context) { TypedExpression<? super T> rightOperand = filter.getRightOperand() .orElseThrow(() -> new InvalidExpressionException("Missing right operand in filter [" + filter + "]")); return PredicateExpression.create(Expressions.booleanOperation(filter.isIncludeEquals() ? Ops.LOE : Ops.LT, context.resolveOrFail(filter.getLeftOperand(), QueryDslExpression.class).getExpression(), context.resolveOrFail(rightOperand, QueryDslExpression.class).getExpression())); }
@Override public void validate() throws InvalidExpressionException { if (getPropertySet() == null) { throw new InvalidExpressionException("Null property set"); } }
@Override public void validate() throws InvalidExpressionException { super.validate(); if (getValue() == null) { throw new InvalidExpressionException("Missing operation PropertyBox value"); } }
@Override public void validate() throws InvalidExpressionException { if (getBeanClass() == null) { throw new InvalidExpressionException("Null bean class"); } }
@Override public void validate() throws InvalidExpressionException { if (value == null) { throw new InvalidExpressionException("Kay value must be not null"); } }
@Override public Optional<PropertyBoxValue> resolve(DocumentValue expression, MongoResolutionContext context) throws InvalidExpressionException { // validate expression.validate(); // Document context final MongoDocumentContext documentContext = MongoDocumentContext.isDocumentContext(context).orElseThrow( () -> new InvalidExpressionException("The resolution context must be a MongoDocumentContext")); return Optional .ofNullable(PropertyBoxValue.create(decodePropertyBox(documentContext, null, expression.getValue()))); }
@Override public void validate() throws InvalidExpressionException { if (getBson() == null) { throw new InvalidExpressionException("Null Bson sort value"); } }
@Override public void validate() throws InvalidExpressionException { if (getDefinition() == null) { throw new InvalidExpressionException("Null query definition"); } }
@Override public void validate() throws InvalidExpressionException { if (getValue() == null) { throw new InvalidExpressionException("Null document value"); } }
@Override public void validate() throws InvalidExpressionException { if (getEntityPath() == null) { throw new InvalidExpressionException("Null entity path"); } } }
@Override public void validate() throws InvalidExpressionException { if (getOrderSpecifiers() == null || getOrderSpecifiers().isEmpty()) { throw new InvalidExpressionException("No OrderSpecifier available"); } }
@Override public void validate() throws InvalidExpressionException { super.validate(); if (!getRightOperand().isPresent()) { throw new InvalidExpressionException("Missing right hand operand"); } }
@Override public void validate() throws InvalidExpressionException { if (getValue() == null) { throw new InvalidExpressionException("Null value"); } }
@Override public void validate() throws InvalidExpressionException { if (getType() == null) { throw new InvalidExpressionException("Null expression type"); } }
@Override public void validate() throws InvalidExpressionException { super.validate(); if (!getRightOperand().isPresent()) { throw new InvalidExpressionException("Missing right hand operand"); } }
@Override public void validate() throws InvalidExpressionException { if (aggregationPaths == null || aggregationPaths.length == 0) { throw new InvalidExpressionException("No aggregation path available"); } }
@Override public void validate() throws InvalidExpressionException { if (getLeftOperand() == null) { throw new InvalidExpressionException("Null left hand operand"); } if (getOperator() == null) { throw new InvalidExpressionException("Null operator"); } }