I want to create an Enum class that contains a path, and a class type that I can then use to call another class and have the generic type of that already there.
For example:
public enum Settings {
EXAMPLE_1("path here", Integer.class),
EXAMPLE_2("path here", String.class);
private String path;
private Class<?> clazz;
Settings(String path, Class<?> clazz){
this.path = path;
this.clazz = clazz;
}
public String getPath() {
return path;
}
public Class<?> getClassType(){
return clazz;
}
}
Then, I would then use this to create another class using the types in this class, like so:
public class Setting <T> {
private T value;
public Setting(T value) {
this.value = value;
}
public T getValue() {
return value;
}
}
I've tried multiple different things, but I'm not sure how to go from the enum, containing the class type, to actually making the Setting class have that type initalised in it.
I then want to have a Map containing the Enum, and then the Setting class.
private Map<Settings, Setting> settings = new HashMap<>();
For example, then calling the enum EXAMPLE_2, would return the Setting class with a String, where as EXAMPLE_1 would return it as an Integer.