Skip to content

Commit

Permalink
Add utility methods Client#isInServerGroup(int) and Client#isInServer…
Browse files Browse the repository at this point in the history
…Group(ServerGroup).
  • Loading branch information
rogermb committed Mar 31, 2016
1 parent 3f78c6f commit 0a8aa43
Showing 1 changed file with 32 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,38 @@ public boolean isChannelCommander() {
return getBoolean(ClientProperty.CLIENT_IS_CHANNEL_COMMANDER);
}

/**
* Utility method that does a linear search on the array of server group IDs returned
* by {@link #getServerGroups()} and returns {@code true} if that array contains
* the given server group ID.
*
* @param serverGroupId
* the ID of the server group to search for
*
* @return whether this client is a member of the given server group
*/
public boolean isInServerGroup(int serverGroupId) {
int[] serverGroupIds = getServerGroups();
for (int s : serverGroupIds) {
if (s == serverGroupId) return true;
}
return false;
}

/**
* Utility method that does a linear search on the array of server group IDs returned
* by {@link #getServerGroups()} and returns {@code true} if that array contains
* the ID of the given server group.
*
* @param serverGroup
* the server group to search for
*
* @return whether this client is a member of the given server group
*/
public boolean isInServerGroup(ServerGroup serverGroup) {
return isInServerGroup(serverGroup.getId());
}

public boolean isInputHardware() {
return getBoolean(ClientProperty.CLIENT_INPUT_HARDWARE);
}
Expand Down

0 comments on commit 0a8aa43

Please sign in to comment.