Is there a way that I can have a method in a class that is executed every time I call any method of this class.
I will briefly talk about my scenario:
Class Util{ private isConnected(){ if(!xxxapi.connected()) throw new MyException(....) } public createFile(){....} public removeFile(){....} }
So, anytime I call new Util.createFile() , I want this isConnected () to be called before createFile() starts. Obviously, I can call isConnected() every time I run each method, but I was wondering if I could have a different solution.
Is there any other suggestion / solution for such a scenario.
source share