Skip to content
This repository has been archived by the owner on May 4, 2022. It is now read-only.

Commit

Permalink
PT-2640-entities: added PrimaryEntityGroupManager.removeAllMembers(gr…
Browse files Browse the repository at this point in the history
…oup, members).
  • Loading branch information
itaiGershtansky authored and sdumitriu committed Feb 24, 2017
1 parent 5762c59 commit 19052a5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
Expand Up @@ -85,10 +85,19 @@ public interface PrimaryEntityGroupManager<G extends PrimaryEntity, E extends Pr
* Removes all members from a group.
*
* @param group to remove members from
* @return true if successul
* @return true if successful
*/
boolean removeAllMembers(G group);

/**
* Removes all members in {@code members} from {@code group}.
*
* @param group to remove members from
* @param members a collection of members to remove
* @return true if successful
*/
boolean removeAllMembers(G group, Collection<E> members);

/**
* Removed the member {@code member} from all the groups it is a member of.
*
Expand Down
Expand Up @@ -167,9 +167,13 @@ public boolean addToAllGroups(E member, Collection<G> groups)
@Override
public boolean removeAllMembers(G group)
{
return this.removeAllMembers(group, this.getMembers(group));
}

@Override
public boolean removeAllMembers(G group, Collection<E> members) {
boolean success = true;
Collection<E> existingMembers = this.getMembers(group);
for (E member : existingMembers) {
for (E member : members) {
if (!this.removeMember(group, member)) {
success = false;
}
Expand Down

0 comments on commit 19052a5

Please sign in to comment.