Code example for WeakHashMap

0
@SuppressWarnings({"UnusedDeclaration"}) 
@Implements(Settings.class)
public class ShadowSettings { 
    @Implements(Settings.class)
    private static class SettingsImpl { 
        private static final WeakHashMap<ContentResolver, Map<String, Object>> dataMap = new WeakHashMap<ContentResolver, Map<String, Object>>();
 
        @Implementation 
        public static boolean putInt(ContentResolver cr, String name, int value) {
            get(cr).put(name, value);
            return true; 
        } 
 
        @Implementation 
        public static int getInt(ContentResolver cr, String name, int def) {
            if (get(cr).get(name) instanceof Integer) {
                return (Integer) get(cr).get(name);
            } else { 
                return def;
            } 
        }