I have an interface that looks like
public interface ListAbstractor
{
List<String> getList();
void addTo(String s);
}
I want to use it for unit tests on get/set/verify operations on a class with several List<String> get_xxxx and void addToList(String) functions. I would LIKE to declare it with the minimal amount of verbage (I'm ocd that way).
I've seen examples where interfaces (with one method) are implemented in a lovely one line lambda:
interface IntegerMath {
int operation(int a, int b);
}
...
IntegerMath addition = (a, b) -> a + b;
I want to implement it something like:
ListAbstractor la =
new ListAbstractor()
{
getList = ()-> settings.getZooKeeperList();
addTo = (s)-> settings.addToZookeeperList(s);
};
but eclipse does not like this. So what is the short'n'sweetest way to do this?