1package com.bumptech.glide.load; 2 3import java.io.OutputStream; 4 5/** 6 * An interface for writing data to some persistent data store (i.e. a local File cache). 7 * 8 * @param <T> The type of the data that will be written. 9 */ 10public interface Encoder<T> { 11 12 /** 13 * Writes the given data to the given output stream and returns True if the write completed successfully and 14 * should be committed. 15 * 16 * @param data The data to write. 17 * @param os The OutputStream to write the data to. 18 */ 19 boolean encode(T data, OutputStream os); 20 21 /** 22 * Returns an ID identifying any transformation this encoder may apply to the given data that will be mixed in to 23 * the cache key. 24 * 25 * <p> 26 * If the encoder does not transform the data in a way that significantly affects the cached result (ie performs 27 * no unusual compression or downsampling) an empty string is an appropriate id. 28 * </p> 29 */ 30 String getId(); 31} 32