NullResourceEncoder.java revision b5419dc08eb0a0f82821d774435720e5a31bc936
1package com.bumptech.glide.load.resource; 2 3import com.bumptech.glide.load.ResourceEncoder; 4import com.bumptech.glide.load.engine.Resource; 5 6import java.io.OutputStream; 7 8/** 9 * A simple {@link com.bumptech.glide.load.ResourceEncoder} that never writes data. 10 * 11 * @param <T> The type of the resource that will always fail to be encoded. 12 */ 13public class NullResourceEncoder<T> implements ResourceEncoder<T> { 14 private static final NullResourceEncoder NULL_ENCODER = new NullResourceEncoder(); 15 16 /** 17 * Returns a NullResourceEncoder for the given type. 18 * 19 * @param <T> The type of data to be written (or in this case not written). 20 */ 21 @SuppressWarnings("unchecked") 22 public static <T> NullResourceEncoder<T> get() { 23 return NULL_ENCODER; 24 } 25 26 @Override 27 public boolean encode(Resource<T> data, OutputStream os) { 28 return false; 29 } 30 31 @Override 32 public String getId() { 33 return ""; 34 } 35} 36