Skip to content
This repository was archived by the owner on Feb 23, 2020. It is now read-only.

Commit 69e23f8

Browse files
committed
Can now use same functions in Java 7 and Java 8
1 parent 577029a commit 69e23f8

File tree

6 files changed

+1318
-139
lines changed

6 files changed

+1318
-139
lines changed

TestProgramJava7/src/linq/testprogram/java7/LambdaFunctions.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,17 @@ copy of this software and associated documentation files (the
2525

2626
package linq.testprogram.java7;
2727

28+
import linq.lamdba.DefaultLambdaFunctions;
29+
2830
/**
2931
* Created by thoma on 23/02/2016.
3032
*/
31-
public class LambdaFunctions {
33+
public final class LambdaFunctions extends DefaultLambdaFunctions {
3234

33-
public static boolean cond(int i) {
35+
private LambdaFunctions(){
36+
throw new RuntimeException("Can not construct an instance of Lambda Functions");
37+
}
38+
public static boolean conditon(int i) {
3439
return i == 10;
3540
}
3641
}

TestProgramJava7/src/linq/testprogram/java7/Main.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ copy of this software and associated documentation files (the
2626
package linq.testprogram.java7;
2727

2828
import static linq.collections.LinqListFunctionsJava7.LINQJava7;
29-
import linq.lamdba.LINQLambda;
29+
import linq.lamdba.Java7Lambda;
3030

3131
import java.util.ArrayList;
3232

@@ -39,11 +39,16 @@ public static void main(String[] args) {
3939
ArrayList<Integer> list = new ArrayList<Integer>();
4040
list.add(10);
4141
int result = LINQJava7.First(list);
42-
LINQLambda<Boolean> lambda = new LINQLambda<Boolean>(LambdaFunctions.class.getMethod("cond", Integer.TYPE)
42+
Java7Lambda<Boolean> lambda = new Java7Lambda<Boolean>(LambdaFunctions.class.getMethod("Test", Integer.TYPE)
4343
,null
44-
,new Object[]{11});
44+
,new Object[]{10});
4545
boolean all = LINQJava7.All(list, lambda);
46+
lambda = new Java7Lambda<Boolean>(LambdaFunctions.class.getMethod("InRange",Integer.TYPE,Integer.TYPE),
47+
null,
48+
new Object[]{10,15});
49+
boolean contains = LINQJava7.Contains(list,10,lambda);
4650
System.out.println(all);
51+
System.out.println(contains);
4752
} catch (Exception ex) {
4853
ex.printStackTrace(System.err);
4954
}

0 commit comments

Comments
 (0)