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 SummaryFields inherited from interface com.atlassian.bitbucket.avatar.CacheableAvatarSupplierTIMESTAMP_ETERNAL, TIMESTAMP_UNKNOWN
- 
Constructor SummaryConstructorsConstructorDescriptionConstructs a newDelegatingCacheableAvatarSupplierwith anunknowntimestamp.DelegatingCacheableAvatarSupplier(AvatarSupplier supplier, long timestamp) Constructs a newDelegatingCacheableAvatarSupplierwith the providedtimestamp.
- 
Method SummaryModifier 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- 
DelegatingCacheableAvatarSupplierConstructs a newDelegatingCacheableAvatarSupplierwith anunknowntimestamp.- Parameters:
- supplier- the- AvatarSuppliercontaining the avatar's content type and- InputStream
- See Also:
 
- 
DelegatingCacheableAvatarSupplierConstructs a newDelegatingCacheableAvatarSupplierwith the providedtimestamp.- Parameters:
- supplier- the- AvatarSuppliercontaining the avatar's content type and- InputStream
- timestamp- the avatar's modification timestamp, which may be- CacheableAvatarSupplier.TIMESTAMP_UNKNOWNif no modification timestamp is known, or- CacheableAvatarSupplier.TIMESTAMP_ETERNALif the avatar is unmodifiable
 
 
- 
- 
Method Details- 
getContentTypeDescription copied from interface:AvatarSupplierThe content type of the avatar, e.g., "image/png"- Specified by:
- getContentTypein interface- AvatarSupplier
- Returns:
- the string representing the content type
 
- 
openDescription copied from interface:AvatarSupplierProvides anInputStreamto read the avatar. Each call to this method will produce a new stream.- Specified by:
- openin interface- AvatarSupplier
- Specified by:
- openin interface- InputSupplier<InputStream>
- Returns:
- a stream from the avatar
- Throws:
- IOException- in case the avatar could not be opened or read
 
- 
getTimestamppublic 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 interface- CacheableAvatarSupplier
- 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 
 
-