I am trying to implement 'and' and 'or' methods in Bifunction the way we have in Predicates.
So, my bifunction functional interface has one abstract method - which takes two objects as arguments and returns a list .
I tried this:
public interface TriFunctionInterface<T, U, R> {
List<R> applyFilter(T t, U u, List<R> r);
default TriFunctionInterface or(TriFunctionInterface other) {
Objects.requireNonNull(other);
return (T t, U u, List<R> r) -> {
List<R> finalList = new ArrayList<>();
List<R> filteredObjects1 = applyFilter(t, u, r);
List<R> filteredObjects2 = other.applyFilter(t, u, r);
finalList.addAll(filteredObjects1);
finalList.addAll(filteredObjects2);
return finalList;
};
}
}
But it seems to be give me an error at this line: 'return (T t, U u, List r) -> {'
it seems to be give me an error
It does give an error, which says:
Error:(11, 16) java: incompatible types: incompatible parameter types in lambda expression.
This error is caused by the fact that your method uses raw types instead of proper generic types. It should be
default TriFunctionInterface<T, U, R> or(TriFunctionInterface<T, U, R> other)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.