public class Group extends AssistmentsPrincipal implements XInfo, HasExternalReference
Modifier and Type | Class and Description |
---|---|
static class |
Group.GroupChildDepth |
XInfoImpl.XInfoState
Constructor and Description |
---|
Group(Group g) |
Group(java.lang.String name) |
Group(java.lang.String name,
User owner) |
Modifier and Type | Method and Description |
---|---|
boolean |
addMember(AssistmentsPrincipal member)
Adds a principal to this group.
|
void |
addMembers(java.util.Set<AssistmentsPrincipal> members) |
java.util.Set<Group> |
getGroups(Group.GroupChildDepth childDepth) |
java.util.Set<Group> |
getGroupsContaining(AssistmentsPrincipal member,
boolean stopOnFirst)
Returns the groups containing a principal (as a member), at any level, in this group's hierarchy.
|
int |
getMemberCount(Group.GroupChildDepth childDepth)
Returns number of child members in a group.
|
(package private) java.util.Set<AssistmentsPrincipal> |
getMembers() |
java.util.Set<AssistmentsPrincipal> |
getMembers(Group.GroupChildDepth childDepth) |
java.util.Set<AssistmentsPrincipal> |
getMembers(PrincipalType pType,
Group.GroupChildDepth childDepth)
Returns the child members of this group which are of a particular Class type.
|
User |
getOwner() |
java.util.Set<User> |
getUsers(Group.GroupChildDepth childDepth)
Returns a set of
User members of this group. |
java.time.Instant |
getWhen() |
ExternalReferenceType |
getXrefType() |
boolean |
isActive() |
boolean |
isMember(AssistmentsPrincipal member,
Group.GroupChildDepth depth)
Returns whether a principal is a child of this group.
|
boolean |
removeMember(AssistmentsPrincipal member)
Removes a principal from this group.
|
(package private) void |
replaceMembers(Group g)
Replaces this Group's members with those belonging to the provided Group.
|
void |
setActive(boolean isActive) |
void |
setOwner(User owner) |
void |
setWhen(java.time.Instant when) |
java.lang.String |
toString() |
java.lang.String |
toString(java.lang.String indent)
Returns a String representation of this group's members formatted somewhat pretty.
|
asPrincipalString, compareTo, equals, getDbid, getName, getPrincipalType, isPrincipalType, setDbid, setName
asXinfoString, clearXinfo, getState, getType, getXid, getXinfo, getXref, hashCode, setXid, setXidOverride, setXinfo, setXref
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
asXinfoString, clearXinfo, equals, getPrincipalType, getType, getXid, getXinfo, getXref, hashCode, setXid, setXidOverride, setXinfo, setXref
getDbid
public Group(java.lang.String name, User owner)
public Group(java.lang.String name)
public Group(Group g)
public User getOwner()
public void setOwner(User owner)
owner
- the owner to setpublic boolean isActive()
public void setActive(boolean isActive)
public java.time.Instant getWhen()
public void setWhen(java.time.Instant when)
java.util.Set<AssistmentsPrincipal> getMembers()
public boolean addMember(AssistmentsPrincipal member) throws CycleDetectedException
member
- The ASSISTments principal to addCycleDetectedException
- When adding a group would create a cycle of groups so that attempting
to return the members of this group would be an endless. For example: Say you have two groups A and B
where
A contains B as a member, and B contains A as a member. If you add both A and B to this group an endless
cycle would be created resulting in an endless execution (or stack overflow) in #allMembers()
and addMember(AssistmentsPrincipal)
.void replaceMembers(Group g)
GroupBuilder
g
- The Group whose members become the members of this Group.public void addMembers(java.util.Set<AssistmentsPrincipal> members) throws CycleDetectedException
CycleDetectedException
public boolean removeMember(AssistmentsPrincipal member)
member
- ASSISTments principal to removepublic boolean isMember(AssistmentsPrincipal member, Group.GroupChildDepth depth)
member
- ASSISTments principal of interestchildDepth
- Specifies to search only direct members or all descendant members.public java.util.Set<User> getUsers(Group.GroupChildDepth childDepth)
User
members of this group.childDepth
- Specifies to return direct User members or all descendant User members.public java.util.Set<Group> getGroups(Group.GroupChildDepth childDepth)
public java.util.Set<AssistmentsPrincipal> getMembers(PrincipalType pType, Group.GroupChildDepth childDepth)
GroupMemberInfo
s - it does not contain subclass objects such as
User
or Group. From the set members you can obtain the member's name and persistence ID.classType
- Class of interest.childDepth
- Specifies to return direct members or all descendant members.GroupMemberInfo
public int getMemberCount(Group.GroupChildDepth childDepth)
Group.GroupChildDepth.ANY_CHILD
, the same member
appearing in more than one child group is counted multiple times.
If you are interested in unique members only, use getMembers(GroupChildDepth)
or
getMembers(PrincipalType, GroupChildDepth)
.
childDepth
- Specifies whether to count direct children of this group or all descendant
children.public java.util.Set<AssistmentsPrincipal> getMembers(Group.GroupChildDepth childDepth)
public java.util.Set<Group> getGroupsContaining(AssistmentsPrincipal member, boolean stopOnFirst)
member
- ASSISTments principal of intereststopOnFirst
- signals whether to stop and return the first group in which member was found, if any.public java.lang.String toString()
toString
in interface java.security.Principal
toString
in interface XInfo
toString
in class AssistmentsPrincipal
public java.lang.String toString(java.lang.String indent)
AssistmentsPrincipal
toString
in interface XInfo
toString
in class AssistmentsPrincipal
indent
- A String of one or more space characters to indent each level of nested groups and members.public ExternalReferenceType getXrefType()
getXrefType
in interface HasExternalReference