Last active
September 18, 2017 08:55
-
-
Save sw-samuraj/c02d9967a46dfcddd909f9ab1cb8d8b5 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 ObservableCache extends Observable { | |
private Map<String, PersonInfo> cache = new HashMap<>(); | |
public void put(String key, PersonInfo person) { | |
cache.put(key, person); | |
setChanged(); | |
notifyObservers(); | |
} | |
public boolean containsKey(String key) { | |
return cache.containsKey(key); | |
} | |
public PersonInfo get(String key) { | |
return cache.get(key); | |
} | |
public PersonInfo remove(String key) { | |
PersonInfo person = cache.remove(key); | |
setChanged(); | |
notifyObservers(); | |
return person; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment