I am looking for a way to pass a method by reference. I understand that Java does not pass methods as parameters, however, I would like to get an alternative.
I\'ve
I'm not a java expert but I solve your problem like this:
@FunctionalInterface
public interface AutoCompleteCallable {
String call(T model) throws Exception;
}
I define the parameter in my special Interface
public void initialize(List entries, AutoCompleteCallable getSearchText) {.......
//call here
String value = getSearchText.call(item);
...
}
Finally, I implement getSearchText method while calling initialize method.
initialize(getMessageContactModelList(), new AutoCompleteCallable() {
@Override
public String call(Object model) throws Exception {
return "custom string" + ((xxxModel)model.getTitle());
}
})