@Test void contains() { list.add(weak1); list.add(weak2); list.add(weak3); Assertions.assertTrue(WeakReferenceUtil.contains(list, data1)); Assertions.assertTrue(WeakReferenceUtil.contains(list, data2)); Assertions.assertTrue(WeakReferenceUtil.contains(list, data3)); Assertions.assertFalse(WeakReferenceUtil.contains(list, weak1)); Assertions.assertFalse(WeakReferenceUtil.contains(list, weak2)); Assertions.assertFalse(WeakReferenceUtil.contains(list, weak3)); list.remove(weak1); Assertions.assertFalse(WeakReferenceUtil.contains(list, data1)); Assertions.assertTrue(WeakReferenceUtil.contains(list, data2)); Assertions.assertFalse(WeakReferenceUtil.contains(list, weak1)); Assertions.assertFalse(WeakReferenceUtil.contains(list, weak2)); list.remove(0); Assertions.assertFalse(WeakReferenceUtil.contains(list, data2)); }
static <T> boolean contains(final List<WeakReference<T>> list, final T object) { for (final WeakReference<T> weakReference : list) { final T ref = weakReference.get(); if (ref != null && ref.equals(object)) { return true; } } return false; }
WeakReferenceUtil { static <T> boolean contains(final List<WeakReference<T>> list, final T object) { for (final WeakReference<T> weakReference : list) { final T ref = weakReference.get(); if (ref != null && ref.equals(object)) { return true; } } return false; } }
WeakReferenceUtil { static <T> boolean contains(final List<WeakReference<T>> list, final T object) { for (final WeakReference<T> weakReference : list) { final T ref = weakReference.get(); if (ref != null && ref.equals(object)) { return true; } } return false; } private  WeakReferenceUtil(); }
WeakReferenceUtil { static <T> boolean contains(final List<WeakReference<T>> list, final T object) { for (final WeakReference<T> weakReference : list) { final T ref = weakReference.get(); if (ref != null && ref.equals(object)) { return true; } } return false; } private  WeakReferenceUtil();  }
WeakReferenceUtil { static <T> boolean contains(final List<WeakReference<T>> list, final T object) { for (final WeakReference<T> weakReference : list) { final T ref = weakReference.get(); if (ref != null && ref.equals(object)) { return true; } } return false; } private  WeakReferenceUtil();   }