I am trying to implement a sample lib using which client can execute their code, to achieve it I am using a functional programming feature of JAVA. But getting compilation error The target type of this expression must be a functional interface
@FunctionalInterface
public interface ImplemenetIt<T> {
public T provideYourImpl();
}
public class HighOrderFunctionClass<T> {
public T executeCode(ImplemenetIt<T> it, T defaultAnswer) {
T answer = defaultAnswer;
return () -> { // At this line I am getting error
try {
answer = it.provideYourImpl();
} catch (Exception ex) {
} finally {
return answer;
}
};
}
}
Please, suggest what I am missing.