All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.sf.javagimmicks.collections8.event.AbstractEventSortedSet Maven / Gradle / Ivy

There is a newer version: 0.99-alpha1
Show newest version
package net.sf.javagimmicks.collections8.event;

import java.util.Comparator;
import java.util.SortedSet;

/**
 * A base {@link SortedSet} wrapper that reports changes to internal callback
 * methods - these must be overwritten by concrete implementations in order to
 * react in any way to the changes.
 * 

* Methods that must be overwritten: *

    *
  • {@link #fireElementAdded(Object)}
  • *
  • {@link #fireElementReadded(Object)}
  • *
  • {@link #fireElementRemoved(Object)}
  • *
*/ public abstract class AbstractEventSortedSet extends AbstractEventSet implements SortedSet { private static final long serialVersionUID = 3408305529028504791L; /** * Wraps a new instance around a given {@link SortedSet} * * @param decorated * the {@link SortedSet} to wrap */ public AbstractEventSortedSet(final SortedSet decorated) { super(decorated); } @Override public SortedSet getDecorated() { return (SortedSet) super.getDecorated(); } @Override public Comparator comparator() { return getDecorated().comparator(); } @Override public E first() { return getDecorated().first(); } @Override public E last() { return getDecorated().last(); } @Override public SortedSet headSet(final E toElement) { return new EventSubSortedSet(this, getDecorated().headSet(toElement)); } @Override public SortedSet subSet(final E fromElement, final E toElement) { return new EventSubSortedSet(this, getDecorated().subSet(fromElement, toElement)); } @Override public SortedSet tailSet(final E fromElement) { return new EventSubSortedSet(this, getDecorated().tailSet(fromElement)); } protected static class EventSubSortedSet extends AbstractEventSortedSet { private static final long serialVersionUID = 7103404017576141323L; protected final AbstractEventSortedSet _parent; protected EventSubSortedSet(final AbstractEventSortedSet parent, final SortedSet decorated) { super(decorated); _parent = parent; } @Override protected void fireElementAdded(final E element) { _parent.fireElementAdded(element); } @Override protected void fireElementReadded(final E element) { _parent.fireElementReadded(element); } @Override protected void fireElementRemoved(final E element) { _parent.fireElementRemoved(element); } } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy