Trying to convert the this section of code to get rid of the lambda expressions so it'll be able to work in java 7
System.out.println(nicksGraph.findPath(nicksGraph.nodeWith(new Coordinate(0,0)), (a->a.getX()==3 && a.getY()==1), new PriorityQueue, Integer>(funcTotal)));
I've looked around but maybe I'm just not understanding it correctly.
解决方案
In Java 8, a lambda expression is a substitute for an anonymous inner class that implements a functional interface. It looks like here you're using a Predicate, because the expression is a boolean.
The Predicate interface was introduced in Java 8, so you need to re-create it yourself. You will not be able to create default or static methods, so just keep the functional interface method.
public interface Predicate
{
public boolean test(T t);
}
Then, replace the lambda expression with the anonymous class declaration.
System.out.println(nicksGraph.findPath(
nicksGraph.nodeWith(new Coordinate(0,0)),
// Replacement anonymous inner class here.
new Predicate() {
@Override
public boolean test(Coordinate a) {
// return the lambda expression here.
return a.getX()==3 && a.getY()==1;
}
},
new PriorityQueue, Integer>(funcTotal)));