Removed DatabaseConnector#loadYamlFile and DatabaseConnector#saveYamlFile

It was only used by FlatFileDatabaseHandler and therefore was useless for other DatabaseHandlers
This commit is contained in:
Florian CUNY 2018-10-28 15:01:17 +01:00
parent 0dc9de9c37
commit f0c4cb710c
5 changed files with 3 additions and 53 deletions

View File

@ -1,9 +1,5 @@
package world.bentobox.bentobox.database;
import java.util.Map;
import org.bukkit.configuration.file.YamlConfiguration;
/**
*
* Creates a connection to a database.
@ -45,22 +41,5 @@ public interface DatabaseConnector {
*/
boolean uniqueIdExists(String tableName, String key);
/**
* Loads a YAML file. Used by the flat file database
* @param tableName - the table name to load
* @param fileName - the filename
* @return Yaml Configuration
*/
YamlConfiguration loadYamlFile(String tableName, String fileName);
/**
* Save the Yaml Config
* @param yamlConfig - the YAML config
* @param path - analogous to a table name in a database
* @param fileName - the name of the record. Must be unique.
* @param commentMap - map of comments, may be empty
*/
void saveYamlFile(YamlConfiguration yamlConfig, String path, String fileName, Map<String, String> commentMap);
}

View File

@ -44,7 +44,6 @@ public class FlatFileDatabaseConnector implements DatabaseConnector {
return null; // Not used
}
@Override
public YamlConfiguration loadYamlFile(String tableName, String fileName) {
if (!fileName.endsWith(".yml")) {
fileName = fileName + ".yml";
@ -79,7 +78,6 @@ public class FlatFileDatabaseConnector implements DatabaseConnector {
return config;
}
@Override
public void saveYamlFile(YamlConfiguration yamlConfig, String tableName, String fileName, Map<String, String> commentMap) {
if (!fileName.endsWith(".yml")) {
fileName = fileName + ".yml";

View File

@ -82,7 +82,7 @@ public class FlatFileDatabaseHandler<T> extends AbstractDatabaseHandler<T> {
key = storeAt.filename();
}
// Load the YAML file at the location.
YamlConfiguration config = databaseConnector.loadYamlFile(path, key);
YamlConfiguration config = ((FlatFileDatabaseConnector)databaseConnector).loadYamlFile(path, key);
// Use the createObject method to turn a YAML config into an Java object
return createObject(config);
}
@ -123,7 +123,7 @@ public class FlatFileDatabaseHandler<T> extends AbstractDatabaseHandler<T> {
if (storeAt != null) {
fileName = storeAt.filename();
}
YamlConfiguration config = databaseConnector.loadYamlFile(DATABASE_FOLDER_NAME + File.separator + dataObject.getSimpleName(), fileName);
YamlConfiguration config = ((FlatFileDatabaseConnector)databaseConnector).loadYamlFile(DATABASE_FOLDER_NAME + File.separator + dataObject.getSimpleName(), fileName);
list.add(createObject(config));
}
return list;
@ -413,7 +413,7 @@ public class FlatFileDatabaseHandler<T> extends AbstractDatabaseHandler<T> {
throw new IllegalArgumentException("No uniqueId in class");
}
databaseConnector.saveYamlFile(config, path, filename, yamlComments);
((FlatFileDatabaseConnector)databaseConnector).saveYamlFile(config, path, filename, yamlComments);
}
private void setComment(ConfigComment comment, YamlConfiguration config, Map<String, String> yamlComments, String parent) {

View File

@ -47,29 +47,15 @@ public class MongoDBDatabaseConnector implements DatabaseConnector {
return "";
}
@Override
public YamlConfiguration loadYamlFile(String string, String key) {
// Not used
return null;
}
@Override
public boolean uniqueIdExists(String tableName, String key) {
// Not used
return false;
}
@Override
public void saveYamlFile(YamlConfiguration yamlConfig, String tableName, String fileName,
Map<String, String> commentMap) {
// Not used
}
@Override
public void closeConnection() {
client.close();
}
}

View File

@ -53,25 +53,12 @@ public class MySQLDatabaseConnector implements DatabaseConnector {
return "";
}
@Override
public YamlConfiguration loadYamlFile(String string, String key) {
// Not used
return null;
}
@Override
public boolean uniqueIdExists(String tableName, String key) {
// Not used
return false;
}
@Override
public void saveYamlFile(YamlConfiguration yamlConfig, String tableName, String fileName,
Map<String, String> commentMap) {
// Not used
}
@Override
public void closeConnection() {
if (connection != null) {