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 InputStreamDelegatingCacheableAvatarSupplier(AvatarSupplier, long),
CacheableAvatarSupplier.TIMESTAMP_UNKNOWNpublic DelegatingCacheableAvatarSupplier(@Nonnull AvatarSupplier supplier, long timestamp)
DelegatingCacheableAvatarSupplier with the provided timestamp.supplier - the AvatarSupplier containing the avatar's content type and InputStreamtimestamp - 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()
AvatarSuppliergetContentType in interface AvatarSupplier@Nonnull public InputStream open() throws IOException
AvatarSupplierInputStream to read the avatar. Each call to this method will produce a new stream.open in interface AvatarSupplieropen in interface InputSupplier<InputStream>IOException - in case the avatar could not be opened or readpublic long getTimestamp()
CacheableAvatarSupplierTo 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 CacheableAvatarSupplierCacheableAvatarSupplier.TIMESTAMP_UNKNOWN if no
modification date is available, or CacheableAvatarSupplier.TIMESTAMP_ETERNAL if the avatar is unmodifiableCopyright © 2019 Atlassian. All rights reserved.