@Test void remove() { list.add(weak1); list.add(weak2); list.add(weak3); WeakReferenceUtil.remove(list, data1); WeakReferenceUtil.remove(list, data2); WeakReferenceUtil.remove(list, weak3); Assertions.assertEquals(1, list.size()); Assertions.assertEquals(weak3, list.get(0)); }
static <T> void remove(final List<WeakReference<T>> weakReferences, final T object) { weakReferences.removeIf(weakReference -> { final T ref = weakReference.get(); if (weakReference.isEnqueued() || ref == null) { return true; } return ref.equals(object); }); }
WeakReferenceUtil { static <T> void remove(final List<WeakReference<T>> weakReferences, final T object) { weakReferences.removeIf(weakReference -> { final T ref = weakReference.get(); if (weakReference.isEnqueued() || ref == null) { return true; } return ref.equals(object); }); } }
WeakReferenceUtil { static <T> void remove(final List<WeakReference<T>> weakReferences, final T object) { weakReferences.removeIf(weakReference -> { final T ref = weakReference.get(); if (weakReference.isEnqueued() || ref == null) { return true; } return ref.equals(object); }); } private  WeakReferenceUtil(); }
WeakReferenceUtil { static <T> void remove(final List<WeakReference<T>> weakReferences, final T object) { weakReferences.removeIf(weakReference -> { final T ref = weakReference.get(); if (weakReference.isEnqueued() || ref == null) { return true; } return ref.equals(object); }); } private  WeakReferenceUtil();  }
WeakReferenceUtil { static <T> void remove(final List<WeakReference<T>> weakReferences, final T object) { weakReferences.removeIf(weakReference -> { final T ref = weakReference.get(); if (weakReference.isEnqueued() || ref == null) { return true; } return ref.equals(object); }); } private  WeakReferenceUtil();   }