Package com.bumptech.glide.load
Class Option<T>
- java.lang.Object
-
- com.bumptech.glide.load.Option<T>
-
- Type Parameters:
T- The type of the option (Integer,Bitmap.CompressFormatetc.), must implementequals(Object)andhashCode().
public final class Option<T> extends java.lang.ObjectDefines available component (decoders, encoders, model loaders etc.) options with optional default values and the ability to affect the resource disk cache key used byDiskCacheStrategy.RESOURCE.Implementations must either be unique (usually declared as static final variables), or implement
equals(Object)andhashCode().Implementations can implement
update(Object, MessageDigest)to make sure that the disk cache key includes the specific option set.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceOption.CacheKeyUpdater<T>An interface that updates aMessageDigestwith the given value as part of a process to generate a disk cache key.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static <T> Option<T>disk(java.lang.String key, Option.CacheKeyUpdater<T> cacheKeyUpdater)Returns a newOptionthat uses the givenOption.CacheKeyUpdaterto update disk cache keys.static <T> Option<T>disk(java.lang.String key, T defaultValue, Option.CacheKeyUpdater<T> cacheKeyUpdater)Returns a newOptionthat uses the givenOption.CacheKeyUpdaterto update disk cache keys and provides the given value as the default value.booleanequals(java.lang.Object o)TgetDefaultValue()Returns a reasonable default to use if no other value is set, ornull.inthashCode()static <T> Option<T>memory(java.lang.String key)Returns a newOptionthat does not affect disk cache keys with anulldefault value.static <T> Option<T>memory(java.lang.String key, T defaultValue)Returns a newOptionthat does not affect disk cache keys with the given value as the default value.java.lang.StringtoString()voidupdate(T value, java.security.MessageDigest messageDigest)Updates the givenMessageDigestused to construct a cache key with the given value using theOption.CacheKeyUpdateroptionally provided in the constructor.
-
-
-
Method Detail
-
memory
@NonNull public static <T> Option<T> memory(@NonNull java.lang.String key)
Returns a newOptionthat does not affect disk cache keys with anulldefault value.- Parameters:
key- A unique package prefixedStringthat identifies this option (must be stable across builds, soClass.getName()should not be used).
-
memory
@NonNull public static <T> Option<T> memory(@NonNull java.lang.String key, @NonNull T defaultValue)
Returns a newOptionthat does not affect disk cache keys with the given value as the default value.- Parameters:
key- A unique package prefixedStringthat identifies this option (must be stable across builds, soClass.getName()should not be used).
-
disk
@NonNull public static <T> Option<T> disk(@NonNull java.lang.String key, @NonNull Option.CacheKeyUpdater<T> cacheKeyUpdater)
Returns a newOptionthat uses the givenOption.CacheKeyUpdaterto update disk cache keys.- Parameters:
key- A unique package prefixedStringthat identifies this option (must be stable across builds, soClass.getName()should not be used).
-
disk
@NonNull public static <T> Option<T> disk(@NonNull java.lang.String key, @Nullable T defaultValue, @NonNull Option.CacheKeyUpdater<T> cacheKeyUpdater)
Returns a newOptionthat uses the givenOption.CacheKeyUpdaterto update disk cache keys and provides the given value as the default value.- Parameters:
key- A unique package prefixedStringthat identifies this option (must be stable across builds, soClass.getName()should not be used).
-
getDefaultValue
@Nullable public T getDefaultValue()
Returns a reasonable default to use if no other value is set, ornull.
-
update
public void update(@NonNull T value, @NonNull java.security.MessageDigest messageDigest)Updates the givenMessageDigestused to construct a cache key with the given value using theOption.CacheKeyUpdateroptionally provided in the constructor.
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-