Package com.atlassian.bitbucket.avatar
Class DelegatingCacheableAvatarSupplier
java.lang.Object
com.atlassian.bitbucket.avatar.DelegatingCacheableAvatarSupplier
- All Implemented Interfaces:
AvatarSupplier,CacheableAvatarSupplier,InputSupplier<InputStream>
An
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.-
Field Summary
Fields inherited from interface com.atlassian.bitbucket.avatar.CacheableAvatarSupplier
TIMESTAMP_ETERNAL, TIMESTAMP_UNKNOWN -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a newDelegatingCacheableAvatarSupplierwith anunknowntimestamp.DelegatingCacheableAvatarSupplier(AvatarSupplier supplier, long timestamp) Constructs a newDelegatingCacheableAvatarSupplierwith the providedtimestamp. -
Method Summary
Modifier and TypeMethodDescriptionThe content type of the avatar, e.g., "image/png"longThe timestamp at which the avatar was last modified, in milliseconds.open()Provides anInputStreamto read the avatar.
-
Constructor Details
-
DelegatingCacheableAvatarSupplier
Constructs a newDelegatingCacheableAvatarSupplierwith anunknowntimestamp.- Parameters:
supplier- theAvatarSuppliercontaining the avatar's content type andInputStream- See Also:
-
DelegatingCacheableAvatarSupplier
Constructs a newDelegatingCacheableAvatarSupplierwith the providedtimestamp.- Parameters:
supplier- theAvatarSuppliercontaining the avatar's content type andInputStreamtimestamp- the avatar's modification timestamp, which may beCacheableAvatarSupplier.TIMESTAMP_UNKNOWNif no modification timestamp is known, orCacheableAvatarSupplier.TIMESTAMP_ETERNALif the avatar is unmodifiable
-
-
Method Details
-
getContentType
Description copied from interface:AvatarSupplierThe content type of the avatar, e.g., "image/png"- Specified by:
getContentTypein interfaceAvatarSupplier- Returns:
- the string representing the content type
-
open
Description copied from interface:AvatarSupplierProvides anInputStreamto read the avatar. Each call to this method will produce a new stream.- Specified by:
openin interfaceAvatarSupplier- Specified by:
openin interfaceInputSupplier<InputStream>- Returns:
- a stream from the avatar
- Throws:
IOException- in case the avatar could not be opened or read
-
getTimestamp
public long getTimestamp()Description copied from interface:CacheableAvatarSupplierThe timestamp at which the avatar was last modified, in milliseconds.To account for differences in avatar repository implementations:
- If timestamp information is not available, implementations shall return
CacheableAvatarSupplier.TIMESTAMP_UNKNOWN. Avatars without timestamps should not be cached, as it may not be possible to reliably detect updates. - If the avatar cannot be updated, implementations shall return
CacheableAvatarSupplier.TIMESTAMP_ETERNAL. Such avatars may be cached more aggressively, as they cannot change.
- Specified by:
getTimestampin interfaceCacheableAvatarSupplier- Returns:
- the avatar's modification timestamp in milliseconds, or
CacheableAvatarSupplier.TIMESTAMP_UNKNOWNif no modification date is available, orCacheableAvatarSupplier.TIMESTAMP_ETERNALif the avatar is unmodifiable
- If timestamp information is not available, implementations shall return
-