Package com.atlassian.bamboo.avatar
Class DelegatingCacheableAvatarSupplier
- java.lang.Object
-
- com.atlassian.bamboo.avatar.DelegatingCacheableAvatarSupplier
-
- All Implemented Interfaces:
AvatarSupplier
,CacheableAvatarSupplier
,InputSupplier<InputStream>
public class DelegatingCacheableAvatarSupplier extends Object implements CacheableAvatarSupplier
AnCacheableAvatarSupplier
implementation which delegates to anAvatarSupplier
, storing the avatar'smodification timestamp
separately. This class can be used to promote an ordinaryAvatarSupplier
to aCacheableAvatarSupplier
.- Since:
- 9.5
-
-
Field Summary
-
Fields inherited from interface com.atlassian.bamboo.avatar.CacheableAvatarSupplier
TIMESTAMP_ETERNAL, TIMESTAMP_UNKNOWN
-
-
Constructor Summary
Constructors Constructor Description DelegatingCacheableAvatarSupplier(@NotNull AvatarSupplier supplier)
Constructs a newDelegatingCacheableAvatarSupplier
with anunknown
timestamp.DelegatingCacheableAvatarSupplier(@NotNull AvatarSupplier supplier, long timestamp)
Constructs a newDelegatingCacheableAvatarSupplier
with the providedtimestamp
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method 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.@NotNull InputStream
open()
Provides anInputStream
to read the avatar.
-
-
-
Constructor Detail
-
DelegatingCacheableAvatarSupplier
public DelegatingCacheableAvatarSupplier(@NotNull @NotNull AvatarSupplier supplier)
Constructs a newDelegatingCacheableAvatarSupplier
with anunknown
timestamp.- Parameters:
supplier
- theAvatarSupplier
containing the avatar's content type andInputStream
- See Also:
DelegatingCacheableAvatarSupplier(AvatarSupplier, long)
,CacheableAvatarSupplier.TIMESTAMP_UNKNOWN
-
DelegatingCacheableAvatarSupplier
public DelegatingCacheableAvatarSupplier(@NotNull @NotNull AvatarSupplier supplier, long timestamp)
Constructs a newDelegatingCacheableAvatarSupplier
with the providedtimestamp
.- Parameters:
supplier
- theAvatarSupplier
containing the avatar's content type andInputStream
timestamp
- the avatar's modification timestamp, which may beCacheableAvatarSupplier.TIMESTAMP_UNKNOWN
if no modification timestamp is known, orCacheableAvatarSupplier.TIMESTAMP_ETERNAL
if the avatar is unmodifiable
-
-
Method Detail
-
getContentType
public String getContentType()
Description copied from interface:AvatarSupplier
The content type of the avatar, e.g., "image/png"- Specified by:
getContentType
in interfaceAvatarSupplier
- Returns:
- the string representing the content type
-
open
@NotNull public @NotNull InputStream open() throws IOException
Description copied from interface:AvatarSupplier
Provides anInputStream
to read the avatar. Each call to this method will produce a new stream.- Specified by:
open
in interfaceAvatarSupplier
- Specified by:
open
in 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:CacheableAvatarSupplier
The 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:
getTimestamp
in interfaceCacheableAvatarSupplier
- Returns:
- the avatar's modification timestamp in milliseconds, or
CacheableAvatarSupplier.TIMESTAMP_UNKNOWN
if no modification date is available, orCacheableAvatarSupplier.TIMESTAMP_ETERNAL
if the avatar is unmodifiable
- If timestamp information is not available, implementations shall return
-
-