java.lang.Object
net.foxgenesis.database.AbstractDatabase
- All Implemented Interfaces:
AutoCloseable
NEED_JAVADOC
- Author:
- Ashley
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceNEED_JAVADOCstatic interfaceNEED_JAVADOC -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionAbstractDatabase(@NotNull String name, @NotNull ModuleResource operationsFile, @NotNull ModuleResource setupFile) NEED_JAVADOC -
Method Summary
Modifier and TypeMethodDescriptionfinal @NotNull StringgetName()protected final StringNEED_JAVADOCprotected final booleanhasStatementID(String id) NEED_JAVADOCbooleanisReady()NEED_JAVADOCprotected <U> @Nullable Optional<U>mapCallable(String id, AbstractDatabase.SQLFunction<CallableStatement, U> func) NEED_JAVADOCprotected <U> @NotNull Optional<U>mapStatement(String id, AbstractDatabase.SQLFunction<PreparedStatement, U> func, int... flags) NEED_JAVADOCprotected abstract voidonReady()NEED_JAVADOCprotected ConnectionNEED_JAVADOCprotected voidNEED_JAVADOCprotected voidprepareStatement(String id, AbstractDatabase.SQLConsumer<PreparedStatement> func, int... flags) NEED_JAVADOCMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.AutoCloseable
close
-
Field Details
-
logger
protected final org.slf4j.Logger loggerLogger
-
-
Constructor Details
-
AbstractDatabase
public AbstractDatabase(@NotNull @NotNull String name, @NotNull @NotNull ModuleResource operationsFile, @NotNull @NotNull ModuleResource setupFile) NEED_JAVADOC- Parameters:
name-operationsFile-setupFile-
-
-
Method Details
-
onReady
protected abstract void onReady()NEED_JAVADOC -
openConnection
NEED_JAVADOC- Returns:
- Returns the new
Connection - Throws:
SQLException
-
prepareStatement
protected void prepareStatement(String id, AbstractDatabase.SQLConsumer<PreparedStatement> func, int... flags) throws SQLException NEED_JAVADOC- Parameters:
id-func-flags-- Throws:
SQLException
-
prepareCallable
protected void prepareCallable(String id, AbstractDatabase.SQLConsumer<CallableStatement> func) throws SQLException NEED_JAVADOC- Parameters:
id-func-- Throws:
SQLException
-
mapStatement
@NotNull protected <U> @NotNull Optional<U> mapStatement(String id, AbstractDatabase.SQLFunction<PreparedStatement, U> func, int... flags) throws SQLExceptionNEED_JAVADOC- Type Parameters:
U-- Parameters:
id-func-flags-- Returns:
- Returns the result of
funcotherwise an emptyOptional - Throws:
SQLException
-
mapCallable
@Nullable protected <U> @Nullable Optional<U> mapCallable(String id, AbstractDatabase.SQLFunction<CallableStatement, U> func) throws SQLExceptionNEED_JAVADOC- Type Parameters:
U-- Parameters:
id-func-- Returns:
- Returns the result of
funcotherwise an emptyOptional - Throws:
SQLException
-
hasStatementID
NEED_JAVADOC- Parameters:
id-- Returns:
- Returns
trueif the statement is registered.falseotherwise
-
getRawStatement
NEED_JAVADOC- Parameters:
id-- Returns:
- Returns the raw SQL statement
-
getName
-
isReady
public boolean isReady()NEED_JAVADOC- Returns:
- Returns
trueif the database is ready for use
-
getDatabase
-