public abstract class NegativityAccountManager extends Object
Constructor and Description |
---|
NegativityAccountManager() |
Modifier and Type | Method and Description |
---|---|
abstract @Nullable NegativityAccount |
dispose(UUID accountId)
Indicates that the account for the given UUID can be forgotten by this manager.
|
abstract CompletableFuture<NegativityAccount> |
get(UUID accountId)
Gets the account associated to the given UUID wrapped in a CompletableFuture.
|
NegativityAccount |
getNow(UUID accountId)
Gets the account associated to the given UUID in a blocking manner.
|
abstract CompletableFuture<Void> |
save(UUID accountId)
Saves the account associated to the given UUID.
|
abstract void |
update(NegativityAccount account)
Makes this manager use the the given account's data instead of what it may have already.
|
public abstract CompletableFuture<NegativityAccount> get(UUID accountId)
The account may be returned directly (if cached for example), or loaded via potential (slow) IO operations.
Ideally, cancelling the returned CompletableFuture will cancel the underlying (potentially slow) operations to avoid wasting resources.
accountId
- the ID of the account to getgetNow(java.util.UUID)
public NegativityAccount getNow(UUID accountId)
This is equivalent to calling get(accountId).join()
This method may throw CompletionException
according to CompletableFuture.join()
,
and is unlikely (but still may) throw CancellationException
.
accountId
- the ID of the account to getpublic abstract CompletableFuture<Void> save(UUID accountId)
accountId
- the ID of the account to savepublic abstract void update(NegativityAccount account)
account
- the account to usepublic abstract @Nullable NegativityAccount dispose(UUID accountId)
What this method does is completely up to the implementing class, it may do nothing, or remove the account from a cache for example.
If an implementation caches accounts, the returned account would be the one removed from its cache.
accountId
- the ID of the account to dispose