All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.bumptech.glide.signature.ObjectKey Maven / Gradle / Ivy

Go to download

A fast and efficient image loading library for Android focused on smooth scrolling.

There is a newer version: 5.0.0-rc01
Show newest version
package com.bumptech.glide.signature;

import com.bumptech.glide.load.Key;
import com.bumptech.glide.util.Preconditions;
import java.security.MessageDigest;

/**
 * Wraps an {@link java.lang.Object}, delegating {@link #equals(Object)} and {@link #hashCode()} to
 * the wrapped Object and providing the bytes of the result of the Object's {@link #toString()}
 * method to the {@link java.security.MessageDigest} in
 * {@link #updateDiskCacheKey(java.security.MessageDigest)}.
 *
 * 

The Object's {@link #toString()} method must be unique and suitable for use as a disk cache * key.

*/ public final class ObjectKey implements Key { private final Object object; public ObjectKey(Object object) { this.object = Preconditions.checkNotNull(object); } @Override public String toString() { return "ObjectKey{" + "object=" + object + '}'; } @Override public boolean equals(Object o) { if (o instanceof ObjectKey) { ObjectKey other = (ObjectKey) o; return object.equals(other.object); } return false; } @Override public int hashCode() { return object.hashCode(); } @Override public void updateDiskCacheKey(MessageDigest messageDigest) { messageDigest.update(object.toString().getBytes(CHARSET)); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy