Lightweight-Stream-API

Stream API from Java 8 rewritten on iterators for Java 7 and below

APACHE-2.0 License

Stars
1.6K
Committers
25

Bot releases are visible (Hide)

Lightweight-Stream-API - v1.2.2 Latest Release

Published by aNNiMON over 3 years ago

  • Added teeing collector (from Java 12)
  • Added mapMulti operator for all streams and mapMultiToInt, mapMultiToLong, mapMultiToDouble to object Stream (from Java 16)
  • Added findFirstOrElse(defaultValue), append(T), prepend(T) to Stream (thanks to @wjtxyz)
  • concat now supports 3+ streams or iterators
  • Added SpinedBuffer for objects. SpinedBuffer now public, but it slightly differs from Java 8 API.
  • Fixed unnecessary unboxing of dropWhile, takeUntil, filterIndexed, mapIndexed and scan operators in primitive streams
  • Methods marked with nullability annotations
  • Many other improvements
Lightweight-Stream-API - v1.2.1

Published by aNNiMON about 6 years ago

  • Added ofNullable for primitive Optionals (thanks to @mannodermaus)
  • Added filterIndexed, mapIndexed, forEachIndexed operators to primitive streams (thanks to @PromanSEW)
  • Added an ability to combine multiple predicates (thanks to @SunnyJithin for suggestion)
  • Added isEmpty method for Optionals (from Java 11)
Lightweight-Stream-API - v1.2.0

Published by aNNiMON over 6 years ago

  • Added Optional.mapToBoolean (thanks to @bejibx)
  • Added Stream.equalsOnly operator (thanks to @operando)
  • Added deepEquals, requireNonNullElse, requireNonNullElseGet, isNull, nonNull and requireNonNullElements methods to Objects (thanks @ened for suggestion)
  • Added orElseThrow() method to Optional classes. Please, prefer this method instead of get() as it better reflects the behavior of the method
  • Added toUnmodifiableList(), toUnmodifiableSet() and toUnmodifiableMap() collectors from Java 10 (thanks to @javadev and @PromanSEW). See PromanSEW's comment
  • The Collectors.toMap implementation was changed to match Java 8 specs. toMap(keyMapper), toMap(keyMapper, valueMapper) and toMap(keyMapper, valueMapper, mapFactory) now disallows duplicate keys. If the mapped keys contain duplicates, use new toMap(keyMapper, valueMapper, mergeFunction) and toMap(keyMapper, valueMapper, mergeFunction, mapFactory) methods
  • Removed useless FunctionalInterface annotation
  • Removed deprecated Stream.getIterator method
Lightweight-Stream-API - v1.1.9

Published by aNNiMON about 7 years ago

  • Added custom operators for Optionals (thanks to @dr-projectiro for suggestion)
  • Added filterNot for Optionals
  • Added Stream.merge operator (thanks to @landawn)
  • Added Stream.concat for iterators
  • Added Stream.ofNullable for array, map and iterator (thanks to @petnagy)
  • Added Collectors.partitioningBy
  • Added getOrElse(Supplier), isPresent and custom operators support for Exceptional (thanks to @PromanSEW)
Lightweight-Stream-API - v1.1.8

Published by aNNiMON over 7 years ago

  • Added findIndexed operator. Thanks to @PromanSEW
  • Added an ability to run action after closing streams. Stream classes now implements Closeable, close and onClose methods are added. Thanks to @frett
    Notice that it is not necessary to close all streams. Please, refer to official Stream API documentation: https://docs.oracle.com/javase/8/docs/api/java/util/stream/Stream.html
  • Added IntStream ofCodePoints. Thanks to @arturogutierrez
  • Added OptionalBoolean and boolean functional interfaces. Thanks to @PromanSEW
  • Added distinctBy and findLast operators. Small optimization of distinct operator. Thanks to @landawn

streamTest

  • Added OptionalBooleanMatcher
Lightweight-Stream-API - v1.1.7

Published by aNNiMON over 7 years ago

  • Added primitive throwable interfaces and Util.safe converters. Thanks to @PromanSEW
  • Improved comparators chaining in ComparatorCompat . Thanks to @BattleShipPark
  • Fixed filter operator in primitive streams. Thanks to @RomainPiel
  • Removed deprecated Stream.ofRange methods.
  • Iterators moved to separate package.

Warning

