So, I have a list of enums that extend the interface:
public interface MyInterface {}
Then I have a few enumerations that extend the interface:
public enum A implements MyInterface {}
public enum B implements MyInterface {}
I need a function that will only accept an enumeration extending this interface. I cant:
public void MyFunction(MyInterface input)
because inside the function I create EnumSet using EnumSet.of (input). I cannod do
public <T extends Enum<T>> void myFunction(T input)
because inside the function I need to create a map that needs to be passed to another function. So is there any safe type for this without casting?
Edit: Fixed interface definitions.
source
share