/** * Call before invoking {@link Map#put} on super. */ public static boolean beforePut(ProxyMap map, Object key, Object value) { assertAllowedType(key, map.getKeyType()); assertAllowedType(value, map.getValueType()); dirty(map, false); return map.containsKey(key); }
/** * Override for {@link Map#keySet}. */ public static Set keySet(ProxyMap map) { ProxyEntrySet entries = (ProxyEntrySet) map.entrySet(); entries.setView(ProxyEntrySet.VIEW_KEYS); return entries; }
/** * Call after invoking {@link Map#get} on super. * The potential change is tracked when the get method is called. This change * will not translated to an update statement if the retrieved value * is not dirty. * * @param ret the return value from the super's method * @param before the return value from {@link #beforeGet} * @return the value to return from {@link Map#get} */ public static Object afterGet(ProxyMap map, Object key, Object ret, boolean before) { if (before) { if (map.getChangeTracker() != null) ((MapChangeTracker) map.getChangeTracker()).changed(key, ret, ret); } return ret; }
public boolean remove(Object o) { if (_view != VIEW_KEYS) throw new UnsupportedOperationException(); if (!_map.containsKey(o)) return false; _map.remove(o); return true; }
/** * Call before invoking {@link Map#get} on super. */ public static boolean beforeGet(ProxyMap map, Object key) { assertAllowedType(key, map.getKeyType()); // Java 8 solution/workaround due to containsKey() calling get!=null, which could cause infinite loop return map.keySet().contains(key); }
/** * Call before invoking {@link Map#remove(key, value) } on super. */ public static boolean beforeRemove(ProxyMap map, Object key, Object value) { dirty(map, false); return map.containsKey(key); }
/** * Overload for {@link Map#putAll}. */ public static void putAll(ProxyMap map, Map values) { Map.Entry entry; for (Iterator itr = values.entrySet().iterator(); itr.hasNext();) { entry = (Map.Entry) itr.next(); map.put(entry.getKey(), entry.getValue()); } }
public Map copyMap(Map orig) { if (orig == null) return null; if (orig instanceof Proxy) return (Map) ((Proxy) orig).copy(orig); ProxyMap proxy = getFactoryProxyMap(orig.getClass()); return (Map) proxy.copy(orig); }
public Proxy newMapProxy(Class type, Class keyType, Class elementType, Comparator compare,boolean autoOff) { type = toProxyableMapType(type); ProxyMap proxy = getFactoryProxyMap(type); return proxy.newInstance((_assertType) ? keyType : null, (_assertType) ? elementType : null, compare, _trackChanges, autoOff); }
public boolean remove(Object o) { if (_view != VIEW_KEYS) throw new UnsupportedOperationException(); if (!_map.containsKey(o)) return false; _map.remove(o); return true; }
/** * Call before invoking {@link Map#get} on super. */ public static boolean beforeGet(ProxyMap map, Object key) { assertAllowedType(key, map.getKeyType()); // Java 8 solution/workaround due to containsKey() calling get!=null, which could cause infinite loop return map.keySet().contains(key); }
/** * Call before invoking {@link Map#remove} on super. */ public static boolean beforeRemove(ProxyMap map, Object key) { dirty(map, false); return map.containsKey(key); }
/** * Overload for {@link Map#putAll}. */ public static void putAll(ProxyMap map, Map values) { Map.Entry entry; for (Iterator itr = values.entrySet().iterator(); itr.hasNext();) { entry = (Map.Entry) itr.next(); map.put(entry.getKey(), entry.getValue()); } }
public Map copyMap(Map orig) { if (orig == null) return null; if (orig instanceof Proxy) return (Map) ((Proxy) orig).copy(orig); ProxyMap proxy = getFactoryProxyMap(orig.getClass()); return (Map) proxy.copy(orig); }
public Proxy newMapProxy(Class type, Class keyType, Class elementType, Comparator compare,boolean autoOff) { type = toProxyableMapType(type); ProxyMap proxy = getFactoryProxyMap(type); return proxy.newInstance((_assertType) ? keyType : null, (_assertType) ? elementType : null, compare, _trackChanges, autoOff); }
/** * Call before invoking {@link Map#put} on super. */ public static boolean beforePut(ProxyMap map, Object key, Object value) { assertAllowedType(key, map.getKeyType()); assertAllowedType(value, map.getValueType()); dirty(map, false); return map.containsKey(key); }
/** * Call after invoking {@link Map#get} on super. * The potential change is tracked when the get method is called. This change * will not translated to an update statement if the retrieved value * is not dirty. * * @param ret the return value from the super's method * @param before the return value from {@link #beforeGet} * @return the value to return from {@link Map#get} */ public static Object afterGet(ProxyMap map, Object key, Object ret, boolean before) { if (before) { if (map.getChangeTracker() != null) ((MapChangeTracker) map.getChangeTracker()).changed(key, ret, ret); } return ret; }
public boolean remove(Object o) { if (_view != VIEW_KEYS) throw new UnsupportedOperationException(); if (!_map.containsKey(o)) return false; _map.remove(o); return true; }
/** * Override for {@link Map#values}. */ public static Collection values(ProxyMap map) { ProxyEntrySet entries = (ProxyEntrySet) map.entrySet(); entries.setView(ProxyEntrySet.VIEW_VALUES); return entries; }
/** * Call before invoking {@link Map#get} on super. */ public static boolean beforeGet(ProxyMap map, Object key) { assertAllowedType(key, map.getKeyType()); // Java 8 solution/workaround due to containsKey() calling get!=null, which could cause infinite loop return map.keySet().contains(key); }