mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-11-28 13:45:14 +01:00
BREAKING: Renamed [...]DatabaseConnecter to [...]DatabaseConnector
It was a typo shown by IntelliJ
This commit is contained in:
parent
5fa8f3997f
commit
cfbf3df1c3
@ -25,7 +25,7 @@ public abstract class AbstractDatabaseHandler<T> {
|
||||
* Contains the settings to create a connection to the database like
|
||||
* host/port/database/user/password
|
||||
*/
|
||||
protected DatabaseConnecter databaseConnecter;
|
||||
protected DatabaseConnector databaseConnector;
|
||||
|
||||
protected BentoBox plugin;
|
||||
|
||||
@ -35,13 +35,13 @@ public abstract class AbstractDatabaseHandler<T> {
|
||||
* @param type
|
||||
* The type of the objects that should be created and filled with
|
||||
* values from the database or inserted into the database
|
||||
* @param databaseConnecter
|
||||
* @param databaseConnector
|
||||
* Contains the settings to create a connection to the database
|
||||
* like host/port/database/user/password
|
||||
*/
|
||||
protected AbstractDatabaseHandler(BentoBox plugin, Class<T> type, DatabaseConnecter databaseConnecter) {
|
||||
protected AbstractDatabaseHandler(BentoBox plugin, Class<T> type, DatabaseConnector databaseConnector) {
|
||||
this.plugin = plugin;
|
||||
this.databaseConnecter = databaseConnecter;
|
||||
this.databaseConnector = databaseConnector;
|
||||
this.dataObject = type;
|
||||
}
|
||||
|
||||
|
@ -9,7 +9,7 @@ import org.bukkit.configuration.file.YamlConfiguration;
|
||||
* Creates a connection to a database.
|
||||
*
|
||||
*/
|
||||
public interface DatabaseConnecter {
|
||||
public interface DatabaseConnector {
|
||||
|
||||
/**
|
||||
* Establishes a new connection to the database
|
@ -4,7 +4,7 @@ import java.beans.IntrospectionException;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
import world.bentobox.bentobox.BentoBox;
|
||||
import world.bentobox.bentobox.database.DatabaseConnecter;
|
||||
import world.bentobox.bentobox.database.DatabaseConnector;
|
||||
|
||||
/**
|
||||
* Class handles config settings saving and loading
|
||||
@ -16,8 +16,8 @@ import world.bentobox.bentobox.database.DatabaseConnecter;
|
||||
|
||||
public class ConfigHandler<T> extends FlatFileDatabaseHandler<T> {
|
||||
|
||||
public ConfigHandler(BentoBox plugin, Class<T> type, DatabaseConnecter databaseConnecter) {
|
||||
super(plugin, type, databaseConnecter);
|
||||
public ConfigHandler(BentoBox plugin, Class<T> type, DatabaseConnector databaseConnector) {
|
||||
super(plugin, type, databaseConnector);
|
||||
}
|
||||
|
||||
public void saveSettings(T instance) throws IllegalAccessException, InvocationTargetException, IntrospectionException {
|
||||
|
@ -13,12 +13,12 @@ public class FlatFileDatabase extends DatabaseSetup {
|
||||
* @return - the config handler
|
||||
*/
|
||||
public <T> AbstractDatabaseHandler<T> getConfig(Class<T> type) {
|
||||
return new ConfigHandler<>(BentoBox.getInstance(), type, new FlatFileDatabaseConnecter(BentoBox.getInstance()));
|
||||
return new ConfigHandler<>(BentoBox.getInstance(), type, new FlatFileDatabaseConnector(BentoBox.getInstance()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> AbstractDatabaseHandler<T> getHandler(Class<T> type) {
|
||||
return new FlatFileDatabaseHandler<>(BentoBox.getInstance(), type, new FlatFileDatabaseConnecter(BentoBox.getInstance()));
|
||||
return new FlatFileDatabaseHandler<>(BentoBox.getInstance(), type, new FlatFileDatabaseConnector(BentoBox.getInstance()));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -15,9 +15,9 @@ import java.util.UUID;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import world.bentobox.bentobox.BentoBox;
|
||||
import world.bentobox.bentobox.database.DatabaseConnecter;
|
||||
import world.bentobox.bentobox.database.DatabaseConnector;
|
||||
|
||||
public class FlatFileDatabaseConnecter implements DatabaseConnecter {
|
||||
public class FlatFileDatabaseConnector implements DatabaseConnector {
|
||||
|
||||
private static final int MAX_LOOPS = 100;
|
||||
private static final String DATABASE_FOLDER_NAME = "database";
|
||||
@ -25,7 +25,7 @@ public class FlatFileDatabaseConnecter implements DatabaseConnecter {
|
||||
private File dataFolder;
|
||||
|
||||
|
||||
public FlatFileDatabaseConnecter(BentoBox plugin) {
|
||||
public FlatFileDatabaseConnector(BentoBox plugin) {
|
||||
this.plugin = plugin;
|
||||
dataFolder = new File(plugin.getDataFolder(), DATABASE_FOLDER_NAME);
|
||||
}
|
@ -33,7 +33,7 @@ import world.bentobox.bentobox.api.configuration.ConfigEntry;
|
||||
import world.bentobox.bentobox.api.configuration.StoreAt;
|
||||
import world.bentobox.bentobox.api.localization.TextVariables;
|
||||
import world.bentobox.bentobox.database.AbstractDatabaseHandler;
|
||||
import world.bentobox.bentobox.database.DatabaseConnecter;
|
||||
import world.bentobox.bentobox.database.DatabaseConnector;
|
||||
import world.bentobox.bentobox.database.objects.adapters.Adapter;
|
||||
import world.bentobox.bentobox.database.objects.adapters.AdapterInterface;
|
||||
import world.bentobox.bentobox.util.Util;
|
||||
@ -52,8 +52,8 @@ public class FlatFileDatabaseHandler<T> extends AbstractDatabaseHandler<T> {
|
||||
private static final String DATABASE_FOLDER_NAME = "database";
|
||||
protected boolean configFlag;
|
||||
|
||||
public FlatFileDatabaseHandler(BentoBox plugin, Class<T> type, DatabaseConnecter dbConnecter) {
|
||||
super(plugin, type, dbConnecter);
|
||||
public FlatFileDatabaseHandler(BentoBox plugin, Class<T> type, DatabaseConnector databaseConnector) {
|
||||
super(plugin, type, databaseConnector);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -65,13 +65,13 @@ public class FlatFileDatabaseHandler<T> extends AbstractDatabaseHandler<T> {
|
||||
path = storeAt.path();
|
||||
fileName = storeAt.filename();
|
||||
}
|
||||
YamlConfiguration config = databaseConnecter.loadYamlFile(path, fileName);
|
||||
YamlConfiguration config = databaseConnector.loadYamlFile(path, fileName);
|
||||
return createObject(config);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean objectExists(String uniqueId) {
|
||||
return databaseConnecter.uniqueIdExists(dataObject.getSimpleName(), uniqueId);
|
||||
return databaseConnector.uniqueIdExists(dataObject.getSimpleName(), uniqueId);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -94,7 +94,7 @@ public class FlatFileDatabaseHandler<T> extends AbstractDatabaseHandler<T> {
|
||||
if (storeAt != null) {
|
||||
fileName = storeAt.filename();
|
||||
}
|
||||
YamlConfiguration config = databaseConnecter.loadYamlFile(DATABASE_FOLDER_NAME + File.separator + dataObject.getSimpleName(), fileName);
|
||||
YamlConfiguration config = databaseConnector.loadYamlFile(DATABASE_FOLDER_NAME + File.separator + dataObject.getSimpleName(), fileName);
|
||||
list.add(createObject(config));
|
||||
}
|
||||
return list;
|
||||
@ -317,7 +317,7 @@ public class FlatFileDatabaseHandler<T> extends AbstractDatabaseHandler<T> {
|
||||
// If the object does not have a unique name assigned to it already, one is created at random
|
||||
String id = (String)value;
|
||||
if (value == null || id.isEmpty()) {
|
||||
id = databaseConnecter.getUniqueId(dataObject.getSimpleName());
|
||||
id = databaseConnector.getUniqueId(dataObject.getSimpleName());
|
||||
// Set it in the class so that it will be used next time
|
||||
propertyDescriptor.getWriteMethod().invoke(instance, id);
|
||||
}
|
||||
@ -359,7 +359,7 @@ public class FlatFileDatabaseHandler<T> extends AbstractDatabaseHandler<T> {
|
||||
throw new IllegalArgumentException("No uniqueId in class");
|
||||
}
|
||||
|
||||
databaseConnecter.saveYamlFile(config, path, filename, yamlComments);
|
||||
databaseConnector.saveYamlFile(config, path, filename, yamlComments);
|
||||
}
|
||||
|
||||
private void setComment(ConfigComment comment, YamlConfiguration config, Map<String, String> yamlComments, String parent) {
|
||||
|
@ -17,7 +17,7 @@ public class MongoDBDatabase extends DatabaseSetup {
|
||||
plugin.getServer().getPluginManager().disablePlugin(plugin);
|
||||
return null;
|
||||
}
|
||||
return new MongoDBDatabaseHandler<>(plugin, type, new MongoDBDatabaseConnecter(new DatabaseConnectionSettingsImpl(
|
||||
return new MongoDBDatabaseHandler<>(plugin, type, new MongoDBDatabaseConnector(new DatabaseConnectionSettingsImpl(
|
||||
plugin.getSettings().getDbHost(),
|
||||
plugin.getSettings().getDbPort(),
|
||||
plugin.getSettings().getDbName(),
|
||||
|
@ -10,10 +10,10 @@ import com.mongodb.MongoCredential;
|
||||
import com.mongodb.ServerAddress;
|
||||
import com.mongodb.client.MongoDatabase;
|
||||
|
||||
import world.bentobox.bentobox.database.DatabaseConnecter;
|
||||
import world.bentobox.bentobox.database.DatabaseConnector;
|
||||
import world.bentobox.bentobox.database.DatabaseConnectionSettingsImpl;
|
||||
|
||||
public class MongoDBDatabaseConnecter implements DatabaseConnecter {
|
||||
public class MongoDBDatabaseConnector implements DatabaseConnector {
|
||||
|
||||
private MongoClient client;
|
||||
private DatabaseConnectionSettingsImpl dbSettings;
|
||||
@ -22,7 +22,7 @@ public class MongoDBDatabaseConnecter implements DatabaseConnecter {
|
||||
* Class for MySQL database connections using the settings provided
|
||||
* @param dbSettings - database settings
|
||||
*/
|
||||
public MongoDBDatabaseConnecter(DatabaseConnectionSettingsImpl dbSettings) {
|
||||
public MongoDBDatabaseConnector(DatabaseConnectionSettingsImpl dbSettings) {
|
||||
this.dbSettings = dbSettings;
|
||||
MongoCredential credential = MongoCredential.createCredential(dbSettings.getUsername(),
|
||||
dbSettings.getDatabaseName(),
|
@ -21,7 +21,7 @@ import com.mongodb.util.JSON;
|
||||
import world.bentobox.bentobox.BentoBox;
|
||||
import world.bentobox.bentobox.api.flags.Flag;
|
||||
import world.bentobox.bentobox.database.AbstractDatabaseHandler;
|
||||
import world.bentobox.bentobox.database.DatabaseConnecter;
|
||||
import world.bentobox.bentobox.database.DatabaseConnector;
|
||||
import world.bentobox.bentobox.database.mysql.adapters.FlagAdapter;
|
||||
import world.bentobox.bentobox.database.mysql.adapters.LocationAdapter;
|
||||
import world.bentobox.bentobox.database.mysql.adapters.PotionEffectTypeAdapter;
|
||||
@ -43,7 +43,7 @@ public class MongoDBDatabaseHandler<T> extends AbstractDatabaseHandler<T> {
|
||||
private static final String MONGO_ID = "_id";
|
||||
|
||||
private MongoCollection<Document> collection;
|
||||
private DatabaseConnecter dbConnecter;
|
||||
private DatabaseConnector dbConnecter;
|
||||
|
||||
|
||||
/**
|
||||
@ -53,7 +53,7 @@ public class MongoDBDatabaseHandler<T> extends AbstractDatabaseHandler<T> {
|
||||
* @param type - the type of class to be stored in the database. Must inherit DataObject
|
||||
* @param dbConnecter - authentication details for the database
|
||||
*/
|
||||
public MongoDBDatabaseHandler(BentoBox plugin, Class<T> type, DatabaseConnecter dbConnecter) {
|
||||
public MongoDBDatabaseHandler(BentoBox plugin, Class<T> type, DatabaseConnector dbConnecter) {
|
||||
super(plugin, type, dbConnecter);
|
||||
this.dbConnecter = dbConnecter;
|
||||
/*
|
||||
|
@ -14,7 +14,7 @@ public class MySQLDatabase extends DatabaseSetup {
|
||||
@Override
|
||||
public <T> AbstractDatabaseHandler<T> getHandler(Class<T> type) {
|
||||
BentoBox plugin = BentoBox.getInstance();
|
||||
return new MySQLDatabaseHandler<>(plugin, type, new MySQLDatabaseConnecter(new DatabaseConnectionSettingsImpl(
|
||||
return new MySQLDatabaseHandler<>(plugin, type, new MySQLDatabaseConnector(new DatabaseConnectionSettingsImpl(
|
||||
plugin.getSettings().getDbHost(),
|
||||
plugin.getSettings().getDbPort(),
|
||||
plugin.getSettings().getDbName(),
|
||||
|
@ -8,10 +8,10 @@ import java.util.Map;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import world.bentobox.bentobox.database.DatabaseConnecter;
|
||||
import world.bentobox.bentobox.database.DatabaseConnector;
|
||||
import world.bentobox.bentobox.database.DatabaseConnectionSettingsImpl;
|
||||
|
||||
public class MySQLDatabaseConnecter implements DatabaseConnecter {
|
||||
public class MySQLDatabaseConnector implements DatabaseConnector {
|
||||
|
||||
private String connectionUrl;
|
||||
private DatabaseConnectionSettingsImpl dbSettings;
|
||||
@ -21,7 +21,7 @@ public class MySQLDatabaseConnecter implements DatabaseConnecter {
|
||||
* Class for MySQL database connections using the settings provided
|
||||
* @param dbSettings - database settings
|
||||
*/
|
||||
public MySQLDatabaseConnecter(DatabaseConnectionSettingsImpl dbSettings) {
|
||||
public MySQLDatabaseConnector(DatabaseConnectionSettingsImpl dbSettings) {
|
||||
this.dbSettings = dbSettings;
|
||||
try {
|
||||
Class.forName("com.mysql.jdbc.Driver").newInstance();
|
@ -19,7 +19,7 @@ import com.google.gson.GsonBuilder;
|
||||
import world.bentobox.bentobox.BentoBox;
|
||||
import world.bentobox.bentobox.api.flags.Flag;
|
||||
import world.bentobox.bentobox.database.AbstractDatabaseHandler;
|
||||
import world.bentobox.bentobox.database.DatabaseConnecter;
|
||||
import world.bentobox.bentobox.database.DatabaseConnector;
|
||||
import world.bentobox.bentobox.database.mysql.adapters.FlagAdapter;
|
||||
import world.bentobox.bentobox.database.mysql.adapters.LocationAdapter;
|
||||
import world.bentobox.bentobox.database.mysql.adapters.PotionEffectTypeAdapter;
|
||||
@ -49,7 +49,7 @@ public class MySQLDatabaseHandler<T> extends AbstractDatabaseHandler<T> {
|
||||
* @param type - the type of class to be stored in the database. Must inherit DataObject
|
||||
* @param dbConnecter - authentication details for the database
|
||||
*/
|
||||
public MySQLDatabaseHandler(BentoBox plugin, Class<T> type, DatabaseConnecter dbConnecter) {
|
||||
public MySQLDatabaseHandler(BentoBox plugin, Class<T> type, DatabaseConnector dbConnecter) {
|
||||
super(plugin, type, dbConnecter);
|
||||
connection = (Connection)dbConnecter.createConnection();
|
||||
// Check if the table exists in the database and if not, create it
|
||||
|
@ -45,7 +45,7 @@ public class MySQLDatabaseHandlerTest {
|
||||
private static MySQLDatabaseHandler<Island> handler;
|
||||
private static Island instance;
|
||||
private static String UNIQUE_ID = "xyz";
|
||||
private static MySQLDatabaseConnecter dbConn;
|
||||
private static MySQLDatabaseConnector dbConn;
|
||||
private static World world;
|
||||
@Mock
|
||||
static BentoBox plugin = mock(BentoBox.class);
|
||||
@ -81,7 +81,7 @@ public class MySQLDatabaseHandlerTest {
|
||||
when(plugin.getIWM()).thenReturn(iwm);
|
||||
|
||||
when(Bukkit.getLogger()).thenReturn(Logger.getAnonymousLogger());
|
||||
dbConn = mock(MySQLDatabaseConnecter.class);
|
||||
dbConn = mock(MySQLDatabaseConnector.class);
|
||||
Connection connection = mock(Connection.class);
|
||||
when(dbConn.createConnection()).thenReturn(connection);
|
||||
PreparedStatement ps = mock(PreparedStatement.class);
|
||||
|
Loading…
Reference in New Issue
Block a user