Skip to content

Commit 845167e

Browse files
committed
feat: Join提供直接支持Collection的api
1 parent 4354bb0 commit 845167e

File tree

2 files changed

+33
-3
lines changed

2 files changed

+33
-3
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
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.1.1</version>
9+
<version>0.1.2-SNAPSHOT</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

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,22 @@ public static <T1, T2> JoinType<T1, T2> fullOuterJoin(Stream<T1> left, Stream<T2
2929
return new JoinType<>(left, right, t -> !(t.getT1() == null && t.getT2() == null));
3030
}
3131

32+
public static <T1, T2> JoinType<T1, T2> innerJoin(Collection<T1> left, Collection<T2> right) {
33+
return innerJoin(left.stream(), right.stream());
34+
}
35+
36+
public static <T1, T2> JoinType<T1, T2> leftOuterJoin(Collection<T1> left, Collection<T2> right) {
37+
return leftOuterJoin(left.stream(), right.stream());
38+
}
39+
40+
public static <T1, T2> JoinType<T1, T2> rightOuterJoin(Collection<T1> left, Collection<T2> right) {
41+
return rightOuterJoin(left.stream(), right.stream());
42+
}
43+
44+
public static <T1, T2> JoinType<T1, T2> fullOuterJoin(Collection<T1> left, Collection<T2> right) {
45+
return fullOuterJoin(left.stream(), right.stream());
46+
}
47+
3248
public static class JoinStream<T1, T2> {
3349

3450
private final Stream<Tuple2<T1, T2>> left;
@@ -49,17 +65,33 @@ public <T3> JoinType<Tuple2<T1, T2>, T3> innerJoin(Stream<T3> right) {
4965
return Join.innerJoin(left, right);
5066
}
5167

68+
public <T3> JoinType<Tuple2<T1, T2>, T3> innerJoin(Collection<T3> right) {
69+
return Join.innerJoin(left, right.stream());
70+
}
71+
5272
public <T3> JoinType<Tuple2<T1, T2>, T3> leftOuterJoin(Stream<T3> right) {
5373
return Join.leftOuterJoin(left, right);
5474
}
5575

76+
public <T3> JoinType<Tuple2<T1, T2>, T3> leftOuterJoin(Collection<T3> right) {
77+
return Join.leftOuterJoin(left, right.stream());
78+
}
79+
5680
public <T3> JoinType<Tuple2<T1, T2>, T3> rightOuterJoin(Stream<T3> right) {
5781
return Join.rightOuterJoin(left, right);
5882
}
5983

84+
public <T3> JoinType<Tuple2<T1, T2>, T3> rightOuterJoin(Collection<T3> right) {
85+
return Join.rightOuterJoin(left, right.stream());
86+
}
87+
6088
public <T3> JoinType<Tuple2<T1, T2>, T3> fullOuterJoin(Stream<T3> right) {
6189
return Join.fullOuterJoin(left, right);
6290
}
91+
92+
public <T3> JoinType<Tuple2<T1, T2>, T3> fullOuterJoin(Collection<T3> right) {
93+
return Join.fullOuterJoin(left, right.stream());
94+
}
6395
}
6496

6597
public static class JoinType<T1, T2> {
@@ -144,8 +176,6 @@ private <T> Collector<T, List<T>, List<T>> toListOrNullList() {
144176
}
145177
);
146178
}
147-
148-
149179
}
150180

151181
}

0 commit comments

Comments
 (0)