How can I assure a class to have a static property by using interface or abstract?

You can’t do that. Interfaces, abstract, etc. cannot apply to static members. If you want to accomplish this, you will have to manually remember to do it on all deriving classes. Also, static members are inherited by deriving classes. Child classes must hide the static parent member if they wish to specify alternate behavior.

Deserializing an abstract class in Gson

I’d suggest adding a custom JsonDeserializer for Nodes: Gson gson = new GsonBuilder() .registerTypeAdapter(Node.class, new NodeDeserializer()) .create(); You will be able to access the JsonElement representing the node in the deserializer’s method, convert that to a JsonObject, and retrieve the field that specifies the type. You can then create an instance of the correct type … Read more

Are there good reasons for a public constructor of an abstract class

The answer is the same for java: THere’s no reason for a public constructor for an abstract class. I’d assume that the reason that the compiler doesn’t complain is as simple that they just didn’t spend time covering that since it really doesn’t matter if it’s public or protected. (source) You can’t call a constructor … Read more

Java generic method inheritance and override rules

What we are having here is two different methods with individual type parameters each. public abstract <T extends AnotherClass> void getAndParse(Args… args); This is a method with a type parameter named T, and bounded by AnotherClass, meaning each subtype of AnotherClass is allowed as a type parameter. public <SpecificClass> void getAndParse(Args… args) This is a … Read more