public class DelegatingCacheableAvatarSupplier extends Object implements CacheableAvatarSupplier
CacheableAvatarSupplier
implementation which delegates to an AvatarSupplier
, storing the avatar's
modification timestamp
separately. This class can be used to promote an ordinary
AvatarSupplier
to a CacheableAvatarSupplier
.TIMESTAMP_ETERNAL, TIMESTAMP_UNKNOWN
Constructor and Description |
---|
DelegatingCacheableAvatarSupplier(AvatarSupplier supplier)
Constructs a new
DelegatingCacheableAvatarSupplier with an unknown timestamp. |
DelegatingCacheableAvatarSupplier(AvatarSupplier supplier,
long timestamp)
Constructs a new
DelegatingCacheableAvatarSupplier with the provided timestamp . |
Modifier and Type | Method and Description |
---|---|
String |
getContentType()
The content type of the avatar, e.g., "image/png"
|
long |
getTimestamp()
The timestamp at which the avatar was last modified, in milliseconds.
|
InputStream |
open()
Provides an
InputStream to read the avatar. |
public DelegatingCacheableAvatarSupplier(@Nonnull AvatarSupplier supplier)
DelegatingCacheableAvatarSupplier
with an unknown
timestamp.supplier
- the AvatarSupplier
containing the avatar's content type and InputStream
DelegatingCacheableAvatarSupplier(AvatarSupplier, long)
,
CacheableAvatarSupplier.TIMESTAMP_UNKNOWN
public DelegatingCacheableAvatarSupplier(@Nonnull AvatarSupplier supplier, long timestamp)
DelegatingCacheableAvatarSupplier
with the provided timestamp
.supplier
- the AvatarSupplier
containing the avatar's content type and InputStream
timestamp
- the avatar's modification timestamp, which may be CacheableAvatarSupplier.TIMESTAMP_UNKNOWN
if no modification
timestamp is known, or CacheableAvatarSupplier.TIMESTAMP_ETERNAL
if the avatar is unmodifiablepublic String getContentType()
AvatarSupplier
getContentType
in interface AvatarSupplier
@Nonnull public InputStream open() throws IOException
AvatarSupplier
InputStream
to read the avatar. Each call to this method will produce a new stream.open
in interface AvatarSupplier
open
in interface InputSupplier<InputStream>
IOException
- in case the avatar could not be opened or readpublic long getTimestamp()
CacheableAvatarSupplier
To account for differences in avatar repository implementations:
CacheableAvatarSupplier.TIMESTAMP_UNKNOWN
.
Avatars without timestamps should not be cached, as it may not be possible to reliably detect updates.CacheableAvatarSupplier.TIMESTAMP_ETERNAL
. Such
avatars may be cached more aggressively, as they cannot change.getTimestamp
in interface CacheableAvatarSupplier
CacheableAvatarSupplier.TIMESTAMP_UNKNOWN
if no
modification date is available, or CacheableAvatarSupplier.TIMESTAMP_ETERNAL
if the avatar is unmodifiableCopyright © 2022 Atlassian. All rights reserved.