Package org.atlanmod.commons.collect
Class MoreStreams
- java.lang.Object
-
- org.atlanmod.commons.collect.MoreStreams
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Optional<Integer>indexOf(Stream<?> stream, Object value)Finds the index of the givenvaluein thestream.static Optional<Integer>lastIndexOf(Stream<?> stream, Object value)Finds the last index of the givenvaluein thestream.static IntUnaryOperatorreverseOrder(int startInclusive, int endExclusive)Returns an unary operator to iterates over anIntStreamin the reverse direction.static LongUnaryOperatorreverseOrder(long startInclusive, long endExclusive)Returns an unary operator to iterates over anLongStreamin the reverse direction.static Optional<Integer>size(Stream<?> stream)Returns the number of element in thestreamas an integer;
-
-
-
Method Detail
-
indexOf
@Nonnull public static Optional<Integer> indexOf(Stream<?> stream, Object value)
Finds the index of the givenvaluein thestream.- Parameters:
stream- the stream to search through for the objectvalue- the value to find- Returns:
- an
Optionalcontaining the index of the value within the stream,Optional.empty()if not found
-
lastIndexOf
@Nonnull public static Optional<Integer> lastIndexOf(Stream<?> stream, Object value)
Finds the last index of the givenvaluein thestream.- Parameters:
stream- the stream to traverse for looking for the objectvalue- the value to find, may benull- Returns:
- an
Optionalcontaining the index of the value within the stream,Optional.empty()if not found
-
size
@Nonnull public static Optional<Integer> size(Stream<?> stream)
Returns the number of element in thestreamas an integer;- Parameters:
stream- the stream- Returns:
- an
Optionalcontaining the size,Optional.empty()if the stream is empty
-
reverseOrder
@Nonnull public static IntUnaryOperator reverseOrder(int startInclusive, int endExclusive)
Returns an unary operator to iterates over anIntStreamin the reverse direction.- Parameters:
startInclusive- the (inclusive) initial valueendExclusive- the exclusive upper bound- Returns:
- an unary operator
- See Also:
IntStream.range(int, int)
-
reverseOrder
@Nonnull public static LongUnaryOperator reverseOrder(long startInclusive, long endExclusive)
Returns an unary operator to iterates over anLongStreamin the reverse direction.- Parameters:
startInclusive- the (inclusive) initial valueendExclusive- the exclusive upper bound- Returns:
- an unary operator
- See Also:
LongStream.range(long, long)
-
-