Skip to content

Instantly share code, notes, and snippets.

@enesakar
Created March 8, 2012 08:00
Show Gist options
  • Save enesakar/1999547 to your computer and use it in GitHub Desktop.
Save enesakar/1999547 to your computer and use it in GitHub Desktop.
public class MyMapStore implements MapStore<String,Contact> {
public void store(String key, Contact contact) {
DataService.getInstance().addContact(contact.getPhone(), contact.getName());
}
public void storeAll(Map<String, Contact> contactMap) {
for(String key: contactMap.keySet()) {
store(key, contactMap.get(key));
}
}
public void delete(String key) {
}
public void deleteAll(Collection<String> strings) {
}
public Contact load(String key) {
return DataService.getInstance().loadContact(key);
}
public Map<String, Contact> loadAll(Collection<String> keys) {
Map<String, Contact> contactMap = new HashMap<String, Contact>();
List<Contact> contacts= DataService.getInstance().loadAllContacts(keys);
for(Contact contact: contacts) {
contactMap.put(contact.getPhone(), contact);
}
return contactMap;
}
public Set<String> loadAllKeys() {
return DataService.getInstance().loadAllKeys();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment