-
Notifications
You must be signed in to change notification settings - Fork 135
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rework storages to make them extensible with addons
- Loading branch information
Showing
73 changed files
with
3,176 additions
and
3,306 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/config/storage/Dialect.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package de.bluecolored.bluemap.common.config.storage; | ||
|
||
import de.bluecolored.bluemap.core.storage.sql.Database; | ||
import de.bluecolored.bluemap.core.storage.sql.commandset.CommandSet; | ||
import de.bluecolored.bluemap.core.storage.sql.commandset.MySQLCommandSet; | ||
import de.bluecolored.bluemap.core.storage.sql.commandset.PostgreSQLCommandSet; | ||
import de.bluecolored.bluemap.core.storage.sql.commandset.SqliteCommandSet; | ||
import de.bluecolored.bluemap.core.util.Key; | ||
import de.bluecolored.bluemap.core.util.Keyed; | ||
import de.bluecolored.bluemap.core.util.Registry; | ||
import lombok.Getter; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
import java.util.function.Function; | ||
|
||
public interface Dialect extends Keyed { | ||
|
||
Dialect MYSQL = new Impl(Key.bluemap("mysql"), MySQLCommandSet::new); | ||
Dialect MARIADB = new Impl(Key.bluemap("mariadb"), MySQLCommandSet::new); | ||
Dialect POSTGRESQL = new Impl(Key.bluemap("postgresql"), PostgreSQLCommandSet::new); | ||
Dialect SQLITE = new Impl(Key.bluemap("sqlite"), SqliteCommandSet::new); | ||
|
||
Registry<Dialect> REGISTRY = new Registry<>( | ||
MYSQL, | ||
MARIADB, | ||
POSTGRESQL, | ||
SQLITE | ||
); | ||
|
||
CommandSet createCommandSet(Database database); | ||
|
||
@RequiredArgsConstructor | ||
class Impl implements Dialect { | ||
|
||
@Getter | ||
private final Key key; | ||
|
||
private final Function<Database, CommandSet> commandSetProvider; | ||
|
||
@Override | ||
public CommandSet createCommandSet(Database database) { | ||
return commandSetProvider.apply(database); | ||
} | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.