Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,21 @@ public boolean addEntry(@NotNull String entry) {
return entries.add(entry);
}

@Override
public boolean addEntries(@NotNull final Collection<String> entries) {
return this.entries.addAll(entries);
}

@Override
public boolean removeEntry(@NotNull String entry) {
return entries.remove(entry);
}

@Override
public boolean removeEntries(@NotNull final Collection<String> entries) {
return this.entries.removeAll(entries);
}

@Override
public @NotNull Component displayName() {
return displayName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,15 @@ public interface TeamDisplay {
*/
boolean addEntry(@NotNull String entry);

/**
* Adds multiple entries.
*
* @param entries entries to add
* @return whether any entry was added
* @see #entries
*/
boolean addEntries(@NotNull Collection<String> entries);

/**
* Removes an entry.
*
Expand All @@ -51,6 +60,15 @@ public interface TeamDisplay {
*/
boolean removeEntry(@NotNull String entry);

/**
* Removes multiple entries.
*
* @param entries entries to remove
* @return whether any entry was removed
* @see #entries
*/
boolean removeEntries(@NotNull Collection<String> entries);

// Properties

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,20 @@ public boolean addEntry(@NotNull String entry) {
return false;
}

@Override
public boolean addEntries(@NotNull Collection<String> entries) {
Set<String> existing = new HashSet<>(this.entries);
List<String> toAdd = new ArrayList<>(entries);
toAdd.removeIf(existing::contains);
if (!toAdd.isEmpty()) {
this.entries.addAll(toAdd);
team.teamManager().taskQueue().add(new TeamManagerTask.AddEntries(this, toAdd));
return true;
}

return false;
}

@Override
public boolean removeEntry(@NotNull String entry) {
if (entries.remove(entry)) {
Expand All @@ -77,6 +91,19 @@ public boolean removeEntry(@NotNull String entry) {
return false;
}

@Override
public boolean removeEntries(@NotNull Collection<String> entries) {
List<String> toRemove = new ArrayList<>(entries);
toRemove.retainAll(this.entries);
if (!toRemove.isEmpty()) {
this.entries.removeAll(toRemove);
team.teamManager().taskQueue().add(new TeamManagerTask.RemoveEntries(this, toRemove));
return true;
}

return false;
}

@Override
public @NotNull Component displayName() {
return displayName;
Expand Down