Package io.github.mrtesz.teszcore.api
Class TeszCoreApi
java.lang.Object
io.github.mrtesz.teszcore.api.TeszCoreApi
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptioncopy()Copy the executing classcreateMariaDBManager(@Nullable String projectName, boolean infoWhenCredentialsAreNull, @Nullable String name, String url, String user, String password) Creates aMariaDBManagerfor your projectcreateMariaDBManager(@Nullable String projectName, boolean infoWhenCredentialsAreNull, String url, String user, String password) Creates aMariaDBManagerfor your projectcreateSqliteManager(@Nullable String projectName, @Nullable String path, @NotNull String fileName) Creates aSqliteManagerfor your Projectstatic TeszCoreApiGet the current instanceorg.apache.logging.log4j.LoggerGet theLogger, TeszCore uses internallygetLogger(@NotNull DebugLevel debugLevel) Creates aTeszCoreLoggergetLogger(@NotNull DebugLevel debugLevel, @Nullable String projectName) Creates aTeszCoreLoggerwith project name for specific logsorg.apache.logging.log4j.core.LoggerContextGet theLoggerContext, thelog4j.Loggerusesstatic TeszCoreApiinitialize(TeszCoreApi.Initializer initializer) Create a newTeszCoreApiinstancevoidlogException(@NotNull Throwable throwable) Logs a throwable by callingTeszCoreLogger.printStackTrace(java.lang.Throwable)
-
Method Details
-
initialize
public static TeszCoreApi initialize(TeszCoreApi.Initializer initializer) throws DuplicateInitializationException Create a newTeszCoreApiinstance- Parameters:
initializer- Initializer class (previously created with the)invalid reference
Initializer#builder()- Returns:
- The created
TeszCoreApiinstance (can also be obtained withgetInstance() - Throws:
DuplicateInitializationException- when aTeszCoreApiinstance was already initialized by other projects (can be bypassed with settingTeszCoreApi.Initializer.overwriteto true)
-
logException
Logs a throwable by callingTeszCoreLogger.printStackTrace(java.lang.Throwable)- Parameters:
throwable- The throwable to log
-
getLogger
Creates aTeszCoreLogger- Parameters:
debugLevel- Level of Logging used for your Message- Returns:
- a new TeszCoreLogger
-
getLogger
public TeszCoreLogger getLogger(@NotNull @NotNull DebugLevel debugLevel, @Nullable @Nullable String projectName) Creates aTeszCoreLoggerwith project name for specific logs- Parameters:
debugLevel- Level of Logging used for your MessageprojectName- The name of the project, using the logger- Returns:
- a new TeszCoreLogger
-
createMariaDBManager
public MariaDBManager createMariaDBManager(@Nullable @Nullable String projectName, boolean infoWhenCredentialsAreNull, @Nullable @Nullable String name, String url, String user, String password) Creates aMariaDBManagerfor your project- Parameters:
projectName- Name of the project using the methodinfoWhenCredentialsAreNull- throw an error, if url, user or password is null/blankname- Name of the database manager Default: "Main"url- Url of the database, connecting touser- Username of the user, connecting withpassword- Password of the user, connecting with- Returns:
- a
MariaDBManager
-
createMariaDBManager
public MariaDBManager createMariaDBManager(@Nullable @Nullable String projectName, boolean infoWhenCredentialsAreNull, String url, String user, String password) Creates aMariaDBManagerfor your project- Parameters:
projectName- Name of the project using the methodinfoWhenCredentialsAreNull- throw an error, if url, user or password is null/blankurl- Url of the database, connecting touser- Username of the user, connecting withpassword- Password of the user, connecting with- Returns:
- a
MariaDBManager
-
createSqliteManager
public SqliteManager createSqliteManager(@Nullable @Nullable String projectName, @Nullable @Nullable String path, @NotNull @NotNull String fileName) Creates aSqliteManagerfor your Project- Parameters:
projectName- The name of the Project using the methodpath- Path of the `.db` file — `null` uses the default locationfileName- Name of the `.db` file- Returns:
- a
SqliteManager
-
getLog4jLogger
public org.apache.logging.log4j.Logger getLog4jLogger()Get theLogger, TeszCore uses internally- Returns:
- the
Logger, TeszCore uses internally
-
getLoggerContext
public org.apache.logging.log4j.core.LoggerContext getLoggerContext()Get theLoggerContext, thelog4j.Loggeruses- Returns:
- the
LoggerContext, thelog4j.Loggeruses
-
getInstance
Get the current instance- Returns:
- Current TeszCoreApi instance
- Throws:
NullPointerException- if the TeszCoreApi was not initialized before withinitialize(Initializer)
-
copy
Description copied from interface:CopyableCopy the executing class- Specified by:
copyin interfaceCopyable<TeszCoreApi>- Returns:
- a copy of the class executed in
- Throws:
DuplicateInitializationExceptionIllegalArgumentException
-