From 0c210f4877ee139685d87029d569838020357657 Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Wed, 16 Aug 2017 10:53:38 +0300 Subject: [PATCH] removed NumberFormatException, IllegalArgumentException,UnsupportedOperationException, NullPointerException throws from method signatures --- .../plan/command/commands/RegisterCommand.java | 2 +- .../com/djrapitops/plan/data/additional/PluginData.java | 3 ++- .../com/djrapitops/plan/data/analysis/GamemodePart.java | 8 +++++++- .../java/com/djrapitops/plan/data/analysis/KillPart.java | 9 ++++++++- .../main/java/com/djrapitops/plan/data/time/GMTimes.java | 2 +- .../java/com/djrapitops/plan/data/time/TimeKeeper.java | 8 +++++++- .../main/java/com/djrapitops/plan/database/Database.java | 2 +- .../djrapitops/plan/database/tables/CommandUseTable.java | 6 +++--- .../java/com/djrapitops/plan/utilities/FormatUtils.java | 2 +- .../com/djrapitops/plan/utilities/PassEncryptUtil.java | 2 +- 10 files changed, 32 insertions(+), 12 deletions(-) diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/RegisterCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/RegisterCommand.java index 38058ffa5..058c63c4f 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/RegisterCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/RegisterCommand.java @@ -70,7 +70,7 @@ public class RegisterCommand extends SubCommand { return true; } - private void consoleRegister(String[] args, ISender sender, String notEnoughArgsMsg) throws NumberFormatException, PassEncryptUtil.CannotPerformOperationException { + private void consoleRegister(String[] args, ISender sender, String notEnoughArgsMsg) throws PassEncryptUtil.CannotPerformOperationException { if (Check.isTrue(args.length >= 3, notEnoughArgsMsg, sender)) { int permLevel; permLevel = Integer.parseInt(args[2]); diff --git a/Plan/src/main/java/com/djrapitops/plan/data/additional/PluginData.java b/Plan/src/main/java/com/djrapitops/plan/data/additional/PluginData.java index ff5ce4c12..b60f3d788 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/additional/PluginData.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/additional/PluginData.java @@ -200,10 +200,11 @@ public abstract class PluginData { * @param uuid UUID of the player the value belongs to. * @return Long, Integer, Double, Boolean or String, return -1 if the player * has no value. + * @throws UnsupportedOperationException if implementing class has not overridden the method. */ public abstract Serializable getValue(UUID uuid); - public Map getValues(Collection uuids) throws UnsupportedOperationException { + public Map getValues(Collection uuids) { throw new UnsupportedOperationException("Not overridden."); } diff --git a/Plan/src/main/java/com/djrapitops/plan/data/analysis/GamemodePart.java b/Plan/src/main/java/com/djrapitops/plan/data/analysis/GamemodePart.java index 8b6d15f0b..c01e20951 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/analysis/GamemodePart.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/analysis/GamemodePart.java @@ -83,7 +83,13 @@ public class GamemodePart extends RawData { } } - public void addTo(String gm, long amount) throws IllegalArgumentException { + /** + * Adds time to a gamemode. + * @param gm Name of Gamemode + * @param amount milliseconds to add + * @throws IllegalArgumentException if gm is null + */ + public void addTo(String gm, long amount) { Verify.nullCheck(gm); switch (gm) { case "SURVIVAL": diff --git a/Plan/src/main/java/com/djrapitops/plan/data/analysis/KillPart.java b/Plan/src/main/java/com/djrapitops/plan/data/analysis/KillPart.java index 68e93e54d..39103b039 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/analysis/KillPart.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/analysis/KillPart.java @@ -48,7 +48,14 @@ public class KillPart extends RawData { addValue("avgplayerkills", MathUtils.averageLong(playerKillAmount, playerCount)); } - public void addKills(UUID uuid, List kills) throws IllegalArgumentException { + /** + * Adds kills to the dataset. + * + * @param uuid Player whose kills are being added + * @param kills all kills of a player + * @throws IllegalArgumentException if kills is null + */ + public void addKills(UUID uuid, List kills) { Verify.nullCheck(kills); playerKills.put(uuid, kills); } diff --git a/Plan/src/main/java/com/djrapitops/plan/data/time/GMTimes.java b/Plan/src/main/java/com/djrapitops/plan/data/time/GMTimes.java index f5e5cf38e..6d2495b97 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/time/GMTimes.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/time/GMTimes.java @@ -45,7 +45,7 @@ public class GMTimes extends TimeKeeper { * @param times 1-4 time parameters. * @throws IllegalArgumentException If any parameter is null. */ - public void setAllGMTimes(long... times) throws IllegalArgumentException { + public void setAllGMTimes(long... times) { Verify.nullCheck(times); String[] gms = GMTimesTable.getGMKeyArray(); int size = times.length; diff --git a/Plan/src/main/java/com/djrapitops/plan/data/time/TimeKeeper.java b/Plan/src/main/java/com/djrapitops/plan/data/time/TimeKeeper.java index 44d4cd5d6..36b2399d4 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/time/TimeKeeper.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/time/TimeKeeper.java @@ -44,7 +44,13 @@ public abstract class TimeKeeper { this(new HashMap<>()); } - public void setTime(String state, long time) throws IllegalArgumentException { + /** + * Sets a specific time for a state. + * @param state State to set + * @param time Time in ms the state has been active for + * @throws IllegalArgumentException If given state is null + */ + public void setTime(String state, long time) { times.put(Verify.nullCheck(state), time); } diff --git a/Plan/src/main/java/com/djrapitops/plan/database/Database.java b/Plan/src/main/java/com/djrapitops/plan/database/Database.java index 4c187e7e5..d9303e43b 100644 --- a/Plan/src/main/java/com/djrapitops/plan/database/Database.java +++ b/Plan/src/main/java/com/djrapitops/plan/database/Database.java @@ -255,7 +255,7 @@ public abstract class Database { * @throws SQLException If a database error occurs. * @throws NullPointerException If the database has not initialized tables. */ - public void saveCommandUse(Map data) throws SQLException, NullPointerException { + public void saveCommandUse(Map data) throws SQLException { commandUseTable.saveCommandUse(data); } diff --git a/Plan/src/main/java/com/djrapitops/plan/database/tables/CommandUseTable.java b/Plan/src/main/java/com/djrapitops/plan/database/tables/CommandUseTable.java index cef699ea0..c962d3a0d 100644 --- a/Plan/src/main/java/com/djrapitops/plan/database/tables/CommandUseTable.java +++ b/Plan/src/main/java/com/djrapitops/plan/database/tables/CommandUseTable.java @@ -1,5 +1,6 @@ package main.java.com.djrapitops.plan.database.tables; +import com.djrapitops.plugin.utilities.Verify; import main.java.com.djrapitops.plan.Log; import main.java.com.djrapitops.plan.database.databases.SQLDB; import main.java.com.djrapitops.plan.utilities.Benchmark; @@ -77,10 +78,9 @@ public class CommandUseTable extends Table { /** * @param data * @throws SQLException - * @throws NullPointerException */ - public void saveCommandUse(Map data) throws SQLException, NullPointerException { - if (data.isEmpty()) { + public void saveCommandUse(Map data) throws SQLException { + if (Verify.isEmpty(data)) { return; } diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/FormatUtils.java b/Plan/src/main/java/com/djrapitops/plan/utilities/FormatUtils.java index aeac55a84..b313d517f 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/FormatUtils.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/FormatUtils.java @@ -150,7 +150,7 @@ public class FormatUtils { * @return parsed double - for example 1,11 * @throws NumberFormatException When wrong format */ - public static int parseVersionNumber(String versionString) throws NumberFormatException { + public static int parseVersionNumber(String versionString) { return FormattingUtils.parseVersionNumber(versionString); } diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/PassEncryptUtil.java b/Plan/src/main/java/com/djrapitops/plan/utilities/PassEncryptUtil.java index 8a162e971..cbb1a4db2 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/PassEncryptUtil.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/PassEncryptUtil.java @@ -158,7 +158,7 @@ public class PassEncryptUtil { } } - private static byte[] fromBase64(String hex) throws IllegalArgumentException { + private static byte[] fromBase64(String hex) { return DatatypeConverter.parseBase64Binary(hex); }