Is it possible to add generics to enum values?
Something similar to this pseudo code:
public enum MyEnum<T> {
VALUE1<String>,
VALUE2<Boolean>;
public T get() {
return (T) AnotherSystem.get(this); // Where AnotherSystem.get returns an Object
}
}
Have I just written this incorrectly, or is this not possible at all?
What other options do I have to make get() return a specific generic type (T)
You can do
If you need to associate a type with an enum, it can be a property