Package dev.morphia.aggregation.stages
Class Group
- java.lang.Object
-
- dev.morphia.aggregation.stages.Stage
-
- dev.morphia.aggregation.stages.Group
-
public class Group extends Stage
Groups input documents by the specified _id expression and for each distinct grouping, outputs a document.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Group.GroupId
Defines a group ID
-
Constructor Summary
Constructors Modifier Constructor Description protected
Group()
protected
Group(Group.GroupId id)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description Group
field(String name)
Adds a field to the group.Group
field(String name, dev.morphia.aggregation.expressions.impls.Expression expression)
Adds a named field to the group with an expression giving the value.dev.morphia.aggregation.expressions.impls.Fields<Group>
getFields()
Group.GroupId
getId()
static Group
group()
Creates a group stage with no ID definitionstatic Group
group(Group.GroupId id)
Creates a group stage with an ID definitionstatic Group.GroupId
id()
Creates an unnamed group IDstatic Group.GroupId
id(dev.morphia.aggregation.expressions.impls.Expression name)
Creates a named group IDstatic Group.GroupId
id(String name)
Creates a named group IDstatic Group
of()
Deprecated, for removal: This API element is subject to removal in a future version.usergroup()
static Group
of(Group.GroupId id)
Deprecated, for removal: This API element is subject to removal in a future version.usegroup(GroupId)
-
Methods inherited from class dev.morphia.aggregation.stages.Stage
aggregation, stageName
-
-
-
-
Constructor Detail
-
Group
protected Group()
-
Group
protected Group(Group.GroupId id)
-
-
Method Detail
-
group
public static Group group(Group.GroupId id)
Creates a group stage with an ID definition- Parameters:
id
- the group ID- Returns:
- the new stage
- Since:
- 2.2
-
group
public static Group group()
Creates a group stage with no ID definition- Returns:
- the new stage
- Since:
- 2.2
-
id
public static Group.GroupId id()
Creates an unnamed group ID- Returns:
- the new groupID
-
id
public static Group.GroupId id(String name)
Creates a named group ID- Parameters:
name
- the id name- Returns:
- the new groupID
-
id
public static Group.GroupId id(dev.morphia.aggregation.expressions.impls.Expression name)
Creates a named group ID- Parameters:
name
- the id name- Returns:
- the new groupID
-
of
@Deprecated(forRemoval=true) public static Group of(Group.GroupId id)
Deprecated, for removal: This API element is subject to removal in a future version.usegroup(GroupId)
Creates a group stage with an ID definition- Parameters:
id
- the group ID- Returns:
- the new stage
-
of
@Deprecated(forRemoval=true) public static Group of()
Deprecated, for removal: This API element is subject to removal in a future version.usergroup()
Creates a group stage with no ID definition- Returns:
- the new stage
-
field
public Group field(String name)
Adds a field to the group. This method is equivalent to callingfield("name", Expression.field("name"))
- Parameters:
name
- the field name- Returns:
- this
- See Also:
field(String, Expression)
,Expressions.field(String)
-
field
public Group field(String name, dev.morphia.aggregation.expressions.impls.Expression expression)
Adds a named field to the group with an expression giving the value.- Parameters:
name
- the name of the fieldexpression
- the expression giving the value- Returns:
- this
-
getFields
@Nullable @MorphiaInternal public dev.morphia.aggregation.expressions.impls.Fields<Group> getFields()
- Returns:
- the fields
Developer note.This is an internal item. Its function and presence are subject to change without warning. Its use is highly discouraged.
-
getId
@Nullable @MorphiaInternal public Group.GroupId getId()
- Returns:
- the ID
Developer note.This is an internal item. Its function and presence are subject to change without warning. Its use is highly discouraged.
-
-