I have come across this workaround for making custom events in java and it seems like just what I need.
Although, my concern is how to scale this on, lets say 20 different methods, and I also need them to be optional individually. It is known that you must override all the methods of an interface with no exceptions so at the end i would need 20 nearly similar methods to call event listeners in the exact same way. This is new stuff to me, is there any more convenient way to do this?
What I got in mind (this basically repeated 20 times):
private return_type foo(int foo1, String foo2){
//method does what it is supposed to do
//interested listeners are called, and their purpose is to execute some additional code, for this exact method
fooListener(foo1, foo2);
return something;
}