mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-11-28 05:35:44 +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.mongodb.MongoDBDatabase;
|
||||||
import world.bentobox.bentobox.database.mysql.MySQLDatabase;
|
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
|
* Gets the type of database being used.
|
||||||
* FLATFILE and MYSQL. Default is FLATFILE
|
* Currently supported options are FLATFILE and MYSQL.
|
||||||
|
* Default is FLATFILE.
|
||||||
* @return Database type
|
* @return Database type
|
||||||
*/
|
*/
|
||||||
public static DatabaseSetup getDatabase(){
|
static DatabaseSetup getDatabase() {
|
||||||
for(DatabaseType type : DatabaseType.values()){
|
for(DatabaseType type : DatabaseType.values()){
|
||||||
if(type == BentoBox.getInstance().getSettings().getDatabaseType()) {
|
if(type == BentoBox.getInstance().getSettings().getDatabaseType()) {
|
||||||
return type.database;
|
return type.database;
|
||||||
@ -21,7 +22,7 @@ public abstract class DatabaseSetup {
|
|||||||
return DatabaseType.FLATFILE.database;
|
return DatabaseType.FLATFILE.database;
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum DatabaseType{
|
enum DatabaseType {
|
||||||
FLATFILE(new FlatFileDatabase()),
|
FLATFILE(new FlatFileDatabase()),
|
||||||
MYSQL(new MySQLDatabase()),
|
MYSQL(new MySQLDatabase()),
|
||||||
MONGO(new MongoDBDatabase());
|
MONGO(new MongoDBDatabase());
|
||||||
@ -39,6 +40,6 @@ public abstract class DatabaseSetup {
|
|||||||
* @param dataObjectClass - class of the object to be stored in the database
|
* @param dataObjectClass - class of the object to be stored in the database
|
||||||
* @return handler for this database object
|
* @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.AbstractDatabaseHandler;
|
||||||
import world.bentobox.bentobox.database.DatabaseSetup;
|
import world.bentobox.bentobox.database.DatabaseSetup;
|
||||||
|
|
||||||
public class FlatFileDatabase extends DatabaseSetup {
|
public class FlatFileDatabase implements DatabaseSetup {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the config
|
* Get the config
|
||||||
|
@ -5,7 +5,7 @@ import world.bentobox.bentobox.database.AbstractDatabaseHandler;
|
|||||||
import world.bentobox.bentobox.database.DatabaseSetup;
|
import world.bentobox.bentobox.database.DatabaseSetup;
|
||||||
import world.bentobox.bentobox.database.DatabaseConnectionSettingsImpl;
|
import world.bentobox.bentobox.database.DatabaseConnectionSettingsImpl;
|
||||||
|
|
||||||
public class MongoDBDatabase extends DatabaseSetup {
|
public class MongoDBDatabase implements DatabaseSetup {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <T> AbstractDatabaseHandler<T> getHandler(Class<T> type) {
|
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.DatabaseSetup;
|
||||||
import world.bentobox.bentobox.database.DatabaseConnectionSettingsImpl;
|
import world.bentobox.bentobox.database.DatabaseConnectionSettingsImpl;
|
||||||
|
|
||||||
public class MySQLDatabase extends DatabaseSetup {
|
public class MySQLDatabase implements DatabaseSetup {
|
||||||
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
Loading…
Reference in New Issue
Block a user