Improved quality of method argument checks.
This commit is contained in:
@@ -80,7 +80,7 @@ public final class TrackScheduler extends AudioEventAdapter {
|
||||
}
|
||||
|
||||
public final void removeFromQueue(final int index) {
|
||||
Checks.notNull(index, "Index");
|
||||
Checks.positive(index, "Index");
|
||||
|
||||
logger.info("Track '" + queue.remove(index).getTrack().getInfo().title + "' has been removed from the queue in "
|
||||
+ this.guild.getName() + " (" + this.guild.getId() + ").");
|
||||
@@ -110,8 +110,6 @@ public final class TrackScheduler extends AudioEventAdapter {
|
||||
}
|
||||
|
||||
public final void setQueueLocked(final boolean locked) {
|
||||
Checks.notNull(locked, "Locked");
|
||||
|
||||
this.queueLocked = locked;
|
||||
}
|
||||
|
||||
@@ -124,6 +122,8 @@ public final class TrackScheduler extends AudioEventAdapter {
|
||||
}
|
||||
|
||||
public final int occupiedSlotCount(Member member) {
|
||||
Checks.notNull(member, "Member");
|
||||
|
||||
int count = 0;
|
||||
for (RequestedTrack requestedTrack : this.queue) {
|
||||
if (requestedTrack.getRequester().equals(member)) {
|
||||
|
||||
@@ -44,8 +44,8 @@ public final class CommandResponse {
|
||||
private TimeUnit deletionDelayUnit, expireDelayUnit;
|
||||
|
||||
public CommandResponse(final String emoji, final String response) {
|
||||
Checks.notNull(emoji, "Emoji");
|
||||
Checks.notNull(response, "Response");
|
||||
Checks.notEmpty(emoji, "Emoji");
|
||||
Checks.notEmpty(response, "Response");
|
||||
|
||||
this.emoji = EmojiManager.getForAlias(emoji);
|
||||
this.response = response;
|
||||
@@ -59,7 +59,7 @@ public final class CommandResponse {
|
||||
}
|
||||
|
||||
public final CommandResponse setDeletionDelay(final long delay, final TimeUnit unit) {
|
||||
Checks.notNull(delay, "Delay");
|
||||
Checks.positive(delay, "Delay");
|
||||
Checks.notNull(unit, "Unit");
|
||||
|
||||
this.deletionDelay = delay;
|
||||
@@ -68,7 +68,7 @@ public final class CommandResponse {
|
||||
}
|
||||
|
||||
public final CommandResponse addReactionCallback(final String emoji, final ReactionCallback callback) {
|
||||
Checks.notNull(emoji, "Emoji");
|
||||
Checks.notEmpty(emoji, "Emoji");
|
||||
Checks.notNull(callback, "Callback");
|
||||
|
||||
this.callbacks.put(EmojiManager.getForAlias(emoji), callback);
|
||||
@@ -83,7 +83,7 @@ public final class CommandResponse {
|
||||
}
|
||||
|
||||
public final CommandResponse setReactionCallbackExpireDelay(final long delay, final TimeUnit unit) {
|
||||
Checks.notNull(delay, "Delay");
|
||||
Checks.positive(delay, "Delay");
|
||||
Checks.notNull(unit, "Unit");
|
||||
|
||||
this.expireDelay = delay;
|
||||
|
||||
@@ -132,7 +132,6 @@ public final class AudioUtil {
|
||||
|
||||
public static final void setPausedState(final Guild guild, final boolean pausedState) {
|
||||
Checks.notNull(guild, "Guild");
|
||||
Checks.notNull(pausedState, "Paused state");
|
||||
|
||||
guild.getAudioManager().setSelfMuted(pausedState);
|
||||
players.get(guild.getIdLong()).setPaused(pausedState);
|
||||
@@ -166,7 +165,7 @@ public final class AudioUtil {
|
||||
}
|
||||
|
||||
public static final void findTrack(final String query, final Member requester, final TextChannel channel) {
|
||||
Checks.notNull(query, "Query");
|
||||
Checks.notEmpty(query, "Query");
|
||||
Checks.notNull(requester, "Requester");
|
||||
Checks.notNull(channel, "Channel");
|
||||
|
||||
|
||||
@@ -72,7 +72,8 @@ public final class ReactionCallbackManager {
|
||||
|
||||
public static final void executeCallback(final long messageID, final TextChannel channel, final Member reactor,
|
||||
final String emoji) {
|
||||
Checks.notNull(messageID, "Message ID");
|
||||
Checks.positive(messageID, "Message ID");
|
||||
Checks.notNull(channel, "Channel");
|
||||
Checks.notNull(reactor, "Reactor");
|
||||
Checks.notEmpty(emoji, "Emoji");
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ public final class Scheduler {
|
||||
|
||||
public static final ScheduledFuture<?> schedule(final Runnable runnable, final long delay, final TimeUnit unit) {
|
||||
Checks.notNull(runnable, "Runnable");
|
||||
Checks.notNull(delay, "Delay");
|
||||
Checks.positive(delay, "Delay");
|
||||
Checks.notNull(unit, "Unit");
|
||||
|
||||
return pool.schedule(runnable, delay, unit);
|
||||
@@ -39,8 +39,8 @@ public final class Scheduler {
|
||||
public static final ScheduledFuture<?> scheduleRepeating(final Runnable runnable, final long initialDelay,
|
||||
final long period, final TimeUnit unit) {
|
||||
Checks.notNull(runnable, "Runnable");
|
||||
Checks.notNull(initialDelay, "Initial delay");
|
||||
Checks.notNull(period, "Period");
|
||||
Checks.positive(initialDelay, "Initial delay");
|
||||
Checks.positive(period, "Period");
|
||||
Checks.notNull(unit, "Unit");
|
||||
|
||||
return pool.scheduleAtFixedRate(runnable, initialDelay, period, unit);
|
||||
|
||||
@@ -81,7 +81,7 @@ public final class StringUtil {
|
||||
}
|
||||
|
||||
public static final String formatTime(final long milliseconds) {
|
||||
Checks.notNull(milliseconds, "Milliseconds");
|
||||
Checks.positive(milliseconds, "Milliseconds");
|
||||
|
||||
final long second = (milliseconds / 1000) % 60;
|
||||
final long minute = (milliseconds / (1000 * 60)) % 60;
|
||||
|
||||
@@ -65,7 +65,6 @@ public final class TrackUtil {
|
||||
|
||||
public static final MessageEmbed trackListInfoEmbed(final List<RequestedTrack> tracks, final boolean numbered) {
|
||||
Checks.notNull(tracks, "Tracks");
|
||||
Checks.notNull(numbered, "Numbered");
|
||||
|
||||
final EmbedBuilder builder = new EmbedBuilder();
|
||||
for (int i = 0; i < tracks.size(); i++) {
|
||||
@@ -94,7 +93,6 @@ public final class TrackUtil {
|
||||
|
||||
public static final MessageEmbed pagedTrackListInfoEmbed(final List<RequestedTrack> tracks, int page) {
|
||||
Checks.notNull(tracks, "Tracks");
|
||||
Checks.notNull(page, "Page");
|
||||
|
||||
final EmbedBuilder builder = new EmbedBuilder();
|
||||
if (page < 1) {
|
||||
@@ -124,7 +122,6 @@ public final class TrackUtil {
|
||||
|
||||
public static final boolean doesGreaterPageExist(final List<RequestedTrack> tracks, int page) {
|
||||
Checks.notNull(tracks, "Tracks");
|
||||
Checks.notNull(page, "Page");
|
||||
|
||||
final int pages = (int) Math.ceil(tracks.size() / 10d);
|
||||
return (page < pages);
|
||||
|
||||
Reference in New Issue
Block a user