use of com.mongodb.operation.GroupOperation in project mongo-java-driver by mongodb.
the class GroupCommand method toOperation.
GroupOperation<DBObject> toOperation(final MongoNamespace namespace, final DBObjectCodec codec) {
if (initial == null) {
throw new IllegalArgumentException("Group command requires an initial document for the aggregate result");
}
if (reduce == null) {
throw new IllegalArgumentException("Group command requires a reduce function for the aggregate result");
}
GroupOperation<DBObject> operation = new GroupOperation<DBObject>(namespace, new BsonJavaScript(reduce), new BsonDocumentWrapper<DBObject>(initial, codec), codec);
if (keys != null) {
operation.key(new BsonDocumentWrapper<DBObject>(keys, codec));
}
if (keyf != null) {
operation.keyFunction(new BsonJavaScript(keyf));
}
if (condition != null) {
operation.filter(new BsonDocumentWrapper<DBObject>(condition, codec));
}
if (finalize != null) {
operation.finalizeFunction(new BsonJavaScript(finalize));
}
operation.collation(collation);
return operation;
}
Aggregations