filterMatches(Object)
with a Matcher
or
MatcherEditor
, logic can be reused. That approach is far more flexible and
powerful than the static filtering required by AbstractFilterList.@Deprecated public abstract class AbstractFilterList extends TransformedList
EventList
that shows a subset of the elements of a source EventList
. This
subset is composed of all elements of the source EventList
that match the filter.
The filter can be static or dynamic. Changing the behaviour of the filter will change which elements of the source list are included.
Extending classes define the filter by implementing the method filterMatches(Object)
.
Extending classes must call handleFilterChanged()
when the filter has changed in order
to update the subset of included elements. This method must also be called at the end of the
extending class's constructor.
Warning: This class breaks the contract required by
List
. See EventList
for an example.
Warning: This class is thread ready but not thread
safe. See EventList
for an example of thread safe code.
EventList Overview | |
Writable: | yes |
Concurrency: | thread ready, not thread safe |
Performance: | reads: O(log N), writes O(log N), filter changes O(N) |
Memory: | 0 to 26 bytes per element |
Unit Tests: | N/A |
Issues: | N/A |
source
publisher, readWriteLock, updates
Modifier | Constructor and Description |
---|---|
protected |
AbstractFilterList(EventList source)
Deprecated.
Creates a
AbstractFilterList that includes a subset of the specified source
EventList . |
Modifier and Type | Method and Description |
---|---|
void |
dispose()
Deprecated.
Releases the resources consumed by this
TransformedList so that it may eventually be
garbage collected. |
abstract boolean |
filterMatches(Object element)
Deprecated.
Tests if the specified item from the source
EventList is matched by the current filter. |
protected void |
handleFilterChanged()
Deprecated.
Handles changes to the behavior of the filter.
|
protected void |
handleFilterCleared()
Deprecated.
Handles a clearing of the filter.
|
protected void |
handleFilterConstrained()
Deprecated.
Handles a constraining or narrowing of the filter.
|
protected void |
handleFilterRelaxed()
Deprecated.
Handles a relaxing or widening of the filter.
|
protected boolean |
isWritable()
Deprecated.
Gets whether the source
EventList is writable via this API. |
void |
listChanged(ListEvent listChanges)
Deprecated.
When the underlying list changes, this notification allows the object to repaint itself or
update itself as necessary.
|
add, addAll, clear, get, getSourceIndex, remove, removeAll, retainAll, set, size
add, addAll, addListEventListener, contains, containsAll, equals, getPublisher, getReadWriteLock, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, removeListEventListener, subList, toArray, toArray, toString
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
replaceAll, sort, spliterator
parallelStream, removeIf, stream
protected AbstractFilterList(EventList source)
AbstractFilterList
that includes a subset of the specified source
EventList
.
Extending classes must call handleFilterChanged().
protected void handleFilterCleared()
protected final void handleFilterRelaxed()
protected final void handleFilterConstrained()
protected final void handleFilterChanged()
public abstract boolean filterMatches(Object element)
EventList
is matched by the current filter.public void listChanged(ListEvent listChanges)
It is mandatory that the calling thread has obtained the write lock on the source list. This is because the calling thread will have written to the source list to cause this event. This condition guarantees that no writes can occur while the listener is handling this event. It is an error to write to the source list while processing an event.
listChanged
in interface ListEventListener
listChanged
in class TransformedList
listChanges
- a ListEvent
describing the changes to the listprotected boolean isWritable()
EventList
is writable via this API.
Extending classes must override this method in order to make themselves writable.
isWritable
in class TransformedList
public void dispose()
TransformedList
so that it may eventually be
garbage collected.
A TransformedList
will be garbage collected without a call to dispose()
, but
not before its source EventList
is garbage collected. By calling #dispose()
,
you allow the TransformedList
to be garbage collected before its source
EventList
. This is necessary for situations where a TransformedList
is
short-lived but its source EventList
is long-lived.
Warning: It is an error to call any method on a
TransformedList
after it has been disposed.
dispose
in interface EventList
dispose
in class TransformedList
Copyright © 2024 levigo holding gmbh. All rights reserved.