Class SQLUserPersistentStorage
java.lang.Object
dev.chicoferreira.lifestealer.user.persistent.sql.SQLUserPersistentStorage
- All Implemented Interfaces:
UserPersistentStorage
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Closes the database and the database connectionvoid
deleteUser
(LifestealerUser user) Deletes a user from the database.Returns a prettified name of the databasevoid
init()
Initializes the database (for example, connecting and creating necessary tables)Loads a user from the database.void
saveAllUsers
(List<LifestealerUser> users) void
saveUser
(LifestealerUser user) Saves a user to the database.
-
Constructor Details
-
SQLUserPersistentStorage
-
-
Method Details
-
getDatabaseName
Description copied from interface:UserPersistentStorage
Returns a prettified name of the database- Specified by:
getDatabaseName
in interfaceUserPersistentStorage
- Returns:
- the database name
-
init
Description copied from interface:UserPersistentStorage
Initializes the database (for example, connecting and creating necessary tables)- Specified by:
init
in interfaceUserPersistentStorage
- Throws:
Exception
- if an error occurs
-
close
Description copied from interface:UserPersistentStorage
Closes the database and the database connection- Specified by:
close
in interfaceUserPersistentStorage
- Throws:
SQLException
-
loadUser
Description copied from interface:UserPersistentStorage
Loads 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:
loadUser
in 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:
loadAllUsers
in interfaceUserPersistentStorage
- Throws:
Exception
-
saveUser
Description copied from interface:UserPersistentStorage
Saves a user to the database. This operation is blocking. UseLifestealerUserManager.saveUserAsync(LifestealerUser)
if you want to save the user asynchronously.- Specified by:
saveUser
in interfaceUserPersistentStorage
- Parameters:
user
- the user to save- Throws:
Exception
- if an error occurs while saving the user
-
saveAllUsers
- Specified by:
saveAllUsers
in interfaceUserPersistentStorage
- Throws:
Exception
-
deleteUser
Description copied from interface:UserPersistentStorage
Deletes 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:
deleteUser
in interfaceUserPersistentStorage
- Parameters:
user
- the user to delete- Throws:
Exception
- if an error occurs while deleting the user
-