Esempio n. 1
0
  /**
   * A mixed reference is equal to another mixed reference if this reference's instance is equal to
   * the given object's instance according to its <code>equals</code> method.
   *
   * @return true if the two references are equal, and false otherwise.
   */
  @Override
  public boolean equals(Object obj) {
    if (obj instanceof MixedReference<?>) {
      MixedReference<?> ref = (MixedReference<?>) obj;
      return ObjectUtils.equals(this.get(), ref.get());
    }

    return false;
  }
Esempio n. 2
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();
  }
Esempio n. 3
0
 /** {@inheritDoc} */
 @Override
 public T remove(final int index) {
   final MixedReference<T> removed = data.remove(index);
   return removed.get();
 }