Created
December 6, 2013 14:57
-
-
Save alvinsj/7826055 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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