code: public DBObject toDBObject() {
          DBObject dbObject = new BasicDBObject();
          if (granularity != null) {
              dbObject.put("granularity", granularity.getGranulality());
          }
  
          DBObject output = new BasicDBObject();
          for (Map.Entry<String, Accumulator> entry : accumulators.entrySet()) {
              output.put(entry.getKey(), entry.getValue().toDBObject());
          }
          if (!accumulators.isEmpty()) {
              dbObject.put("output", output);
          }
  
          return dbObject;
      }
docs: Converts a BucketAutoOptions to a DBObject for use by the Java driver.
  
  @return the DBObject