public final class CacheKey extends Object
Modifier and Type | Method and Description |
---|---|
CacheKey |
append(Iterable<Object> objects)
Appends the given Objects to this instance.
|
CacheKey |
append(Object... objects)
Appends the given Objects to this instance.
|
boolean |
equals(Object o) |
ArrayList<Object> |
getComponents() |
Optional<String> |
getTenantId()
Getter for the Id of the tenant for which the key is used.
|
Optional<String> |
getUserName()
Getter for the name of the user for which the key is used.
|
int |
hashCode() |
static CacheKey |
of(String tenantId,
String userName)
Constructs a
CacheKey for the given tenant identifier and user name, independent of whether they are
null or not. |
static CacheKey |
ofNoIsolation()
Constructs an instance of
CacheKey without tenant or user isolation. |
static CacheKey |
ofTenantAndUserIsolation()
Constructs a tenant- and user-isolated instance of
CacheKey . |
static CacheKey |
ofTenantIsolation()
Constructs a tenant-isolated instance of
CacheKey . |
String |
toString() |
@Nonnull public Optional<String> getTenantId()
@Nonnull public Optional<String> getUserName()
@Nonnull public CacheKey append(@Nonnull Iterable<Object> objects) throws IllegalArgumentException
Object.equals(Object)
and
Object.hashCode()
are used. The given objects must not be null
.objects
- Additional objects that should be used to identify a cache key.IllegalArgumentException
- If any of the given objects is null
.@Nonnull public CacheKey append(@Nonnull Object... objects) throws IllegalArgumentException
Object.equals(Object)
and
Object.hashCode()
are used. The given objects must not be null
.objects
- Additional objects that should be used to identify a cache key.IllegalArgumentException
- If any of the given objects is null
.@Nonnull public static CacheKey of(@Nullable String tenantId, @Nullable String userName)
CacheKey
for the given tenant identifier and user name, independent of whether they are
null
or not. This provides the highest flexibility for defining different levels of isolation.tenantId
- The identifier of the tenant. If null
, there is not tenant isolation.userName
- The name of the user. If null
, there is no user isolation.CacheKey
constructed from the given tenant identifier and user name.@Nonnull public static CacheKey ofNoIsolation()
CacheKey
without tenant or user isolation. This can be used to share a cache
globally within the application.CacheKey
without isolation.@Nonnull public static CacheKey ofTenantIsolation() throws TenantNotAvailableException, TenantAccessException
CacheKey
. This can be used to share a cache among the users of a
tenant.
When using this method, the tenant isolation is strictly enforced. This means that if the tenant is not available, an exception is thrown.
CacheKey
with tenant isolation based on the current tenant.TenantNotAvailableException
- If the tenant is not available. This typically occurs when trying to access the tenant within code
that is running outside any tenant context, e.g., within a background task.TenantAccessException
- If there is an issue while accessing the tenant.@Nonnull public static CacheKey ofTenantAndUserIsolation() throws TenantNotAvailableException, TenantAccessException, UserNotAuthenticatedException, UserAccessException
CacheKey
.
When using this method, the tenant and user isolation is strictly enforced. This means that if the tenant is not available or the user is not authenticated, an exception is thrown.
CacheKey
with tenant and user isolation based on the current tenant and user.TenantNotAvailableException
- If the tenant is not available. This typically occurs when trying to access the tenant within code
that is running outside any tenant context, e.g., within a background task.TenantAccessException
- If there is an issue while accessing the tenant.UserNotAuthenticatedException
- If the user is not authenticated.UserAccessException
- If there is an issue while accessing the user.Copyright © 2018 SAP SE. All rights reserved.