Is there a way to force classes in Java to have public static final field (through interface or abstract class)? Or at least just a public field?
I need to make sure somehow that a group of classes have
public static final String TYPE = "...";
in them.
No, you can’t.
You can only force them to have a non-static getter method, which would return the appropriate value for each subclass:
If you need to map each subclass of something to a value, without the need to instantiate it, you can create a
public static Map<Class<?>, String> types;somewhere, populate it statically with all the classes and their types, and obtain the type by callingTypesHolder.types.get(SomeClass.class)