Package me.mrnavastar.sqlib.api
Class DataStore
java.lang.Object
me.mrnavastar.sqlib.api.DataStore
This class represents a table in a
Database.-
Constructor Summary
ConstructorsConstructorDescriptionDataStore(@NonNull String modId, @NonNull String name, @NonNull Database database, @NonNull SQLConnection connection) -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanCreates a newDataContainerbooleangetContainer(int id) getContainer(@NonNull String field, @NonNull Object value) getContainers(@NonNull String field, @NonNull Object value) getKeys()getModId()getName()getOrCreateContainer(int id) Tries to get aDataContaineror creates a newDataContainerif it is missing.getOrCreateContainer(int id, Consumer<DataContainer> onCreate) Tries to get aDataContaineror creates a newDataContainerif it is missing.getOrCreateContainer(@NonNull String field, @NonNull Object value) Tries to get aDataContainerwith a matching key value pair or creates a newDataContainerif it is missing.getOrCreateContainer(@NonNull String field, @NonNull Object value, Consumer<DataContainer> onCreate) Tries to get aDataContainerwith a matching key value pair or creates a newDataContainerif it is missing.inthashCode()toString()
-
Constructor Details
-
Method Details
-
toString
-
createContainer
Creates a newDataContainer -
getOrCreateContainer
Tries to get aDataContaineror creates a newDataContainerif it is missing. Note that the createdDataContaineris not guaranteed to have the same id as the one passed in. -
getOrCreateContainer
Tries to get aDataContaineror creates a newDataContainerif it is missing. Note that the createdDataContaineris not guaranteed to have the same id as the one passed in.- Parameters:
onCreate- A function that gets run only when the container is created. This is useful for setting things such as a container id or other elements that are only set once.
-
getOrCreateContainer
public DataContainer getOrCreateContainer(@NonNull @NonNull String field, @NonNull @NonNull Object value) Tries to get aDataContainerwith a matching key value pair or creates a newDataContainerif it is missing. -
getOrCreateContainer
public DataContainer getOrCreateContainer(@NonNull @NonNull String field, @NonNull @NonNull Object value, Consumer<DataContainer> onCreate) Tries to get aDataContainerwith a matching key value pair or creates a newDataContainerif it is missing.- Parameters:
onCreate- A function that gets run only when the container is created. This is useful for setting things such as a container id or other elements that are only set once.
-
getContainer
public Optional<DataContainer> getContainer(@NonNull @NonNull String field, @NonNull @NonNull Object value) - Returns:
- A
DataContainer's with a matching key value pair or null if one does not exist.
-
getContainer
- Returns:
- A
DataContaineror null if it is missing.
-
getContainers
- Returns:
- A list of all the
DataContainer's in this table.
-
getContainers
public List<DataContainer> getContainers(@NonNull @NonNull String field, @NonNull @NonNull Object value) - Returns:
- A list of all the
DataContainer's with a matching key value pair.
-
getKeys
- Returns:
- A list of every key present in this
DataStore.
-
equals
-
canEqual
-
hashCode
public int hashCode() -
getModId
-
getName
-
getDatabase
-