Java(FX) - Only allow 1 class to call a method from a singleton class
问题 I'm currently working on a project where I'm using a singleton class to change the view for the user. This DisplayManager (the singleton) has methods like addView(View view) and replaceView(View view) . But it also has a method called displayRootView() which may only be called once (during init) and by only 1 class, i.e. the StartUp class that extends the Application class. Any idea as to how I can prevent other classes who use the singleton from calling the displayRootView() method? I