Add-ons for java.util.function.
TerConsumer<byte[], Integer, Integer> fn = (byte[] bytes, Integer offset, Integer length) -> new String(bytes, offset, length);
TerConsumer<byte[], Integer, Integer> ref = String::new;
TerFunction<String, Integer, Integer, String> fn = (String s, Integer b, Integer e) -> s.substring(b, e);
TerFunction<String, Integer, Integer, String> ref = String::substring;
TerPredicate<Long, Long, Long> predicate3 = (f, s, t) -> f > 0 ^ s > 0 ^ t > 0;
List<String> list = new LinkedList<>();
Stream.of("1", "2", "3")
// s -> list.add(0, s)
.forEach(ConsumerCurrying.left2(list::add, 0));
String value = String.join("", list);
assert "321".equals(value);
String value = Stream.of("1", "22", "333")
// s -> s.substring(0, 1)
.map(FunctionCurrying.right3(String::substring, 0, 1))
.collect(Collectors.joining());
assert "123".equals(value);
String value = Stream.of("-Task", "-Test", "-Text")
// s -> s.startsWith("Te", 1)
.filter(PredicateCurrying.right3(String::startsWith, "Te", 1))
.collect(Collectors.joining());
assert "-Test-Text".equals(value);
See full code in demo.
implementation 'dev.alexengrig:lambda:2.0'
<dependency>
<groupId>dev.alexengrig</groupId>
<artifactId>lambda</artifactId>
<version>2.0</version>
</dependency>
This project is licensed under Apache License, version 2.0.