I'm trying to create a list of suppliers. I have ClassA with instance methods getOne(), getTwo(). Then In ClassB, I have a method to return a list of suppliers as below:
public List<Supplier<String>> getData(){
return Arrays.asList(
ClassA::getOne,
ClassA::getTwo
);
}
I can't make the methods static. I actually need to call getData() from other class. This other class don't know what method from which class to invoke. It just call the getData() from an abstract class (in this case ClassA extends some abstract class) and iterate the list and call those methods. So this other class can call getData() from any instance of the abstract class