forked from Javacord/Javacord
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d752eed
commit 41aaffe
Showing
6 changed files
with
145 additions
and
2 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
javacord-api/src/main/java/org/javacord/api/entity/server/BulkBanResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package org.javacord.api.entity.server; | ||
|
||
import java.util.Collection; | ||
|
||
/** | ||
* The response of a bulk ban request. | ||
*/ | ||
public interface BulkBanResponse { | ||
|
||
/** | ||
* Gets the user ids that were banned successfully. | ||
* | ||
* @return The banned user ids. | ||
*/ | ||
Collection<Long> getBannedUserIds(); | ||
|
||
/** | ||
* Gets the user ids that could not be banned. | ||
* | ||
* @return The failed user ids. | ||
*/ | ||
Collection<Long> getFailedUserIds(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
javacord-core/src/main/java/org/javacord/core/entity/server/BulkBanResponseImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package org.javacord.core.entity.server; | ||
|
||
import com.fasterxml.jackson.databind.JsonNode; | ||
import org.javacord.api.entity.server.BulkBanResponse; | ||
import java.util.Collection; | ||
import java.util.Collections; | ||
import java.util.LinkedHashSet; | ||
import java.util.Set; | ||
|
||
public class BulkBanResponseImpl implements BulkBanResponse { | ||
|
||
/** | ||
* The user ids that were banned successfully. | ||
*/ | ||
private final Set<Long> bannedUserIds; | ||
|
||
/** | ||
* The user ids that could not be banned. | ||
*/ | ||
private final Set<Long> failedUserIds; | ||
|
||
/** | ||
* Create a new BulkBanResponseImpl. | ||
* | ||
* @param data The json data about this response. | ||
*/ | ||
public BulkBanResponseImpl(JsonNode data) { | ||
Set<Long> bannedUsers = new LinkedHashSet<>(); | ||
Set<Long> failedUsers = new LinkedHashSet<>(); | ||
data.get("banned_users").forEach(bannedUser -> bannedUsers.add(bannedUser.asLong())); | ||
data.get("failed_users").forEach(failedUser -> failedUsers.add(failedUser.asLong())); | ||
bannedUserIds = Collections.unmodifiableSet(bannedUsers); | ||
failedUserIds = Collections.unmodifiableSet(failedUsers); | ||
} | ||
|
||
@Override | ||
public Collection<Long> getBannedUserIds() { | ||
return bannedUserIds; | ||
} | ||
|
||
@Override | ||
public Collection<Long> getFailedUserIds() { | ||
return failedUserIds; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters