T
- The type of the option (Integer
, Bitmap.CompressFormat
etc.), must implement equals(Object)
and
hashCode()
.public final class Option<T>
extends java.lang.Object
DiskCacheStrategy.RESOURCE
.
Implementations must either be unique (usually declared as static final variables), or
implement equals(Object)
and hashCode()
.
Implementations can implement update(Object, MessageDigest)
to make sure that the
disk cache key includes the specific option set.
Modifier and Type | Class and Description |
---|---|
static interface |
Option.CacheKeyUpdater<T>
An interface that updates a
MessageDigest with the given value as part of a process to
generate a disk cache key. |
Modifier and Type | Method and Description |
---|---|
static <T> Option<T> |
disk(java.lang.String key,
Option.CacheKeyUpdater<T> cacheKeyUpdater)
Returns a new
Option that uses the given Option.CacheKeyUpdater to update disk cache keys. |
static <T> Option<T> |
disk(java.lang.String key,
T defaultValue,
Option.CacheKeyUpdater<T> cacheKeyUpdater)
Returns a new
Option that uses the given Option.CacheKeyUpdater to update disk cache keys and provides the
given value as the default value. |
boolean |
equals(java.lang.Object o) |
T |
getDefaultValue()
Returns a reasonable default to use if no other value is set, or
null . |
int |
hashCode() |
static <T> Option<T> |
memory(java.lang.String key)
Returns a new
Option that does not affect disk cache keys with a null default
value. |
static <T> Option<T> |
memory(java.lang.String key,
T defaultValue)
Returns a new
Option that does not affect disk cache keys with the given value as the
default value. |
java.lang.String |
toString() |
void |
update(T value,
java.security.MessageDigest messageDigest)
Updates the given
MessageDigest used to construct a cache key with the given value
using the Option.CacheKeyUpdater optionally provided in the
constructor. |
@NonNull public static <T> Option<T> memory(@NonNull java.lang.String key)
Option
that does not affect disk cache keys with a null
default
value.key
- A unique package prefixed String
that identifies this option (must be stable
across builds, so Class.getName()
should not be used).@NonNull public static <T> Option<T> memory(@NonNull java.lang.String key, @NonNull T defaultValue)
Option
that does not affect disk cache keys with the given value as the
default value.key
- A unique package prefixed String
that identifies this option (must be stable
across builds, so Class.getName()
should not be used).@NonNull public static <T> Option<T> disk(@NonNull java.lang.String key, @NonNull Option.CacheKeyUpdater<T> cacheKeyUpdater)
Option
that uses the given Option.CacheKeyUpdater
to update disk cache keys.key
- A unique package prefixed String
that identifies this option (must be stable
across builds, so Class.getName()
should not be used).@NonNull public static <T> Option<T> disk(@NonNull java.lang.String key, @Nullable T defaultValue, @NonNull Option.CacheKeyUpdater<T> cacheKeyUpdater)
Option
that uses the given Option.CacheKeyUpdater
to update disk cache keys and provides the
given value as the default value.key
- A unique package prefixed String
that identifies this option (must be stable
across builds, so Class.getName()
should not be used).@Nullable public T getDefaultValue()
null
.public void update(@NonNull T value, @NonNull java.security.MessageDigest messageDigest)
MessageDigest
used to construct a cache key with the given value
using the Option.CacheKeyUpdater
optionally provided in the
constructor.public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object