mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-11-24 19:55:17 +01:00
Made DatabaseSetup an interface
This commit is contained in:
parent
539d2a0516
commit
f12773475b
@ -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);
|
||||
|
||||
}
|
@ -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
|
||||
|
@ -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) {
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user