Example #1
0
  /**
   * Puts the given listener into this list at the specified index, replacing the current listener
   * at that index. Either a strong or a weak reference is maintained to the listener depending upon
   * the <code>strong</code> parameter.
   *
   * @param index the index that the given element should be set at.
   * @param element the listener instance to be inserted into the list.
   * @param strong true if a strong reference should be maintained to the listener instance, and
   *     false if only a weak reference should be used.
   */
  public T set(final int index, final T element, final boolean strong) {
    final MixedReference<T> next = new MixedReference<T>(element, strong, referenceQueue);
    final MixedReference<T> prev = data.set(index, next);

    return prev.get();
  }
Example #2
0
 /** {@inheritDoc} */
 @Override
 public T remove(final int index) {
   final MixedReference<T> removed = data.remove(index);
   return removed.get();
 }