Class Option<T>

java.lang.Object
com.bumptech.glide.load.Option<T>
Type Parameters:
T - The type of the option (Integer, Bitmap.CompressFormat etc.), must implement equals(Object) and hashCode().

public final class Option<T> extends Object
Defines available component (decoders, encoders, model loaders etc.) options with optional default values and the ability to affect the resource disk cache key used by 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.

  • Method Details

    • memory

      @NonNull public static <T> Option<T> memory(@NonNull String key)
      Returns a new Option that does not affect disk cache keys with a null default value.
      Parameters:
      key - A unique package prefixed String that identifies this option (must be stable across builds, so Class.getName() should not be used).
    • memory

      @NonNull public static <T> Option<T> memory(@NonNull String key, @NonNull T defaultValue)
      Returns a new Option that does not affect disk cache keys with the given value as the default value.
      Parameters:
      key - A unique package prefixed String that identifies this option (must be stable across builds, so Class.getName() should not be used).
    • disk

      @NonNull public static <T> Option<T> disk(@NonNull String key, @NonNull Option.CacheKeyUpdater<T> cacheKeyUpdater)
      Returns a new Option that uses the given Option.CacheKeyUpdater to update disk cache keys.
      Parameters:
      key - A unique package prefixed String that identifies this option (must be stable across builds, so Class.getName() should not be used).
    • disk

      @NonNull public static <T> Option<T> disk(@NonNull String key, @Nullable T defaultValue, @NonNull 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.
      Parameters:
      key - A unique package prefixed String that identifies this option (must be stable across builds, so Class.getName() should not be used).
    • getDefaultValue

      @Nullable public T getDefaultValue()
      Returns a reasonable default to use if no other value is set, or null.
    • update

      public void update(@NonNull T value, @NonNull 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.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object