/** * Override for {@link Collection#addAll}. */ public static boolean addAll(ProxyCollection coll, Collection values) { boolean added = false; for (Iterator itr = values.iterator(); itr.hasNext();) added |= coll.add(itr.next()); return added; }
public void set(Object o) { assertAllowedType(o, coll.getElementType()); dirty(coll, false); itr.set(o); if (coll.getChangeTracker() != null) coll.getChangeTracker().stopTracking(); Proxies.removed(coll, _last, false); _last = o; }
/** * Call before invoking {@link Queue#poll} on super. */ public static void beforePoll(ProxyCollection coll) { if (!coll.isEmpty()) beforeRemove(coll, 0); }
state = checkState(proxy); boolean tracking = false; ChangeTracker ct = proxy.getChangeTracker(); Collection<?> added = null; Collection<?> removed = null; ct.stopTracking(); if (proxy.size() > 0) { proxy.clear(); proxy.addAll(added); added.clear(); proxy.removeAll(removed); removed.clear();
/** * Call after invoking {@link Collection#add(Object)} on super. * * @param added whether the object was added * @return <code>added</code>, for convenience */ public static boolean afterAdd(ProxyCollection coll, Object value, boolean added) { if (added && coll.getChangeTracker() != null) ((CollectionChangeTracker) coll.getChangeTracker()).added(value); return added; }
/** * Call before invoking {@link List#add(int,Object)} on super. */ public static void beforeAdd(ProxyCollection coll, int index, Object value){ assertAllowedType(value, coll.getElementType()); dirty(coll, true); }
/** * Call after invoking {@link LinkedList#removeLast} on super. */ public static Object afterRemoveLast(ProxyCollection coll, Object removed) { return afterRemove(coll, coll.size(), removed); }
/** * Call before invoking {@link List#add(int,Object)} on super. */ public static void beforeAdd(ProxyCollection coll, int index, Object value){ assertAllowedType(value, coll.getElementType()); if (index == coll.size()) // optimize for adding to the end beforeAdd(coll, value); else dirty(coll, true); }
/** * Override for {@link Collection#removeAll}. */ public static boolean removeAll(ProxyCollection coll, Collection<?> vals) { boolean removed = false; for (Iterator<?> itr = vals.iterator(); itr.hasNext();) removed |= coll.remove(itr.next()); return removed; }
/** * Call before clearing collection. */ public static void beforeClear(ProxyCollection coll) { dirty(coll, true); for (Iterator<?> itr = coll.iterator(); itr.hasNext();) removed(coll, itr.next(), false); }
public Proxy newCollectionProxy(Class type, Class elementType, Comparator compare, boolean autoOff) { type = toProxyableCollectionType(type); ProxyCollection proxy = getFactoryProxyCollection(type); return proxy.newInstance((_assertType) ? elementType : null, compare, _trackChanges, autoOff); }
public Collection copyCollection(Collection orig) { if (orig == null) return null; if (orig instanceof Proxy) return (Collection) ((Proxy) orig).copy(orig); ProxyCollection proxy = getFactoryProxyCollection(orig.getClass()); return (Collection) proxy.copy(orig); }
state = checkState(proxy); boolean tracking = false; ChangeTracker ct = proxy.getChangeTracker(); Collection<?> added = null; Collection<?> removed = null; ct.stopTracking(); if (proxy.size() > 0) { proxy.clear(); proxy.addAll(added); added.clear(); proxy.removeAll(removed); removed.clear();
/** * Call after invoking {@link Collection#remove} on super. * * @param removed whether the object was removed * @return whether the object was removed, for convenience */ public static boolean afterRemove(ProxyCollection coll, Object o, boolean removed){ if (!removed) return false; if (coll.getChangeTracker() != null) ((CollectionChangeTracker) coll.getChangeTracker()).removed(o); removed(coll, o, false); return true; }
/** * Call before invoking {@link List#set} on super. */ public static void beforeSet(ProxyCollection coll, int index, Object element) { assertAllowedType(element, coll.getElementType()); dirty(coll, true); }
/** * Call after invoking {@link LinkedList#removeLast} on super. */ public static void beforeRemoveLast(ProxyCollection coll) { beforeRemove(coll, coll.size() - 1); }
/** * Override for {@link Collection#removeAll}. */ public static boolean removeAll(ProxyCollection coll, Collection<?> vals) { boolean removed = false; for (Iterator<?> itr = vals.iterator(); itr.hasNext();) removed |= coll.remove(itr.next()); return removed; }
/** * Call before clearing collection. */ public static void beforeClear(ProxyCollection coll) { dirty(coll, true); for (Iterator<?> itr = coll.iterator(); itr.hasNext();) removed(coll, itr.next(), false); }