Skip to content

Instantly share code, notes, and snippets.

@alvinsj
Created December 6, 2013 14:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alvinsj/7826055 to your computer and use it in GitHub Desktop.
Save alvinsj/7826055 to your computer and use it in GitHub Desktop.
public class Product implements Cachable{
public Product(String type, String key){
mType = type;
mKey = key;
}
public String cacheId() {
return mKey;
}
public String cacheType() {
return mType;
}
private String mName;
private String mDescription;
private String mImageUrl;
private String mProductUrl;
public Cachable fromCache(String type, String key, HashMap<String, String> cache) {
mType = type;
mKey = key;
mName = cache.get("name");
mDescription = cache.get("desc");
mImageUrl = cache.get("image_url");
mProductUrl = cache.get("url");
return this;
}
public HashMap<String, String> toCache() {
HashMap<String, String> map = new HashMap<String, String>();
map.put("name", mName);
map.put("desc",mDescription);
map.put("image_url", mImageUrl);
map.put("url",mProductUrl);
return map;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment