Package me.mrnavastar.sqlib
Class Table
java.lang.Object
me.mrnavastar.sqlib.Table
This class acts as a wrapper for a table in a
Database-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionTable(@NonNull String modId, @NonNull String name, @NonNull Database database, SQLConnection sqlConnection) -
Method Summary
Modifier and TypeMethodDescriptionaddColumn(@NonNull String name, @NonNull SQLDataType dataType) Adds a column to the table definitionvoidCreate a transactional lock on this database.booleancontains(int id) Checks if the table contains aDataContainerbooleanChecks if the table contains aDataContainerbooleanChecks if the table contains aDataContainercreateDataContainer(int id) Creates a newDataContainercreateDataContainer(@NonNull String id) Creates a newDataContainercreateDataContainer(@NonNull UUID id) Creates a newDataContainerCreates a new row in the database and creates a handy wrapper classvoiddrop(int id) Delete theDataContainerfrom the databasevoidDelete theDataContainerfrom the databasevoidDelete theDataContainerfrom the databasevoiddrop(@NonNull DataContainer dataContainer) Delete theDataContainerfrom the databasevoidClose the transactional lock on this database and write the data.finish()Call this function when you are done configuring your table.get(int id) Tries to get aDataContainerTries to get aDataContainerTries to get aDataContainer@NonNull DatabasegetIds()@NonNull StringgetModId()@NonNull StringgetName()getOrCreateDataContainer(int id) Tries to get aDataContaineror creates a newDataContainerif it is missinggetOrCreateDataContainer(@NonNull String id) Tries to get aDataContaineror creates a newDataContainerif it is missinggetOrCreateDataContainer(@NonNull UUID id) Tries to get aDataContaineror creates a newDataContainerif it is missingbooleanChecks if thisTableis in a transactionMake this table use auto incremented ids.
-
Field Details
-
autoIncrement
protected boolean autoIncrement
-
-
Constructor Details
-
Method Details
-
setAutoIncrement
Make this table use auto incremented ids. SeecreateDataContainerAutoID() -
finish
Call this function when you are done configuring your table.- Returns:
- The finished table
-
getNoConflictName
-
beginTransaction
public void beginTransaction()Create a transactional lock on this database. No data will be written until you callendTransaction() -
endTransaction
public void endTransaction()Close the transactional lock on this database and write the data. -
isInTransaction
public boolean isInTransaction()Checks if thisTableis in a transaction -
getIds
- Returns:
- A list of all the
DataContainerids in this table.
-
getIdsAsUUIDs
- Returns:
- A list of all the
DataContainerids in this table.
-
getIdsAsInts
- Returns:
- A list of all the
DataContainerids in this table.
-
createDataContainer
Creates a newDataContainer -
createDataContainer
Creates a newDataContainer -
createDataContainer
Creates a newDataContainer -
getOrCreateDataContainer
Tries to get aDataContaineror creates a newDataContainerif it is missing -
getOrCreateDataContainer
Tries to get aDataContaineror creates a newDataContainerif it is missing -
getOrCreateDataContainer
Tries to get aDataContaineror creates a newDataContainerif it is missing -
createDataContainerAutoID
Creates a new row in the database and creates a handy wrapper class- Returns:
- DataContainer or null if the table is not configured for autoIncrementing.
-
drop
Delete theDataContainerfrom the database- Parameters:
id- The id of theDataContainerto delete
-
drop
Delete theDataContainerfrom the database- Parameters:
id- The id of theDataContainerto delete
-
drop
public void drop(int id) Delete theDataContainerfrom the database- Parameters:
id- The id of theDataContainerto delete
-
get
Tries to get aDataContainer- Returns:
- The
DataContaineror null if it is missing
-
get
Tries to get aDataContainer- Returns:
- The
DataContaineror null if it is missing
-
get
Tries to get aDataContainer- Returns:
- The
DataContaineror null if it is missing
-
contains
Checks if the table contains aDataContainer- Parameters:
id- The id of theDataContainerto look for
-
contains
Checks if the table contains aDataContainer- Parameters:
id- The id of theDataContainerto look for
-
contains
public boolean contains(int id) Checks if the table contains aDataContainer- Parameters:
id- The id of theDataContainerto look for
-
getDataContainers
- Returns:
- A list of all the
DataContainer's in this table
-
getModId
-
getName
-
getDatabase
-
getColumns
-