public class ModifiableResult<E> extends Object implements MutableResult<E>, ObservableCollection<E>
Constructor and Description |
---|
ModifiableResult(Result<E> result,
CollectionChanges<?,E> changes) |
Modifier and Type | Method and Description |
---|---|
void |
add(E element)
Adds the specified element.
|
void |
close()
Close this result and any resources it holds.
|
<C extends Collection<E>> |
collect(C collection)
Fill the given collection with all elements from this result set.
|
void |
each(Consumer<? super E> action)
Consume the results with the given
Consumer . |
E |
first()
Gets the first element of this result set.
|
E |
firstOr(E defaultElement)
Gets the first element or a default value.
|
E |
firstOr(Supplier<E> supplier)
Gets the first element or a default value from a
Supplier . |
E |
firstOrNull()
Gets the first element or a default null value.
|
CloseableIterator<E> |
iterator() |
CloseableIterator<E> |
iterator(int skip,
int take)
Creates a
AutoCloseable Iterator over a window of the elements
in this result. |
CollectionObserver<E> |
observer() |
void |
remove(E element)
Removes the specified element.
|
Stream<E> |
stream() |
List<E> |
toList()
Converts this result into a list.
|
<K> Map<K,E> |
toMap(Expression<K> key)
Map the results into a new map using an expression of the result element as a key.
|
<K> Map<K,E> |
toMap(Expression<K> key,
Map<K,E> map)
Map the results into the given map using an expression of the result element as a key.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
forEach, spliterator
public ModifiableResult(Result<E> result, CollectionChanges<?,E> changes)
public CollectionObserver<E> observer()
observer
in interface ObservableCollection<E>
public void add(E element)
MutableResult
Result.iterator()
but will not be persisted to the backing store until update is called
for the entity holding this object.add
in interface MutableResult<E>
element
- to addpublic void remove(E element)
MutableResult
Result.iterator()
. Note the element is not actually removed from the backing store until
the entity holding this object is updated.remove
in interface MutableResult<E>
element
- to removepublic CloseableIterator<E> iterator()
public CloseableIterator<E> iterator(int skip, int take)
Result
AutoCloseable
Iterator
over a window of the elements
in this result.public void close()
Result
close
in interface Result<E>
close
in interface AutoCloseable
public List<E> toList()
Result
public <C extends Collection<E>> C collect(C collection)
Result
public E first() throws NoSuchElementException
Result
first
in interface Result<E>
NoSuchElementException
- if there is no first element (empty result).public E firstOr(E defaultElement)
Result
public E firstOrNull()
Result
firstOrNull
in interface Result<E>
public E firstOr(Supplier<E> supplier)
Result
Supplier
.public void each(Consumer<? super E> action)
Result
Consumer
. In Java 8 use Iterable.forEach(java.util.function.Consumer<? super T>)
instead.public <K> Map<K,E> toMap(Expression<K> key)
Result