Skip to content

Commit 2436131

Browse files
committed
feat: 优化部分代码
1 parent 6057edf commit 2436131

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>com.github.lokic</groupId>
88
<artifactId>java-plus</artifactId>
9-
<version>0.0.14</version>
9+
<version>0.0.15</version>
1010
<name>java-plus</name>
1111
<description>Provide some useful extensions on the basis of java8 to make java more usable.</description>
1212
<url>https://github.com/lokic/java-plus</url>

src/main/java/com/github/lokic/javaplus/Join.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,11 @@ public <K> Stream<Tuple2<T1, T2>> on(Function<T1, K> leftKey, Function<T2, K> ri
4949
.collect(Collectors.groupingBy(t -> matchKey(t, leftKey, rightKey)))
5050
.values()
5151
.stream()
52-
.flatMap(this::product)
52+
.flatMap(this::cartesian)
5353
.filter(this.joinMatcher);
5454
}
5555

56-
private Stream<Tuple2<T1, T2>> product(List<Tuple2<T1, T2>> li) {
56+
private Stream<Tuple2<T1, T2>> cartesian(List<Tuple2<T1, T2>> li) {
5757
Map<Boolean, List<Tuple2<T1, T2>>> map = li.stream()
5858
.collect(Collectors.partitioningBy(this::isLeft, this.toListOrNullList()));
5959
List<Tuple2<T1, T2>> left = map.get(true);

src/main/java/com/github/lokic/javaplus/functional/entry/EntryFunctional.java

+6
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33
import com.github.lokic.javaplus.functional.consumer.Consumer2;
44
import com.github.lokic.javaplus.functional.function.Function2;
55
import com.github.lokic.javaplus.functional.function.Function3;
6+
import com.github.lokic.javaplus.functional.function.Function4;
67
import com.github.lokic.javaplus.functional.predicate.Predicate2;
78
import com.github.lokic.javaplus.tuple.Tuple2;
9+
import com.github.lokic.javaplus.tuple.Tuple3;
810

911
public interface EntryFunctional {
1012

@@ -16,6 +18,10 @@ static <T1, T2, V, R> EntryFunction<Tuple2<T1, T2>, V, R> function(Function3<T1,
1618
return (t, v) -> function3.apply(t.getT1(), t.getT2(), v);
1719
}
1820

21+
static <T1, T2, T3, V, R> EntryFunction<Tuple3<T1, T2, T3>, V, R> function(Function4<T1, T2, T3, V, R> function4) {
22+
return (t, v) -> function4.apply(t.getT1(), t.getT2(), t.getT3(), v);
23+
}
24+
1925
static <K, V> EntryConsumer<K, V> consumer(Consumer2<K, V> consumer2) {
2026
return consumer2::accept;
2127
}

0 commit comments

Comments
 (0)