If you're using PrimitiveIterator, PrimitiveExtIterator or LsaExtIterator to create own custom operators, please, fix imports:

// Before
import com.annimon.stream.PrimitiveIterator;
import com.annimon.stream.LsaExtIterator;

// After
import com.annimon.stream.iterator.PrimitiveIterator;
import com.annimon.stream.iterator.LsaExtIterator;

If you're using ComparatorCompat.chain, see #110

streamTest

  • StreamMatcher.elements now uses Iterable matcher
  • Removed deprecated StreamMatcher.isNotEmpty method
Lightweight-Stream-API - v1.1.6

Published by aNNiMON over 7 years ago

  • Added Stream.withoutNulls() Stream.nullsOnly() and Predicate.Util.notNull(). Thanks to @IlyaGulya
  • Added Java 8 Comparator backport. Thanks to @BattleShipPark
  • Added Objects.compareInt and Objects.compareLong — backport of Java 7 Integer.compare and Long.compare
  • Added takeUntil and scan operators
  • Added indexed operators: filterIndexed, mapIndexed, takeWhileIndexed, takeUntilIndexed, dropWhileIndexed, reduceIndexed, forEachIndexed and indexed functional interfaces.
    Many thanks to @dalewking for help and suggestions.
  • Fixed unnecessary boxing in filter, flatMap, scan and single operators of primitive streams.
  • Reduced calls to first iterator in Stream.concat
  • Stream operators now placed into named classes in separate package. It can speed up the execution and improve stack trace readability. See an example.
  • Many other fixes and improvements.

streamTest

  • Added stream custom operator assertions:

    Stream.range(1, 4).custom(assertElements(contains(1, 2, 3)))
    
  • Update mockito to 2.7.13

Lightweight-Stream-API - v1.1.5

Published by aNNiMON over 7 years ago

  • Added Stream.ofNullable(T element) and Stream.ofNullable(iterable) methods
  • Added Stream.toList() which can be much faster and convenient than collect(Collectors.toList()) (thanks to @akonior for both great ideas)
  • Fixed NPE in flatMap iterator of primitive streams
  • New faster implementation of Stream.distinct()
  • Added iterate(T seed, Predicate p, UnaryOperator op) method for all streams
Lightweight-Stream-API - v1.1.4

Published by aNNiMON almost 8 years ago

  • Added LongStream and DoubleStream
  • Added OptionalLong and OptionalDouble
  • Added functional interfaces for operating with long and double primitive types
  • Added Exceptional.of(Throwable) factory method (thanks to @arturdm)
  • Added mapToLong, mapToDouble, flatMapToLong, flatMapToDouble to Stream
  • Added mapToLong, mapToDouble to IntStream
  • Added mapToLong, mapToDouble to Optional
  • Added filter, ifPresentOrElse, mapToLong and mapToDouble methods to OptionalInt
  • Added longs and doubles methods to RandomCompat
  • Fixed IllegalArgumentException in RandomCompat ints method, when bound is greater than max int
  • Fixed IntStream rangeClosed deadlock on Integer.MAX_VALUE bound
  • Stream range and rangeClosed now uses IntStream/LongStream internally
  • Removed unnecessary abstraction in primitive streams
  • Small other optimizations and javadocs fixes

streamTest

  • Added IntStreamMatcher, LongStreamMatcher and DoubleStreamMatcher
  • Added OptionalLongMatcher, OptionalDoubleMatcher
  • Updated mockito version to 2.2.17
Lightweight-Stream-API - v1.1.3

Published by aNNiMON almost 8 years ago

  • Added summingInt, summingLong, summingDouble, averagingInt, averagingLong, averagingDouble collectors
  • Added flatMapping and filtering collectors, which introduced in Java 9
  • Added ToLongFunction and ToDoubleFunction interfaces
  • Added Optional.mapToInt, OptionalInt.map and OptionalInt.mapToObj methods
  • Added IntStream.single, IntStream.findSingle methods
  • Collectors.counting now uses summingLong to avoid unnecessary boxing
  • Collectors.averaging now deprecated and uses averagingDouble internally, also fixed NaN result for empty stream
  • Improved JavaDocs
Lightweight-Stream-API - v1.1.2

Published by aNNiMON about 8 years ago

