Made DatabaseSetup an interface

This commit is contained in:
Florian CUNY 2018-08-15 09:44:04 +02:00
parent 539d2a0516
commit f12773475b
4 changed files with 10 additions and 9 deletions

View File

@ -5,14 +5,15 @@ import world.bentobox.bentobox.database.flatfile.FlatFileDatabase;
import world.bentobox.bentobox.database.mongodb.MongoDBDatabase;
import world.bentobox.bentobox.database.mysql.MySQLDatabase;
public abstract class DatabaseSetup {
public interface DatabaseSetup {
/**
* Gets the type of database being used. Currently supported options are
* FLATFILE and MYSQL. Default is FLATFILE
* Gets the type of database being used.
* Currently supported options are FLATFILE and MYSQL.
* Default is FLATFILE.
* @return Database type
*/
public static DatabaseSetup getDatabase(){
static DatabaseSetup getDatabase() {
for(DatabaseType type : DatabaseType.values()){
if(type == BentoBox.getInstance().getSettings().getDatabaseType()) {
return type.database;
@ -21,7 +22,7 @@ public abstract class DatabaseSetup {
return DatabaseType.FLATFILE.database;
}
public enum DatabaseType{
enum DatabaseType {
FLATFILE(new FlatFileDatabase()),
MYSQL(new MySQLDatabase()),
MONGO(new MongoDBDatabase());
@ -39,6 +40,6 @@ public abstract class DatabaseSetup {
* @param dataObjectClass - class of the object to be stored in the database
* @return handler for this database object
*/
public abstract <T> AbstractDatabaseHandler<T> getHandler(Class<T> dataObjectClass);
<T> AbstractDatabaseHandler<T> getHandler(Class<T> dataObjectClass);
}

View File

@ -4,7 +4,7 @@ import world.bentobox.bentobox.BentoBox;
import world.bentobox.bentobox.database.AbstractDatabaseHandler;
import world.bentobox.bentobox.database.DatabaseSetup;
public class FlatFileDatabase extends DatabaseSetup {
public class FlatFileDatabase implements DatabaseSetup {
/**
* Get the config

View File

@ -5,7 +5,7 @@ import world.bentobox.bentobox.database.AbstractDatabaseHandler;
import world.bentobox.bentobox.database.DatabaseSetup;
import world.bentobox.bentobox.database.DatabaseConnectionSettingsImpl;
public class MongoDBDatabase extends DatabaseSetup {
public class MongoDBDatabase implements DatabaseSetup {
@Override
public <T> AbstractDatabaseHandler<T> getHandler(Class<T> type) {

View File

@ -5,7 +5,7 @@ import world.bentobox.bentobox.database.AbstractDatabaseHandler;
import world.bentobox.bentobox.database.DatabaseSetup;
import world.bentobox.bentobox.database.DatabaseConnectionSettingsImpl;
public class MySQLDatabase extends DatabaseSetup {
public class MySQLDatabase implements DatabaseSetup {
/* (non-Javadoc)