I have an interface Calculator
which shapes a class that computes some results and returns them with a given schema.
interface Calculator {
List<Object> getResults();
List<String> schema();
}
Each of its subclasses has a different schema, as they do not compute exactly the same things. But all instances of a same subclass have the same schema since it computes the same way everytime.
The problem is that I want to access that schema somewhere else in my code without having to compute anything, as computations can be expensive.
Ideally, I would like that each subclass have its own public static final List<String> SCHEMA
attribute. But since static attributes/methods cannot be overriden, I cannot require that all subclasses of the Calculator
interface implement it.
Is there a way around, or must I store the schema when I compute the results, and pass this schema around for later use? (this can become tedious I guess)