distinct method now preserves order (thanks to @pawelkw for having noticed this issue)
Improved error checking in sample method
Added single and findSingle methods (thanks to @xsveda)
Added recover and recoverWith methods to Exceptional (see #66)
Added executeIfPresent and executeIfAbsent methods to Optional and OptionalInt (see #68)
Added ifPresent method to Exceptional
Ability to invoke zip method with Iterator to prevent unnecessary wraping to Stream
Added index operator to Stream
Other fixes and improvements

Lightweight-Stream-API - v1.1.1

Published by aNNiMON about 8 years ago

Added IntStream, OptionalInt and RandomCompat.ints(). Many thanks to @andrey-shikhov for the great work!
Fixed Stream filter causing infinite loop in some cases (issue #53)
Added mapToInt and flatMapToInt to Stream
Added stream, or methods to Optional
Added or method to Exceptional
Stream getIterator is now deprecated, use iterator() instead
Removed method Stream.of(List). This may breaks binary compatibility!
LinkedList replaced with ArrayDeque in sample, slidingWindow methods for performance enhancement. Android 2.1 and 2.2 still uses LinkedList. See #61
Other fixes and optimizations

stream-test v1.1.1

Added OptionalIntMatcher
Added hasValue and hasValueThat methods to OptionalMatcher
Now streamTest library version matches stream version

Lightweight-Stream-API - v1.1.0

Published by aNNiMON over 8 years ago

Fixed compatibility with Android 2.1. Thanks to @andrey-shikhov
Added map method to Exceptional
Added throwable functions and safe method to convert them into normal functions
Added select method to Optional. Thanks to @xsveda

stream-test v1.0.1

Fixed Optional.isEmpty() matches against null value
Added StreamMatcher.hasElements()
Added OptionalMatcher for Mockito

Lightweight-Stream-API - v1.0.9

Published by aNNiMON over 8 years ago

  • Fixed non-RandomAccess List accessed by index. Thanks to @ypresto
  • Added select(Class) method to filter stream by type. Thanks to @andrey-shikhov
  • Added filterNot method
  • Published stream-test:1.0.0 artifact with Hamcrest matchers
Lightweight-Stream-API - v1.0.8

Published by aNNiMON over 8 years ago

  • Added Stream.zip function. Thanks to @ypresto
  • Added chunkBy and slidingWindow operators. Thanks to @solderra
  • Added takeWhile and dropWhile operators
  • Added Stream.empty()
  • Added Function.Util.compose
  • Fixed stream sorted and distinct laziness
  • Minor generics and javadocs fixes
Lightweight-Stream-API - v1.0.7

Published by aNNiMON over 8 years ago

  • Added toArray methods. Thanks to @archinamon
  • ofRange and ofRangeClosed is now deprecated, use range and rangeClosed instead (see Java 8 IntStream). Thanks to @ypresto for suggestion
  • Fixed stream skip laziness.
Lightweight-Stream-API - v1.0.6

Published by aNNiMON over 8 years ago

  • More general reduce interface. Thanks to @Wopple
    Before: T reduce(T identity, BiFunction<T, T, T> accumulator)
    Now: R reduce(R identity, BiFunction<? super R, ? super T, ? extends R> accumulator)
  • Fixed incorrect Iterator implementation on filter and flatMap operators, that breaks concat results. Thanks to @kotucz
Lightweight-Stream-API - v1.0.5

Published by aNNiMON almost 9 years ago

  • Add custom method to Stream for apply custom operators. See CustomOperators,java.
  • Add rangeClosed, concat methods to Stream
  • Minor javadocs fixes
Lightweight-Stream-API - v1.0.4

Published by aNNiMON almost 9 years ago

  • Add methods toCollection, toMap, mapping, reducing, collectingAndThen to Collectors
  • Add JavaDocs
  • Small optimizations and other fixes
Lightweight-Stream-API - v1.0.3

Published by aNNiMON about 9 years ago

  • Add methods groupingBy, counting, joining with parameters (thanks to @fabioCollini) to Collectors
  • Add ThrowableSupplier to use in lambda expressions without writing try/catch in its body
  • Add Exceptional to operate throwable blocks in functional way
  • Add groupBy and Scala-like sortBy methods to Stream
  • Add Stream.generate and Stream.iterate methods
Package Rankings
Top 7.49% on Repo1.maven.org
Top 5.85% on Proxy.golang.org
Badges
Extracted from project README
Coverage Status SonarCloud Status SonarCloud Quality Gate Build Status Maven Central javadoc
Related Projects