Coming from Python and Objective-C land, I may not fully understand what static methods are in Java, I think of them as "methods that operate on all members of the class" or "class-specific methods that are available when you don't have an instance of that class."
But is there a syntax for saying: "This abstract superclass requires each concrete subclass to implement this static method"? I know that static abstract isn't permitted, but it would conceptually be something like this:
public abstract class Lander { @RequireImplmentationInSubclass // clearly my made-up name... static abstract boolean probe(Radio radio); } public class MarsLander extends Lander { static boolean probe(Radio radio) { // ... some MarsLander specific implementation } } public class LunarLander extends Lander { static boolean probe(Radio radio) { // ... some LunarLander specific implementation } } update
... and somewhere else, a factory method does something like:
if (MarsLander.probe(radio)) { ... create an instance of MarsLander and work with it } else if (LunarLander.probe(radio)) { ... create an instance of LunarLander and work with it } In my application, creating an instance invokes a lot of machinery, so I need to call probe() on a class method before I create an instance of the class.
I looked over Is there a way to make sure classes implementing an Interface implement static methods? and most of the responses were "why would you want to do that?".
I hope this example makes it clear(er). Perhaps there's' a more Java-esque way to remind the developer that a class-visible probe() method is required?