Classes related to java.util.Function and extensions like Predicate, Consumer and Supplier.
-
Morphing methods like
-
TriFunction#ignoreArg[1-4](…)morphs aTriFunctionto aQuadriFunction -
TriFunction#withArg[1-3](…)morphs aTriFunctionto aBiFunction.
-
-
Utilities for that in
-
Things like
memoize(to memoize the value of a supplier),closeable(to make a SupplierAutoCloseable) andignoreArg(to morph aSupplierto aFunctionthat ignores the argument) are provided.
-
Consistent
equalsandhashCode, for the utility functions that produce functional implementations. E.g. the above mentionedignoreArg*andwithArg*are not simply implemented with lambda’s, but also with equals and hashcode based on the source functional class implementation.
The mihxil-collections module (since 1.18) contains utilities for java.util.Iterator and java.util.Collection, in package org.meeuw.collections. Most of them originate from vpro-shared-util.
-
CloseableIterator: anIteratorthat is alsoAutoCloseable.CloseableIterator.of(iterator)wraps any iterator (closing it if it isAutoCloseableitself). -
PeekingIterator: an iterator with a one-element lookahead (peek()), like guava’s, but without the dependency. -
CountedIterator: an iterator that knows its current position (getCount()), and optionally the size of what it iterates (getSize()) and of some 'total' (getTotalSize()), e.g. when it represents a page of a larger result. -
Combinations of these:
CloseablePeekingIterator,CountedPeekingIterator. -
CloseableSpliterator: aSpliteratorowning a closeable resource.
Most of these are wrappers around another iterator, and can be constructed with a (lombok generated) builder.
-
BatchedReceiver: presents an API that only supports batched retrieval (paging with offset/max, or some 'resumption token') as one simpleIterator.Iterator<String> i = BatchedReceiver.<String>builder() .batchGetter((offset, max) -> apiClient.getPage(offset, max).iterator()) .batchSize(100) .build();
-
MaxOffsetIterator,CountedMaxOffsetIterator: implements 'offset' and 'max' on top of another iterator.MaxOffsetIterator<String> i = MaxOffsetIterator.<String>builder() .wrapped(iterator) .offset(10) .max(20) .build();
-
FilteringIterator: filters an iterator with a predicate, with optional 'keep alive' callbacks for when many consecutive elements are filtered out. -
TransformingIterator: maps the elements of an iterator with a function. -
SkippingIterator: skips elements based on comparison with the previous one (e.g. to remove consecutive duplicates). -
HeadAdder,TailAdder: add elements at the start or at the end of an iterator (the latter possibly based on the last element). -
MergedSortedIterator: merges several sorted iterators into one sorted iterator.merge(…)uses a priority queue,mergeInSameThread(…)doesn’t (so it is also usable with e.g. Hibernate). -
LazyIterator: wraps aSupplier<Iterator>, delaying creation of the actual iterator until it is first used. -
CallbackIterator: calls a callback when iteration is finished. -
WrappedIterator,BasicWrappedIterator: base classes for iterators wrapping another one.
-
TransformingList,TransformingSortedSet: modifiable views on a collection of other element types, given a 'transformer' and its inverse, a 'producer'. Changes are reflected in the wrapped collection. -
ResortedSortedSet: a modifiableSortedSetview on another collection, with an explicit sort order. -
SortedSetElementWrapper,SortedSetSameElementWrapper: base classes forSortedSetviews on a wrapped sorted set.
| Version | date | remarks |
|---|---|---|
2.0 |
2026-10 |
|
1.18 |
2026-08 |
Having collection module too. |
1.17 |
2026-03 |
For the 'Throwing-' functional interfaces, there are now also overridden verison of the 'withArgN' and 'ignoreArgN' morphing methods, that remain 'Throwing-' functional interfaces, and throw the same exception as the original functional interface. |
1.12 |
2025-06-26 |
A.o, introduction of 'CloseableSupplier' and 'UnwrappableSupplier' interfaces, |
1.11 |
2024-05-11 |
|
1.10 |
2023-12 |
|
1.0 |
2020-11-30 |