mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-11-24 19:55:17 +01:00
Removed generic wildcard type code smell
This commit is contained in:
parent
1f4977ae62
commit
1c29dfca6b
@ -1,4 +0,0 @@
|
||||
package world.bentobox.bentobox.api.commands.island;
|
||||
|
||||
public class IslandInfoCommand {
|
||||
}
|
@ -22,16 +22,14 @@ public class BSBConfig<T> {
|
||||
private AbstractDatabaseHandler<T> handler;
|
||||
private Logger logger;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public BSBConfig(BentoBox plugin, Class<T> type) {
|
||||
this.logger = plugin.getLogger();
|
||||
handler = (AbstractDatabaseHandler<T>) new FlatFileDatabase().getHandler(type);
|
||||
handler = new FlatFileDatabase().getHandler(type);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public BSBConfig(Addon addon, Class<T> type) {
|
||||
this.logger = addon.getLogger();
|
||||
handler = (AbstractDatabaseHandler<T>) new FlatFileDatabase().getHandler(type);
|
||||
handler = new FlatFileDatabase().getHandler(type);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -20,16 +20,14 @@ public class BSBDatabase<T> {
|
||||
private AbstractDatabaseHandler<T> handler;
|
||||
private Logger logger;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public BSBDatabase(BentoBox plugin, Class<T> type) {
|
||||
this.logger = plugin.getLogger();
|
||||
handler = (AbstractDatabaseHandler<T>) BSBDbSetup.getDatabase().getHandler(type);
|
||||
handler = BSBDbSetup.getDatabase().getHandler(type);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public BSBDatabase(Addon addon, Class<T> type) {
|
||||
this.logger = addon.getLogger();
|
||||
handler = (AbstractDatabaseHandler<T>) BSBDbSetup.getDatabase().getHandler(type);
|
||||
handler = BSBDbSetup.getDatabase().getHandler(type);
|
||||
|
||||
}
|
||||
|
||||
|
@ -35,9 +35,10 @@ public abstract class BSBDbSetup {
|
||||
|
||||
/**
|
||||
* Gets a database handler that will store and retrieve classes of type dataObjectClass
|
||||
* @param <T> - 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 <T> AbstractDatabaseHandler<T> getHandler(Class<T> dataObjectClass);
|
||||
|
||||
}
|
@ -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 <T> - Class type
|
||||
* @param type - config object type
|
||||
* @return - the config handler
|
||||
*/
|
||||
public AbstractDatabaseHandler<?> getConfig(Class<?> type) {
|
||||
public <T> AbstractDatabaseHandler<T> getConfig(Class<T> type) {
|
||||
return new ConfigHandler<>(BentoBox.getInstance(), type, new FlatFileDatabaseConnecter(BentoBox.getInstance()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> AbstractDatabaseHandler<T> getHandler(Class<T> type) {
|
||||
return new FlatFileDatabaseHandler<>(BentoBox.getInstance(), type, new FlatFileDatabaseConnecter(BentoBox.getInstance()));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ import world.bentobox.bentobox.database.DatabaseConnectionSettingsImpl;
|
||||
public class MongoDBDatabase extends BSBDbSetup{
|
||||
|
||||
@Override
|
||||
public AbstractDatabaseHandler<?> getHandler(Class<?> type) {
|
||||
public <T> AbstractDatabaseHandler<T> getHandler(Class<T> type) {
|
||||
BentoBox plugin = BentoBox.getInstance();
|
||||
// Check if the MongoDB plugin exists
|
||||
if (plugin.getServer().getPluginManager().getPlugin("BsbMongo") == null) {
|
||||
|
@ -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 <T> AbstractDatabaseHandler<T> getHandler(Class<T> type) {
|
||||
BentoBox plugin = BentoBox.getInstance();
|
||||
return new MySQLDatabaseHandler<>(plugin, type, new MySQLDatabaseConnecter(new DatabaseConnectionSettingsImpl(
|
||||
plugin.getSettings().getDbHost(),
|
||||
|
Loading…
Reference in New Issue
Block a user