public interface CachedData
PermissionHolder.
All calls will account for inheritance, as well as any default data provided by the platform. This calls are heavily cached and are therefore fast.
For meta, both methods accepting Contexts and MetaContexts
are provided. The only difference is that the latter allows you to define
how the meta stack should be structured internally. Where Contexts
are passed, the values from the configuration are used.
| Modifier and Type | Method and Description |
|---|---|
MetaData |
calculateMeta(Contexts contexts)
Calculates meta data, bypassing the cache.
|
MetaData |
calculateMeta(MetaContexts contexts)
Calculates meta data, bypassing the cache.
|
PermissionData |
calculatePermissions(Contexts contexts)
Calculates permission data, bypassing the cache.
|
MetaData |
getMetaData(Contexts contexts)
Gets MetaData from the cache, given a specified context.
|
MetaData |
getMetaData(MetaContexts contexts)
Gets MetaData from the cache, given a specified context.
|
PermissionData |
getPermissionData(Contexts contexts)
Gets PermissionData from the cache, given a specified context.
|
void |
invalidateMeta()
Invalidates all cached
MetaData instances. |
void |
invalidateMeta(Contexts contexts)
|
void |
invalidateMeta(MetaContexts contexts)
Invalidates any cached
MetaData instances mapped to the given
MetaContexts. |
void |
invalidatePermissionCalculators()
Invalidates all of the underlying Permission calculators.
|
void |
invalidatePermissions()
Invalidates all cached
PermissionData instances. |
void |
invalidatePermissions(Contexts contexts)
Invalidates any cached
PermissionData instances mapped to the given
Contexts. |
void |
preCalculate(Contexts contexts)
Pre-calculates and caches
PermissionData and MetaData
instances for a given context. |
default void |
preCalculate(Set<Contexts> contexts)
Pre-calculates and caches
PermissionData and MetaData
instances for the given contexts. |
void |
recalculateMeta()
Recalculates meta data for all known contexts.
|
void |
recalculateMeta(Contexts contexts)
(Re)calculates meta data for a given context.
|
void |
recalculateMeta(MetaContexts contexts)
(Re)calculates meta data for a given context.
|
void |
recalculatePermissions()
Recalculates permission data for all known contexts.
|
void |
recalculatePermissions(Contexts contexts)
(Re)calculates permission data for a given context.
|
CompletableFuture<Void> |
reloadMeta()
Reloads meta data for all known contexts.
|
CompletableFuture<? extends MetaData> |
reloadMeta(Contexts contexts)
(Re)loads meta data for a given context.
|
CompletableFuture<? extends MetaData> |
reloadMeta(MetaContexts contexts)
(Re)loads meta data for a given context.
|
CompletableFuture<Void> |
reloadPermissions()
Reloads permission data for all known contexts.
|
CompletableFuture<? extends PermissionData> |
reloadPermissions(Contexts contexts)
(Re)loads permission data for a given context.
|
@Nonnull PermissionData getPermissionData(@Nonnull Contexts contexts)
contexts - the contexts to get the permission data inNullPointerException - if contexts is null@Nonnull MetaData getMetaData(@Nonnull MetaContexts contexts)
contexts - the contexts to get the permission data inNullPointerException - if contexts is null@Nonnull MetaData getMetaData(@Nonnull Contexts contexts)
contexts - the contexts to get the permission data inNullPointerException - if contexts is null@Nonnull PermissionData calculatePermissions(@Nonnull Contexts contexts)
The result of this operation is calculated each time the method is called. The result is not added to the internal cache.
It is therefore highly recommended to use getPermissionData(Contexts) instead.
The use cases of this method are more around constructing one-time
instances of PermissionData, without adding the result to the cache.
contexts - the contexts to get permission data inNullPointerException - if contexts is null@Nonnull MetaData calculateMeta(@Nonnull MetaContexts contexts)
The result of this operation is calculated each time the method is called. The result is not added to the internal cache.
It is therefore highly recommended to use getMetaData(MetaContexts) instead.
The use cases of this method are more around constructing one-time
instances of MetaData, without adding the result to the cache.
contexts - the contexts to get meta data inNullPointerException - if contexts is null@Nonnull MetaData calculateMeta(@Nonnull Contexts contexts)
The result of this operation is calculated each time the method is called. The result is not added to the internal cache.
It is therefore highly recommended to use getMetaData(Contexts) instead.
The use cases of this method are more around constructing one-time
instances of MetaData, without adding the result to the cache.
contexts - the contexts to get meta data inNullPointerException - if contexts is nullvoid recalculatePermissions(@Nonnull Contexts contexts)
This method returns immediately in all cases. The (re)calculation is performed asynchronously and applied to the cache in the background.
If there was a previous PermissionData instance associated with
the given Contexts, then that instance will continue to be returned by
getPermissionData(Contexts) until the recalculation is completed.
If there was no value calculated and cached prior to the call of this method, then one will be calculated.
contexts - the contexts to recalculate in.NullPointerException - if contexts is nullvoid recalculateMeta(@Nonnull MetaContexts contexts)
This method returns immediately in all cases. The (re)calculation is performed asynchronously and applied to the cache in the background.
If there was a previous MetaData instance associated with
the given MetaContexts, then that instance will continue to be returned by
getMetaData(MetaContexts) until the recalculation is completed.
If there was no value calculated and cached prior to the call of this method, then one will be calculated.
contexts - the contexts to recalculate in.NullPointerException - if contexts is nullvoid recalculateMeta(@Nonnull Contexts contexts)
This method returns immediately in all cases. The (re)calculation is performed asynchronously and applied to the cache in the background.
If there was a previous MetaData instance associated with
the given Contexts, then that instance will continue to be returned by
getMetaData(Contexts) until the recalculation is completed.
If there was no value calculated and cached prior to the call of this method, then one will be calculated.
contexts - the contexts to recalculate in.NullPointerException - if contexts is null@Nonnull CompletableFuture<? extends PermissionData> reloadPermissions(@Nonnull Contexts contexts)
Unlike recalculatePermissions(Contexts), this method immediately
invalidates any previous PermissionData values contained within the cache,
and then schedules a task to reload a new PermissionData instance to
replace the one which was invalidated.
The invalidation happens immediately during the execution of this method. The result of the re-computation encapsulated by the future.
Subsequent calls to getPermissionData(Contexts) will block until
the result of this operation is complete.
If there was no value calculated and cached prior to the call of this method, then one will be calculated.
This method returns a Future so users can optionally choose to wait until the recalculation has been performed.
contexts - the contexts to reload in.NullPointerException - if contexts is null@Nonnull CompletableFuture<? extends MetaData> reloadMeta(@Nonnull MetaContexts contexts)
Unlike recalculateMeta(MetaContexts), this method immediately
invalidates any previous MetaData values contained within the cache,
and then schedules a task to reload a new MetaData instance to
replace the one which was invalidated.
The invalidation happens immediately during the execution of this method. The result of the re-computation encapsulated by the future.
Subsequent calls to getMetaData(MetaContexts) will block until
the result of this operation is complete.
If there was no value calculated and cached prior to the call of this method, then one will be calculated.
This method returns a Future so users can optionally choose to wait until the recalculation has been performed.
contexts - the contexts to reload in.NullPointerException - if contexts is null@Nonnull CompletableFuture<? extends MetaData> reloadMeta(@Nonnull Contexts contexts)
Unlike recalculateMeta(Contexts), this method immediately
invalidates any previous MetaData values contained within the cache,
and then schedules a task to reload a new MetaData instance to
replace the one which was invalidated.
The invalidation happens immediately during the execution of this method. The result of the re-computation encapsulated by the future.
Subsequent calls to getMetaData(Contexts) will block until
the result of this operation is complete.
If there was no value calculated and cached prior to the call of this method, then one will be calculated.
This method returns a Future so users can optionally choose to wait until the recalculation has been performed.
contexts - the contexts to reload in.NullPointerException - if contexts is nullvoid recalculatePermissions()
This method returns immediately. The recalculation is performed asynchronously and applied to the cache in the background.
The previous PermissionData instances will continue to be returned
by getPermissionData(Contexts) until the recalculation is completed.
void recalculateMeta()
This method returns immediately. The recalculation is performed asynchronously and applied to the cache in the background.
The previous MetaData instances will continue to be returned
by getMetaData(MetaContexts) and getMetaData(Contexts)
until the recalculation is completed.
@Nonnull CompletableFuture<Void> reloadPermissions()
Unlike recalculatePermissions(), this method immediately
invalidates all previous PermissionData values contained within the cache,
and then schedules a task to reload a new PermissionData instances to
replace the ones which were invalidated.
The invalidation happens immediately during the execution of this method. The result of the re-computation encapsulated by the future.
Subsequent calls to getPermissionData(Contexts) will block until
the result of this operation is complete.
This method returns a Future so users can optionally choose to wait until the recalculation has been performed.
@Nonnull CompletableFuture<Void> reloadMeta()
Unlike recalculateMeta(), this method immediately
invalidates all previous MetaData values contained within the cache,
and then schedules a task to reload a new MetaData instances to
replace the ones which were invalidated.
The invalidation happens immediately during the execution of this method. The result of the re-computation encapsulated by the future.
Subsequent calls to getMetaData(MetaContexts) and
getMetaData(Contexts) will block until the result of this operation
is complete.
This method returns a Future so users can optionally choose to wait until the recalculation has been performed.
default void preCalculate(@Nonnull Set<Contexts> contexts)
PermissionData and MetaData
instances for the given contexts.
If the cache already contains a value for the given context, no action is taken.
This method blocks until the calculation is completed.
contexts - a set of contextsNullPointerException - if contexts is nullvoid preCalculate(@Nonnull Contexts contexts)
PermissionData and MetaData
instances for a given context.
If the cache already contains a value for the given context, no action is taken.
This method blocks until the calculation is completed.
contexts - the contexts to pre-calculate forNullPointerException - if contexts is nullvoid invalidatePermissions(@Nonnull Contexts contexts)
PermissionData instances mapped to the given
Contexts.contexts - the contexts to invalidate forvoid invalidateMeta(@Nonnull MetaContexts contexts)
MetaData instances mapped to the given
MetaContexts.contexts - the contexts to invalidate forvoid invalidateMeta(@Nonnull Contexts contexts)
contexts - the contexts to invalidate forvoid invalidatePermissions()
PermissionData instances.void invalidateMeta()
MetaData instances.void invalidatePermissionCalculators()
Can be called to allow for an update in defaults.
Copyright © 2018. All rights reserved.