From 1c29dfca6b44a4e99340cd1db789b74ad3333a68 Mon Sep 17 00:00:00 2001 From: tastybento Date: Fri, 3 Aug 2018 21:02:55 -0700 Subject: [PATCH] Removed generic wildcard type code smell --- .../api/commands/island/IslandInfoCommand.java | 4 ---- .../bentobox/api/configuration/BSBConfig.java | 6 ++---- .../bentobox/bentobox/database/BSBDatabase.java | 6 ++---- .../bentobox/bentobox/database/BSBDbSetup.java | 5 +++-- .../database/flatfile/FlatFileDatabase.java | 13 +++++++------ .../bentobox/database/mongodb/MongoDBDatabase.java | 2 +- .../bentobox/database/mysql/MySQLDatabase.java | 6 +++++- 7 files changed, 20 insertions(+), 22 deletions(-) delete mode 100644 src/main/java/world/bentobox/bentobox/api/commands/island/IslandInfoCommand.java diff --git a/src/main/java/world/bentobox/bentobox/api/commands/island/IslandInfoCommand.java b/src/main/java/world/bentobox/bentobox/api/commands/island/IslandInfoCommand.java deleted file mode 100644 index f23053a4a..000000000 --- a/src/main/java/world/bentobox/bentobox/api/commands/island/IslandInfoCommand.java +++ /dev/null @@ -1,4 +0,0 @@ -package world.bentobox.bentobox.api.commands.island; - -public class IslandInfoCommand { -} diff --git a/src/main/java/world/bentobox/bentobox/api/configuration/BSBConfig.java b/src/main/java/world/bentobox/bentobox/api/configuration/BSBConfig.java index 2c2ada88e..826f3a955 100644 --- a/src/main/java/world/bentobox/bentobox/api/configuration/BSBConfig.java +++ b/src/main/java/world/bentobox/bentobox/api/configuration/BSBConfig.java @@ -22,16 +22,14 @@ public class BSBConfig { private AbstractDatabaseHandler handler; private Logger logger; - @SuppressWarnings("unchecked") public BSBConfig(BentoBox plugin, Class type) { this.logger = plugin.getLogger(); - handler = (AbstractDatabaseHandler) new FlatFileDatabase().getHandler(type); + handler = new FlatFileDatabase().getHandler(type); } - @SuppressWarnings("unchecked") public BSBConfig(Addon addon, Class type) { this.logger = addon.getLogger(); - handler = (AbstractDatabaseHandler) new FlatFileDatabase().getHandler(type); + handler = new FlatFileDatabase().getHandler(type); } /** diff --git a/src/main/java/world/bentobox/bentobox/database/BSBDatabase.java b/src/main/java/world/bentobox/bentobox/database/BSBDatabase.java index 0363a38ef..149eee9ad 100644 --- a/src/main/java/world/bentobox/bentobox/database/BSBDatabase.java +++ b/src/main/java/world/bentobox/bentobox/database/BSBDatabase.java @@ -20,16 +20,14 @@ public class BSBDatabase { private AbstractDatabaseHandler handler; private Logger logger; - @SuppressWarnings("unchecked") public BSBDatabase(BentoBox plugin, Class type) { this.logger = plugin.getLogger(); - handler = (AbstractDatabaseHandler) BSBDbSetup.getDatabase().getHandler(type); + handler = BSBDbSetup.getDatabase().getHandler(type); } - @SuppressWarnings("unchecked") public BSBDatabase(Addon addon, Class type) { this.logger = addon.getLogger(); - handler = (AbstractDatabaseHandler) BSBDbSetup.getDatabase().getHandler(type); + handler = BSBDbSetup.getDatabase().getHandler(type); } diff --git a/src/main/java/world/bentobox/bentobox/database/BSBDbSetup.java b/src/main/java/world/bentobox/bentobox/database/BSBDbSetup.java index 6ea1e1009..a82ecde96 100644 --- a/src/main/java/world/bentobox/bentobox/database/BSBDbSetup.java +++ b/src/main/java/world/bentobox/bentobox/database/BSBDbSetup.java @@ -25,7 +25,7 @@ public abstract class BSBDbSetup { FLATFILE(new FlatFileDatabase()), MYSQL(new MySQLDatabase()), MONGO(new MongoDBDatabase()); - + BSBDbSetup database; DatabaseType(BSBDbSetup database){ @@ -35,9 +35,10 @@ public abstract class BSBDbSetup { /** * Gets a database handler that will store and retrieve classes of type dataObjectClass + * @param - Class type * @param dataObjectClass - class of the object to be stored in the database * @return handler for this database object */ - public abstract AbstractDatabaseHandler getHandler(Class dataObjectClass); + public abstract AbstractDatabaseHandler getHandler(Class dataObjectClass); } \ No newline at end of file diff --git a/src/main/java/world/bentobox/bentobox/database/flatfile/FlatFileDatabase.java b/src/main/java/world/bentobox/bentobox/database/flatfile/FlatFileDatabase.java index 00a7cbf4f..51fb45af5 100644 --- a/src/main/java/world/bentobox/bentobox/database/flatfile/FlatFileDatabase.java +++ b/src/main/java/world/bentobox/bentobox/database/flatfile/FlatFileDatabase.java @@ -6,18 +6,19 @@ import world.bentobox.bentobox.database.BSBDbSetup; public class FlatFileDatabase extends BSBDbSetup{ - @Override - public AbstractDatabaseHandler getHandler(Class type) { - return new FlatFileDatabaseHandler<>(BentoBox.getInstance(), type, new FlatFileDatabaseConnecter(BentoBox.getInstance())); - } - /** * Get the config + * @param - Class type * @param type - config object type * @return - the config handler */ - public AbstractDatabaseHandler getConfig(Class type) { + public AbstractDatabaseHandler getConfig(Class type) { return new ConfigHandler<>(BentoBox.getInstance(), type, new FlatFileDatabaseConnecter(BentoBox.getInstance())); } + @Override + public AbstractDatabaseHandler getHandler(Class type) { + return new FlatFileDatabaseHandler<>(BentoBox.getInstance(), type, new FlatFileDatabaseConnecter(BentoBox.getInstance())); + } + } diff --git a/src/main/java/world/bentobox/bentobox/database/mongodb/MongoDBDatabase.java b/src/main/java/world/bentobox/bentobox/database/mongodb/MongoDBDatabase.java index 97a302493..75ba6b658 100644 --- a/src/main/java/world/bentobox/bentobox/database/mongodb/MongoDBDatabase.java +++ b/src/main/java/world/bentobox/bentobox/database/mongodb/MongoDBDatabase.java @@ -8,7 +8,7 @@ import world.bentobox.bentobox.database.DatabaseConnectionSettingsImpl; public class MongoDBDatabase extends BSBDbSetup{ @Override - public AbstractDatabaseHandler getHandler(Class type) { + public AbstractDatabaseHandler getHandler(Class type) { BentoBox plugin = BentoBox.getInstance(); // Check if the MongoDB plugin exists if (plugin.getServer().getPluginManager().getPlugin("BsbMongo") == null) { diff --git a/src/main/java/world/bentobox/bentobox/database/mysql/MySQLDatabase.java b/src/main/java/world/bentobox/bentobox/database/mysql/MySQLDatabase.java index 3134156eb..5fbe5e7c1 100644 --- a/src/main/java/world/bentobox/bentobox/database/mysql/MySQLDatabase.java +++ b/src/main/java/world/bentobox/bentobox/database/mysql/MySQLDatabase.java @@ -7,8 +7,12 @@ import world.bentobox.bentobox.database.DatabaseConnectionSettingsImpl; public class MySQLDatabase extends BSBDbSetup{ + + /* (non-Javadoc) + * @see world.bentobox.bentobox.database.BSBDbSetup#getHandler(java.lang.Class) + */ @Override - public AbstractDatabaseHandler getHandler(Class type) { + public AbstractDatabaseHandler getHandler(Class type) { BentoBox plugin = BentoBox.getInstance(); return new MySQLDatabaseHandler<>(plugin, type, new MySQLDatabaseConnecter(new DatabaseConnectionSettingsImpl( plugin.getSettings().getDbHost(),