class QueryToMongodb {

    protected static Iterable<Bson> getCommands(final List<Query> queries) {
        return new Iterable<Bson>() {
            @Override
            public Iterator<Bson> iterator() {
                return new Iterator<Bson>() {
                    private int rank = 0;

                    @Override
                    public Bson next() {
                        try {
                            return getCommand(queries.get(rank++));
                        } catch (final InvalidParseOperationException e) {
                            // error but ignore ?
                            LOGGER.error("Bad request", e);
                            return null;
                        }
                    }

                    @Override
                    public boolean hasNext() {
                        return rank < queries.size();
                    }
                };
            }
        };
    }

    private  QueryToMongodb();

}