public class Wrapperable<E>
extends java.lang.Object
implements java.lang.Iterable<E>
| Constructor and Description |
|---|
Wrapperable(java.lang.Iterable<E> iterable,
boolean isSynchronized) |
| Modifier and Type | Method and Description |
|---|---|
void |
add(E element) |
void |
add(int index,
E element)
This may have weird results if the collection instance does not preserve order
|
void |
addAll(java.lang.Iterable<E> other) |
void |
clear() |
Wrapperable<E> |
copyNotMatching(java.util.function.Supplier<Wrapperable<E>> supplier,
java.util.function.Function<E,java.lang.Boolean> matcher) |
protected java.lang.Iterable<E> |
fixInstance(java.lang.Iterable<E> itr)
Handles checking the instance of iterators that may be wrapperable or mappable instances
This is done so the instanceof Collection checks do not fail when they should not
|
void |
forEach(java.util.function.Consumer<? super E> action) |
java.util.Collection<E> |
get() |
E |
get(int index) |
java.util.List<E> |
getAsList() |
java.util.List<E> |
getAsList(java.util.function.Function<Wrapperable<E>,? extends java.util.List<E>> onCastException) |
java.util.Set<E> |
getAsSet() |
java.util.Set<E> |
getAsSet(java.util.function.Function<Wrapperable<E>,? extends java.util.Set<E>> onCastException) |
java.util.List<E> |
getAsSynchronizedList() |
java.util.List<E> |
getAsSynchronizedList(java.util.function.Function<Wrapperable<E>,? extends java.util.List<E>> onCastException) |
<T extends java.util.Collection<E>> |
getAsType(java.lang.Class<T> clazz) |
<T extends java.util.Collection<E>> |
getAsType(java.lang.Class<T> clazz,
@Nullable java.util.function.Function<Wrapperable<E>,? extends java.util.Collection<E>> onCastException)
Syntactic sugar...
|
java.lang.Class<?> |
getElementClass() |
E |
getFirstEquals(@Nullable java.lang.Iterable<E> otherItr)
Runs getFirstMatching with Objects#equals as the matcherFunc
|
E |
getFirstMatching(@Nullable java.lang.Iterable<E> otherItr,
java.util.function.BiFunction<E,E,java.lang.Boolean> matcherFunc)
Iterates through the other iterable for each element of the wrapped iterable and returns the matching element.
|
E |
getNonNullElement()
Gets the first element in the collection that is not null.
|
void |
insertMatching(java.util.Collection<E> output,
java.util.function.Function<E,java.lang.Boolean> matcher) |
<C extends java.util.Collection<E>> |
insertMatching(java.util.function.Supplier<C> outputSupplier,
java.util.function.Function<E,java.lang.Boolean> matcher) |
boolean |
isEmpty() |
boolean |
isList() |
boolean |
isNotEmpty() |
boolean |
isSet() |
boolean |
isUnique() |
@NotNull java.util.Iterator<E> |
iterator() |
static <E> Wrapperable<E> |
make(java.util.function.Supplier<java.lang.Iterable<E>> supplier)
Helper method for iterable suppliers
|
static <E> Wrapperable<E> |
make(java.util.function.Supplier<java.lang.Iterable<E>> supplier,
java.util.function.Consumer<Wrapperable<E>> settings) |
static <E> Wrapperable<E> |
makeArray(java.util.function.Consumer<Wrapperable<E>> settings,
E... elements) |
static <E> Wrapperable<E> |
makeArray(E... elements)
Array versions of the make methods
|
static <E> Wrapperable<E> |
makeArray(java.util.function.Supplier<E[]> supplier) |
static <E> Wrapperable<E> |
makeArray(java.util.function.Supplier<E[]> supplier,
java.util.function.Consumer<Wrapperable<E>> settings) |
static <E> Wrapperable<E> |
makeSynchronized(java.util.function.Supplier<java.lang.Iterable<E>> supplier)
Synchronized versions of the make methods
|
static <E> Wrapperable<E> |
makeSynchronized(java.util.function.Supplier<java.lang.Iterable<E>> supplier,
java.util.function.Consumer<Wrapperable<E>> settings) |
static <E> Wrapperable<E> |
makeSynchronizedArray(java.util.function.Consumer<Wrapperable<E>> settings,
E... elements) |
static <E> Wrapperable<E> |
makeSynchronizedArray(E... elements)
Synchronized versions of the makeArray methods
|
static <E> Wrapperable<E> |
makeSynchronizedArray(java.util.function.Supplier<E[]> supplier) |
static <E> Wrapperable<E> |
makeSynchronizedArray(java.util.function.Supplier<E[]> supplier,
java.util.function.Consumer<Wrapperable<E>> settings) |
<M> Wrapperable<M> |
map(java.util.function.Supplier<Wrapperable<M>> supplier,
java.util.function.Function<E,M> mapper) |
<M> void |
mapTo(java.util.Collection<M> c,
java.util.function.Function<E,M> mapper,
boolean clearExisting,
boolean removeNulls) |
<M,C extends java.util.Collection<M>> |
mapTo(java.util.function.Supplier<C> supplier,
java.util.function.Function<E,M> mapper,
boolean removeNulls) |
<M> void |
mapTo(Wrapperable<M> w,
java.util.function.Function<E,M> mapper,
boolean clearExisting,
boolean removeNulls) |
java.util.stream.Stream<E> |
parallelStream() |
void |
remove(E element) |
void |
removeAll(java.lang.Iterable<E> other) |
boolean |
removeIf(java.util.function.Predicate<? super E> filter) |
void |
removeIndex(int index)
This may have weird results if the collection instance does not preserve order or if the elements are integers
|
void |
set(boolean clearExisting,
E... elements) |
void |
set(boolean clearExisting,
java.lang.Iterable<E> elements) |
void |
set(E... elements) |
void |
set(java.lang.Iterable<E> elements) |
int |
size() |
java.util.Spliterator<E> |
spliterator() |
java.util.stream.Stream<E> |
stream() |
E[] |
toArray() |
java.lang.String |
toString() |
public Wrapperable(java.lang.Iterable<E> iterable, boolean isSynchronized)
public static <E> Wrapperable<E> make(java.util.function.Supplier<java.lang.Iterable<E>> supplier)
public static <E> Wrapperable<E> make(java.util.function.Supplier<java.lang.Iterable<E>> supplier, java.util.function.Consumer<Wrapperable<E>> settings)
public static <E> Wrapperable<E> makeSynchronized(java.util.function.Supplier<java.lang.Iterable<E>> supplier)
public static <E> Wrapperable<E> makeSynchronized(java.util.function.Supplier<java.lang.Iterable<E>> supplier, java.util.function.Consumer<Wrapperable<E>> settings)
public static <E> Wrapperable<E> makeArray(E... elements)
public static <E> Wrapperable<E> makeArray(java.util.function.Consumer<Wrapperable<E>> settings, E... elements)
public static <E> Wrapperable<E> makeArray(java.util.function.Supplier<E[]> supplier)
public static <E> Wrapperable<E> makeArray(java.util.function.Supplier<E[]> supplier, java.util.function.Consumer<Wrapperable<E>> settings)
public static <E> Wrapperable<E> makeSynchronizedArray(E... elements)
public static <E> Wrapperable<E> makeSynchronizedArray(java.util.function.Consumer<Wrapperable<E>> settings, E... elements)
public static <E> Wrapperable<E> makeSynchronizedArray(java.util.function.Supplier<E[]> supplier)
public static <E> Wrapperable<E> makeSynchronizedArray(java.util.function.Supplier<E[]> supplier, java.util.function.Consumer<Wrapperable<E>> settings)
public void add(E element)
public void add(int index,
E element)
public void addAll(java.lang.Iterable<E> other)
public void clear()
public Wrapperable<E> copyNotMatching(java.util.function.Supplier<Wrapperable<E>> supplier, java.util.function.Function<E,java.lang.Boolean> matcher)
protected java.lang.Iterable<E> fixInstance(java.lang.Iterable<E> itr)
public void forEach(java.util.function.Consumer<? super E> action)
forEach in interface java.lang.Iterable<E>public java.util.Collection<E> get()
@Nullable public E get(int index)
public java.util.List<E> getAsList() throws java.lang.ClassCastException
java.lang.ClassCastExceptionpublic java.util.List<E> getAsList(java.util.function.Function<Wrapperable<E>,? extends java.util.List<E>> onCastException)
public java.util.List<E> getAsSynchronizedList() throws java.lang.ClassCastException
java.lang.ClassCastExceptionpublic java.util.List<E> getAsSynchronizedList(java.util.function.Function<Wrapperable<E>,? extends java.util.List<E>> onCastException)
public java.util.Set<E> getAsSet() throws java.lang.ClassCastException
java.lang.ClassCastExceptionpublic java.util.Set<E> getAsSet(java.util.function.Function<Wrapperable<E>,? extends java.util.Set<E>> onCastException)
public <T extends java.util.Collection<E>> T getAsType(java.lang.Class<T> clazz) throws java.lang.ClassCastException
java.lang.ClassCastExceptionpublic <T extends java.util.Collection<E>> T getAsType(java.lang.Class<T> clazz, @Nullable @Nullable java.util.function.Function<Wrapperable<E>,? extends java.util.Collection<E>> onCastException)
public java.lang.Class<?> getElementClass()
@Nullable public E getFirstEquals(@Nullable @Nullable java.lang.Iterable<E> otherItr)
@Nullable public E getFirstMatching(@Nullable @Nullable java.lang.Iterable<E> otherItr, java.util.function.BiFunction<E,E,java.lang.Boolean> matcherFunc)
@Nullable public E getNonNullElement()
public void insertMatching(java.util.Collection<E> output, java.util.function.Function<E,java.lang.Boolean> matcher)
public <C extends java.util.Collection<E>> C insertMatching(java.util.function.Supplier<C> outputSupplier, java.util.function.Function<E,java.lang.Boolean> matcher)
public boolean isEmpty()
public boolean isList()
public boolean isNotEmpty()
public boolean isSet()
public boolean isUnique()
@NotNull public @NotNull java.util.Iterator<E> iterator()
iterator in interface java.lang.Iterable<E>public <M> Wrapperable<M> map(java.util.function.Supplier<Wrapperable<M>> supplier, java.util.function.Function<E,M> mapper)
public <M> void mapTo(Wrapperable<M> w, java.util.function.Function<E,M> mapper, boolean clearExisting, boolean removeNulls)
public <M> void mapTo(java.util.Collection<M> c,
java.util.function.Function<E,M> mapper,
boolean clearExisting,
boolean removeNulls)
public <M,C extends java.util.Collection<M>> C mapTo(java.util.function.Supplier<C> supplier,
java.util.function.Function<E,M> mapper,
boolean removeNulls)
public java.util.stream.Stream<E> parallelStream()
public void remove(E element)
public boolean removeIf(java.util.function.Predicate<? super E> filter)
public void removeAll(java.lang.Iterable<E> other)
public void removeIndex(int index)
public final void set(E... elements)
public final void set(boolean clearExisting,
E... elements)
public void set(java.lang.Iterable<E> elements)
public void set(boolean clearExisting,
java.lang.Iterable<E> elements)
public int size()
public java.util.Spliterator<E> spliterator()
spliterator in interface java.lang.Iterable<E>public java.util.stream.Stream<E> stream()
public E[] toArray()
public java.lang.String toString()
toString in class java.lang.Object