private static ImmutableMap<String,Expression<?>> createBindings(Expression<?>... args) { ImmutableMap.Builder<String, Expression<?>> rv = ImmutableMap.builder(); for (Expression<?> expr : args) { if (expr instanceof Path<?>) { Path<?> path = (Path<?>) expr; rv.put(path.getMetadata().getName(), expr); } else if (expr instanceof Operation<?>) { Operation<?> operation = (Operation<?>) expr; if (operation.getOperator() == Ops.ALIAS && operation.getArg(1) instanceof Path<?>) { Path<?> path = (Path<?>) operation.getArg(1); if (isCompoundExpression(operation.getArg(0))) { rv.put(path.getMetadata().getName(), operation.getArg(0)); } else { rv.put(path.getMetadata().getName(), operation); } } else { throw new IllegalArgumentException("Unsupported expression " + expr); } } else { throw new IllegalArgumentException("Unsupported expression " + expr); } } return rv.build(); }
private static ImmutableMap<String,Expression<?>> createBindings(Expression<?>... args) { ImmutableMap.Builder<String, Expression<?>> rv = ImmutableMap.builder(); for (Expression<?> expr : args) { if (expr instanceof Path<?>) { Path<?> path = (Path<?>) expr; rv.put(path.getMetadata().getName(), expr); } else if (expr instanceof Operation<?>) { Operation<?> operation = (Operation<?>) expr; if (operation.getOperator() == Ops.ALIAS && operation.getArg(1) instanceof Path<?>) { Path<?> path = (Path<?>) operation.getArg(1); if (isCompoundExpression(operation.getArg(0))) { rv.put(path.getMetadata().getName(), operation.getArg(0)); } else { rv.put(path.getMetadata().getName(), operation); } } else { throw new IllegalArgumentException("Unsupported expression " + expr); } } else { throw new IllegalArgumentException("Unsupported expression " + expr); } } return rv.build(); }