public final class StreamUtils
extends java.lang.Object
| Modifier and Type | Method and Description |
|---|---|
static <T> boolean |
allMatch(java.util.Collection<T> objects,
java.util.function.Predicate<T> predicate)
Given a
Collection of objects of type <T> and a Predicate, returns a
boolean value indicating whether all of the values in the collection match the predicate. |
static <T> boolean |
anyMatch(java.util.Collection<T> objects,
java.util.function.Predicate<T> predicate)
Given a
Collection of objects of type <T> and a Predicate, returns a
boolean value indicating whether any of the values in the collection match the predicate. |
static <T> long |
count(java.util.Collection<T> objects,
java.util.function.Predicate<T> predicate)
Given a
Collection of objects of type <T>, and a Predicate, returns a
long value indicating the number of elements in the collection that match the predicate. |
static <T> java.util.stream.Stream<T> |
defaultStream(java.util.Collection<T> objects)
Given a
Collection of elements of type <T>, returns a Stream of those elements. |
static <T> java.util.stream.Stream<T> |
defaultStream(java.util.stream.Stream<T> stream)
Given a
Stream of elements of type <T>, returns that stream if it is not null,
otherwise returns an empty Stream. |
static <T> java.util.stream.Stream<T> |
defaultStream(T target)
Given a single element of type <T>, returns a
Stream containing only that element. |
static <T> java.util.stream.Stream<T> |
defaultStream(T[] array)
Given an array of elements of type <T>, returns a
Stream of them. |
static <T> T |
findAnyDefaultNull(java.util.Collection<T> objects,
java.util.function.Predicate<T> predicate)
Attempt to find any matching element in a
Collection of elements of type <T> using a
predicate, returning null if one is not found. |
static <T> T |
findAnyWithDefault(java.util.Collection<T> objects,
org.perro.functions.stream.FindWithDefault<T> findWithDefault)
Attempt to find any matching element in a
Collection of elements of type <T> using a
predicate, returning a default element if one is not found. |
static <T> T |
findAnyWithDefault(java.util.Collection<T> objects,
org.perro.functions.stream.FindWithDefaultSupplier<T> findWithDefaultSupplier)
Attempt to find any matching element in a
Collection of elements of type <T> using a
predicate, returning a default value retrieved using a Supplier if one is not found. |
static <T> T |
findFirstDefaultNull(java.util.Collection<T> objects,
java.util.function.Predicate<T> predicate)
Attempt to find the first matching element in a
Collection of elements of type <T> using a
predicate, returning null if one is not found. |
static <T> T |
findFirstWithDefault(java.util.Collection<T> objects,
org.perro.functions.stream.FindWithDefault<T> findWithDefault)
Attempt to find the first matching element in a
Collection of elements of type <T> using a
predicate, returning a default element if one is not found. |
static <T> T |
findFirstWithDefault(java.util.Collection<T> objects,
org.perro.functions.stream.FindWithDefaultSupplier<T> findWithDefaultSupplier)
Attempt to find the first matching element in a
Collection of elements of type <T> using a
predicate, returning a default value retrieved using a Supplier if one is not found. |
static <T> org.perro.functions.stream.FindWithDefaultSupplier<T> |
findWithDefault(java.util.function.Predicate<T> predicate,
java.util.function.Supplier<T> defaultSupplier)
Retrieves an object representing a predicate for finding a value, and a default
Supplier if one is
not found. |
static <T> org.perro.functions.stream.FindWithDefault<T> |
findWithDefault(java.util.function.Predicate<T> predicate,
T defaultValue)
Retrieves an object representing a predicate for finding a value, and a default element of type <T> if one
is not found.
|
static <T> java.util.stream.Stream<T> |
fromIterator(java.util.Iterator<T> iterator)
Given an
Iterator of elements of type <T>, returns a Stream of those elements. |
static <T> int |
indexOfFirst(java.util.Collection<T> objects,
java.util.function.Predicate<T> predicate)
Finds the index of the first element in a
Collection of type <T>, that matches a
Predicate. |
static <T> java.lang.String |
join(java.util.Collection<T> objects,
org.perro.functions.stream.CharSequenceMapperWithCollector<T> mapperWithCollector)
Given a
Collection of elements of type <T>, and an object representing a Function
that takes an element of type <T> and returns a CharSequence, and a joining Collector, this
method builds a String of those char sequences joined together using the collector. |
static <T> java.lang.String |
join(java.util.Collection<T> objects,
org.perro.functions.stream.CharSequenceMapperWithDelimiter<T> mapperWithDelimiter)
Given a
Collection of elements of type <T>, and an object representing a Function
that takes an element of type <T> and returns a CharSequence, and a delimiter, this method
builds a String of those char sequences joined together using the delimiter. |
static <T> java.lang.String |
join(java.util.Collection<T> objects,
java.util.function.Function<T,java.lang.CharSequence> mapper)
Given a
Collection of elements of type <T>, and a Function that takes an element
of type <T> and returns a CharSequence, this method builds a String of those
char sequences joined together using "," as a delimiter. |
static <T> org.perro.functions.stream.CharSequenceMapperWithCollector<T> |
mapperWithCollector(java.util.function.Function<T,java.lang.CharSequence> charSequenceMapper,
java.util.stream.Collector<java.lang.CharSequence,?,java.lang.String> joiner)
Builds an object representing a
Function that takes an element of type <T> and returns a
CharSequence, and a joining Collector. |
static <T> org.perro.functions.stream.CharSequenceMapperWithDelimiter<T> |
mapperWithDelimiter(java.util.function.Function<T,java.lang.CharSequence> charSequenceMapper,
java.lang.CharSequence delimiter)
Builds an object representing a
Function that takes an element of type <T> and returns a
CharSequence, and a delimiter. |
static <T extends java.lang.Comparable<T>> |
maxDefault(java.util.Collection<T> objects,
org.perro.functions.stream.FindWithDefault<T> findWithDefault)
Given a
Collection of elements of type <T>, and an object representing a
Predicate along with a default value of type <T>, this method returns the maximum element in
the Collection that matches the predicate, or the default value if no matching element is found. |
static <T extends java.lang.Comparable<T>> |
maxDefault(java.util.Collection<T> objects,
org.perro.functions.stream.FindWithDefaultSupplier<T> findWithDefaultSupplier)
Given a
Collection of elements of type <T>, and an object representing a
Predicate along with a Supplier for a default value, this method returns the maximum
element in the Collection that matches the predicate, or a default value from the supplier if no matching element
is found. |
static <T extends java.lang.Comparable<T>> |
maxDefaultNull(java.util.Collection<T> objects,
java.util.function.Predicate<T> predicate)
Given a
Collection of elements of type <T> and a Predicate, this method returns
the maximum element in the collection that matches the predicate, returning null if none are found. |
static <T extends java.lang.Comparable<T>> |
minDefault(java.util.Collection<T> objects,
org.perro.functions.stream.FindWithDefault<T> findWithDefault)
Given a
Collection of elements of type <T>, and an object representing a
Predicate along with a default value of type <T>, this method returns the minimum element in
the Collection that matches the predicate, or the default value if no matching element is found. |
static <T extends java.lang.Comparable<T>> |
minDefault(java.util.Collection<T> objects,
org.perro.functions.stream.FindWithDefaultSupplier<T> findWithDefaultSupplier)
Given a
Collection of elements of type <T>, and an object representing a
Predicate along with a Supplier for a default value, this method returns the minimum
element in the Collection that matches the predicate, or a default value from the supplier if no matching element
is found. |
static <T extends java.lang.Comparable<T>> |
minDefaultNull(java.util.Collection<T> objects,
java.util.function.Predicate<T> predicate)
Given a
Collection of elements of type <T> and a Predicate, this method returns
the minimum element in the collection that matches the predicate, returning null if none are found. |
static <T> boolean |
noneMatch(java.util.Collection<T> objects,
java.util.function.Predicate<T> predicate)
Given a
Collection of objects of type <T> and a Predicate, returns a
boolean value indicating whether none of the values in the collection match the predicate. |
static <T> java.util.Set<T> |
subtract(java.util.Set<T> from,
java.util.Set<T> toSubtract)
Given a
Set from which to subtract the elements of another one, returns a Set of the
remaining elements. |
static <T> java.util.List<java.util.List<T>> |
toPartitionedList(java.util.Collection<T> objects,
int partitionSize)
Given a
Collection of elements of type <T>, and a partition size, this method divides the
collection into a List of lists, each of whose length is at most partitionSize. |
static <T> java.util.stream.Stream<java.util.List<T>> |
toPartitionedStream(java.util.Collection<T> objects,
int partitionSize)
Given a
Collection of elements of type <T>, and a partition size, this method divides the
collection into a Stream of lists, each of whose length is at most partitionSize. |
public static <T> boolean allMatch(java.util.Collection<T> objects,
java.util.function.Predicate<T> predicate)
Collection of objects of type <T> and a Predicate, returns a
boolean value indicating whether all of the values in the collection match the predicate.T - The type of elements in the objects Collection. Extends Comparable.objects - A Collection of objects of type <T>, to be checked whether the given Predicate matches all
of its elements.predicate - A Predicate to match against the elements in the input Collection.public static <T> boolean anyMatch(java.util.Collection<T> objects,
java.util.function.Predicate<T> predicate)
Collection of objects of type <T> and a Predicate, returns a
boolean value indicating whether any of the values in the collection match the predicate.T - The type of elements in the objects Collection. Extends Comparable.objects - A Collection of objects of type <T>, to be checked whether the given Predicate matches any
of its elements.predicate - A Predicate to match against the elements in the input Collection.public static <T> boolean noneMatch(java.util.Collection<T> objects,
java.util.function.Predicate<T> predicate)
Collection of objects of type <T> and a Predicate, returns a
boolean value indicating whether none of the values in the collection match the predicate.T - The type of elements in the objects Collection. Extends Comparable.objects - A Collection of objects of type <T>, to be checked whether the given Predicate matches
none of its elements.predicate - A Predicate to match against the elements in the input Collection.public static <T> long count(java.util.Collection<T> objects,
java.util.function.Predicate<T> predicate)
Collection of objects of type <T>, and a Predicate, returns a
long value indicating the number of elements in the collection that match the predicate.T - The type of elements in the objects Collection.objects - A Collection of objects of type <T>, to be counted for the number of them that match the
given Predicate.predicate - A Predicate to match against the values in the input array.public static <T extends java.lang.Comparable<T>> T maxDefaultNull(java.util.Collection<T> objects,
java.util.function.Predicate<T> predicate)
Collection of elements of type <T> and a Predicate, this method returns
the maximum element in the collection that matches the predicate, returning null if none are found.
Note that <T> must extend Comparable.T - The type of elements in the objects Collection. Extends Comparable.objects - A Collection of elements of type <T> from which to get the maximum element.predicate - A Predicate to match against the elements in the input Collection.public static <T extends java.lang.Comparable<T>> T maxDefault(java.util.Collection<T> objects,
org.perro.functions.stream.FindWithDefault<T> findWithDefault)
Collection of elements of type <T>, and an object representing a
Predicate along with a default value of type <T>, this method returns the maximum element in
the Collection that matches the predicate, or the default value if no matching element is found. Note that
<T> must extend Comparable.T - The type of elements in the objects Collection. Extends Comparable.objects - A Collection of elements of type <T> from which to get the maximum element or the
default value in the given findWithDefault object.findWithDefault - An object representing a Predicate along with a default value of type <T>.public static <T extends java.lang.Comparable<T>> T maxDefault(java.util.Collection<T> objects,
org.perro.functions.stream.FindWithDefaultSupplier<T> findWithDefaultSupplier)
Collection of elements of type <T>, and an object representing a
Predicate along with a Supplier for a default value, this method returns the maximum
element in the Collection that matches the predicate, or a default value from the supplier if no matching element
is found.T - The type of elements in the objects Collection. Extends Comparable.objects - A Collection of elements of type <T> from which to get the maximum element
or the default value from the supplier in the given findWithDefaultSupplier
object.findWithDefaultSupplier - An object representing a Predicate along with a Supplier of a default value.public static <T extends java.lang.Comparable<T>> T minDefaultNull(java.util.Collection<T> objects,
java.util.function.Predicate<T> predicate)
Collection of elements of type <T> and a Predicate, this method returns
the minimum element in the collection that matches the predicate, returning null if none are found.
Note that <T> must extend Comparable.T - The type of elements in the objects Collection. Extends Comparable.objects - A Collection of elements of type <T> from which to get the minimum element.predicate - A Predicate to match against the elements in the input Collection.public static <T extends java.lang.Comparable<T>> T minDefault(java.util.Collection<T> objects,
org.perro.functions.stream.FindWithDefault<T> findWithDefault)
Collection of elements of type <T>, and an object representing a
Predicate along with a default value of type <T>, this method returns the minimum element in
the Collection that matches the predicate, or the default value if no matching element is found. Note that
<T> must extend Comparable.T - The type of elements in the objects Collection. Extends Comparable.objects - A Collection of elements of type <T> from which to get the minimum element or the
default value in the given findWithDefault object.findWithDefault - An object representing a Predicate along with a default value of type <T>.public static <T extends java.lang.Comparable<T>> T minDefault(java.util.Collection<T> objects,
org.perro.functions.stream.FindWithDefaultSupplier<T> findWithDefaultSupplier)
Collection of elements of type <T>, and an object representing a
Predicate along with a Supplier for a default value, this method returns the minimum
element in the Collection that matches the predicate, or a default value from the supplier if no matching element
is found.T - The type of elements in the objects Collection. Extends Comparable.objects - A Collection of elements of type <T> from which to get the minimum element
or the default value from the supplier in the given findWithDefaultSupplier
object.findWithDefaultSupplier - An object representing a Predicate along with a Supplier of a default value.public static <T> T findAnyDefaultNull(java.util.Collection<T> objects,
java.util.function.Predicate<T> predicate)
Collection of elements of type <T> using a
predicate, returning null if one is not found. Here is a contrived example of how this method would
be called - assume WidgetType is an enum representing the type of Widget:
{
Collection<Widget> widgets = ...
return StreamUtils.findAnyDefaultNull(widgets, PredicateUtils.isEqual(WidgetType.PREMIUM, Widget::getType));
}
Or, with static imports:
{
Collection<Widget> widgets = ...
return findAnyDefaultNull(widgets, isEqual(WidgetType.PREMIUM, Widget::getType));
}
T - The type of elements in the objects Collection.objects - A Collection of elements of type <T>.predicate - A predicate for finding an element of type <T>.public static <T> T findAnyWithDefault(java.util.Collection<T> objects,
org.perro.functions.stream.FindWithDefault<T> findWithDefault)
Collection of elements of type <T> using a
predicate, returning a default element if one is not found. Here is a contrived example of how this method would
be called:
{
Collection<Widget> widgets = ...
Widget defaultWidget = ...
return StreamUtils.findAnyWithDefault(widgets, StreamUtils.findWithDefault(PredicateUtils.isEqual(WidgetType.PREMIUM, Widget::getType), defaultWidget));
}
Or, with static imports:
{
Collection<Widget> widgets = ...
Widget defaultWidget = ...
return findAnyWithDefault(widgets, findWithDefault(isEqual(WidgetType.PREMIUM, Widget::getType), defaultWidget));
}
T - The type of elements in the objects Collection.objects - A Collection of elements of type <T>.findWithDefault - An object representing a predicate for finding a value, and a default element one is not
found. Use the findWithDefault(Predicate, Supplier) to provide this parameter.public static <T> T findAnyWithDefault(java.util.Collection<T> objects,
org.perro.functions.stream.FindWithDefaultSupplier<T> findWithDefaultSupplier)
Collection of elements of type <T> using a
predicate, returning a default value retrieved using a Supplier if one is not found. Here is a
contrived example of how this method would be called:
{
Collection<Widget> widgets = ...
return StreamUtils.findAnyWithDefault(widgets, StreamUtils.findWithDefault(PredicateUtils.isEqual(WidgetType.PREMIUM, Widget::getType), Widget::createDefault));
}
Or, with static imports:
{
Collection<Widget> widgets = ...
return findAnyWithDefault(widgets, findWithDefault(isEqual(WidgetType.PREMIUM, Widget::getType), Widget::createDefault));
}
T - The type of elements in the objects Collection.objects - A Collection of elements of type <T>.findWithDefaultSupplier - An object representing a predicate for finding a value, and a default Supplier if
one is not found. Use the findWithDefault(Predicate, Supplier) method to
provide this parameter.public static <T> T findFirstDefaultNull(java.util.Collection<T> objects,
java.util.function.Predicate<T> predicate)
Collection of elements of type <T> using a
predicate, returning null if one is not found. Here is a contrived example of how this method would
be called - assume WidgetType is an enum representing the type of Widget:
{
Collection<Widget> widgets = ...
return StreamUtils.findFirstDefaultNull(widgets, PredicateUtils.isEqual(WidgetType.PREMIUM, Widget::getType));
}
Or, with static imports:
{
Collection<Widget> widgets = ...
return findFirstDefaultNull(widgets, isEqual(WidgetType.PREMIUM, Widget::getType));
}
T - The type of elements in the objects Collection.objects - A Collection of elements of type <T>.predicate - A predicate for finding an element of type <T>.public static <T> T findFirstWithDefault(java.util.Collection<T> objects,
org.perro.functions.stream.FindWithDefault<T> findWithDefault)
Collection of elements of type <T> using a
predicate, returning a default element if one is not found. Here is a contrived example of how this method would
be called:
{
Collection<Widget> widgets = ...
Widget defaultWidget = ...
return StreamUtils.findFirstWithDefault(widgets, StreamUtils.findWithDefault(PredicateUtils.isEqual(WidgetType.PREMIUM, Widget::getType), defaultWidget));
}
Or, with static imports:
{
Collection<Widget> widgets = ...
Widget defaultWidget = ...
return findFirstWithDefault(widgets, findWithDefault(isEqual(WidgetType.PREMIUM, Widget::getType), defaultWidget));
}
T - The type of elements in the objects Collection.objects - A Collection of elements of type <T>.findWithDefault - An object representing a predicate for finding a value, and a default element one is not
found. Use the findWithDefault(Predicate, Supplier) to provide this parameter.public static <T> T findFirstWithDefault(java.util.Collection<T> objects,
org.perro.functions.stream.FindWithDefaultSupplier<T> findWithDefaultSupplier)
Collection of elements of type <T> using a
predicate, returning a default value retrieved using a Supplier if one is not found. Here is a
contrived example of how this method would be called:
{
Collection<Widget> widgets = ...
return StreamUtils.findFirstWithDefault(widgets, StreamUtils.findWithDefault(PredicateUtils.isEqual(WidgetType.PREMIUM, Widget::getType), Widget::createDefault));
}
Or, with static imports:
{
Collection<Widget> widgets = ...
return findFirstWithDefault(widgets, findWithDefault(isEqual(WidgetType.PREMIUM, Widget::getType), Widget::createDefault));
}
T - The type of elements in the objects Collection.objects - A Collection of elements of type <T>.findWithDefaultSupplier - An object representing a predicate for finding a value, and a default Supplier if
one is not found. Use the findWithDefault(Predicate, Supplier) method to
provide this parameter.public static <T> org.perro.functions.stream.FindWithDefault<T> findWithDefault(java.util.function.Predicate<T> predicate,
T defaultValue)
findAnyWithDefault(Collection, FindWithDefault) or
findFirstWithDefault(Collection, FindWithDefault) for usage examples.T - The type of elements taken by the given Predicate. Also, the type of the defaultValue.predicate - A predicate used in finding a particular element of type <T>.defaultValue - A default element of type <T> to return if one could not be found using the above
predicate.public static <T> org.perro.functions.stream.FindWithDefaultSupplier<T> findWithDefault(java.util.function.Predicate<T> predicate,
java.util.function.Supplier<T> defaultSupplier)
Supplier if one is
not found. See findAnyWithDefault(Collection, FindWithDefaultSupplier) or
findFirstWithDefault(Collection, FindWithDefaultSupplier) for usage examples.T - The type of elements taken by the given Predicate. Also, the return type of the
defaultSupplier.predicate - A predicate used in finding a particular double value.defaultSupplier - A default DoubleSupplier used to return if one could not be found using the above
predicate.public static <T> int indexOfFirst(java.util.Collection<T> objects,
java.util.function.Predicate<T> predicate)
Collection of type <T>, that matches a
Predicate.T - The type of elements in the objects Collection.objects - A Collection of elements of type <T>.predicate - A Predicate used to find a matching value.public static <T> java.lang.String join(java.util.Collection<T> objects,
java.util.function.Function<T,java.lang.CharSequence> mapper)
Collection of elements of type <T>, and a Function that takes an element
of type <T> and returns a CharSequence, this method builds a String of those
char sequences joined together using "," as a delimiter.T - The type of elements in the objects Collection.objects - A Collection of elements of type <T>, each of which is to be mapped to a CharSequence. A
String will be built using each individual CharSequence, delimited by ",".mapper - A Function to map each element of type <T> to a CharSequence.public static <T> java.lang.String join(java.util.Collection<T> objects,
org.perro.functions.stream.CharSequenceMapperWithDelimiter<T> mapperWithDelimiter)
Collection of elements of type <T>, and an object representing a Function
that takes an element of type <T> and returns a CharSequence, and a delimiter, this method
builds a String of those char sequences joined together using the delimiter.T - The type of elements in the objects Collection.objects - A Collection of elements of type <T>, each of which is to be mapped to a
CharSequence. A String will be built using each individual CharSequence.mapperWithDelimiter - An object representing a Function that takes an element of type <T>
and returns a CharSequence, and a delimiter.public static <T> java.lang.String join(java.util.Collection<T> objects,
org.perro.functions.stream.CharSequenceMapperWithCollector<T> mapperWithCollector)
Collection of elements of type <T>, and an object representing a Function
that takes an element of type <T> and returns a CharSequence, and a joining Collector, this
method builds a String of those char sequences joined together using the collector. The
mapperWithCollector(Function, Collector) should be used to build the second parameter to this method.
Because that method takes a Collector<CharSequence, ?, String>, the overloads of the
Java Collector.joining(...) method may be used, including the one that takes a delimiter, prefix and
suffix.T - The type of elements in the objects Collection.objects - A Collection of elements of type <T>, each of which is to be mapped to a
CharSequence. A String will be built using each individual CharSequence.mapperWithCollector - An object representing a Function that takes an element of type <T>
and returns a CharSequence, and a Collector used to join the individual
char sequences together.public static <T> org.perro.functions.stream.CharSequenceMapperWithDelimiter<T> mapperWithDelimiter(java.util.function.Function<T,java.lang.CharSequence> charSequenceMapper,
java.lang.CharSequence delimiter)
Function that takes an element of type <T> and returns a
CharSequence, and a delimiter. Used to build the second parameter to the
join(Collection, CharSequenceMapperWithDelimiter) method.T - The type of elements taken by the given Function.charSequenceMapper - A Function that takes an element of type <T> and returns a CharSequence.delimiter - A delimiter used to join individual char sequences together.public static <T> org.perro.functions.stream.CharSequenceMapperWithCollector<T> mapperWithCollector(java.util.function.Function<T,java.lang.CharSequence> charSequenceMapper,
java.util.stream.Collector<java.lang.CharSequence,?,java.lang.String> joiner)
Function that takes an element of type <T> and returns a
CharSequence, and a joining Collector. Used to build the second parameter to the
join(Collection, CharSequenceMapperWithCollector) method.T - The type of elements taken by the given Function.charSequenceMapper - A Function that takes an element of type <T> and returns a CharSequence.joiner - A joining Collector used to join individual char sequences together.public static <T> java.util.Set<T> subtract(java.util.Set<T> from,
java.util.Set<T> toSubtract)
Set from which to subtract the elements of another one, returns a Set of the
remaining elements. More formally, elements o in the toSubtract set are removed from
the from set if (o==null ? e==null : o.equals(e)) where e is an element in
from.T - The type of elements in the from and toSubtract sets.from - A source set from which to subtract elements.toSubtract - A set of elements to be subtracted from a source set.public static <T> java.util.List<java.util.List<T>> toPartitionedList(java.util.Collection<T> objects,
int partitionSize)
Collection of elements of type <T>, and a partition size, this method divides the
collection into a List of lists, each of whose length is at most partitionSize.T - The type of the elements in the objects parameter.objects - A Collection of elements of type <T> to be partitioned up into a list of lists.partitionSize - The maximum length of the individual lists in the returned list.public static <T> java.util.stream.Stream<java.util.List<T>> toPartitionedStream(java.util.Collection<T> objects,
int partitionSize)
Collection of elements of type <T>, and a partition size, this method divides the
collection into a Stream of lists, each of whose length is at most partitionSize.T - The type of the elements in the objects parameter.objects - A Collection of elements of type <T> to be partitioned up into a stream of lists.partitionSize - The maximum length of the individual lists in the returned stream.public static <T> java.util.stream.Stream<T> fromIterator(java.util.Iterator<T> iterator)
Iterator of elements of type <T>, returns a Stream of those elements.T - The type of elements iterated by the above iterator.iterator - An Iterator of elements of type <T>.public static <T> java.util.stream.Stream<T> defaultStream(java.util.Collection<T> objects)
Collection of elements of type <T>, returns a Stream of those elements.T - The type of the elements in the objects parameter. Also, the type of the elements in the returned
Stream.objects - A Collection of elements of type <T> from which to return a Stream.public static <T> java.util.stream.Stream<T> defaultStream(java.util.stream.Stream<T> stream)
Stream of elements of type <T>, returns that stream if it is not null,
otherwise returns an empty Stream.T - The type of the elements in the objects parameter. Also, the type of the elements in the returned
Stream.stream - An input Stream.public static <T> java.util.stream.Stream<T> defaultStream(T[] array)
Stream of them.T - The type of the elements in the array parameter. Also, the type of the elements in the returned
Stream.array - An array of elements of type <T>.public static <T> java.util.stream.Stream<T> defaultStream(T target)
Stream containing only that element.T - The type of the target element.target - A single element of type <T>.