Class SQLUserPersistentStorage
java.lang.Object
dev.chicoferreira.lifestealer.user.persistent.sql.SQLUserPersistentStorage
- All Implemented Interfaces:
UserPersistentStorage
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes the database and the database connectionvoiddeleteUser(LifestealerUser user) Deletes a user from the database.Returns a prettified name of the databasevoidinit()Initializes the database (for example, connecting and creating necessary tables)Loads a user from the database.voidsaveAllUsers(List<LifestealerUser> users) voidsaveUser(LifestealerUser user) Saves a user to the database.
-
Constructor Details
-
SQLUserPersistentStorage
-
-
Method Details
-
getDatabaseName
Description copied from interface:UserPersistentStorageReturns a prettified name of the database- Specified by:
getDatabaseNamein interfaceUserPersistentStorage- Returns:
- the database name
-
init
Description copied from interface:UserPersistentStorageInitializes the database (for example, connecting and creating necessary tables)- Specified by:
initin interfaceUserPersistentStorage- Throws:
Exception- if an error occurs
-
close
Description copied from interface:UserPersistentStorageCloses the database and the database connection- Specified by:
closein interfaceUserPersistentStorage- Throws:
SQLException
-
loadUser
Description copied from interface:UserPersistentStorageLoads a user from the database. This operation is blocking. UseLifestealerUserManager.getOrLoadUser(UUID)if you want to get the user if it is already loaded or load it from the database if it is not loaded.- Specified by:
loadUserin interfaceUserPersistentStorage- Parameters:
uuid- the uuid of the user to load- Returns:
- the loaded user or null if the user is not saved in the database
- Throws:
Exception- if an error occurs while loading the user
-
loadAllUsers
- Specified by:
loadAllUsersin interfaceUserPersistentStorage- Throws:
Exception
-
saveUser
Description copied from interface:UserPersistentStorageSaves a user to the database. This operation is blocking. UseLifestealerUserManager.saveUserAsync(LifestealerUser)if you want to save the user asynchronously.- Specified by:
saveUserin interfaceUserPersistentStorage- Parameters:
user- the user to save- Throws:
Exception- if an error occurs while saving the user
-
saveAllUsers
- Specified by:
saveAllUsersin interfaceUserPersistentStorage- Throws:
Exception
-
deleteUser
Description copied from interface:UserPersistentStorageDeletes a user from the database. This is used to delete a user from the database if they have no difference from the default values when saving throughLifestealerUserManager- Specified by:
deleteUserin interfaceUserPersistentStorage- Parameters:
user- the user to delete- Throws:
Exception- if an error occurs while deleting the user
-