So I have these classes:
public class DeviceInState implements MyInterface<Device> {
    private List<DeviceState> toStates(String statesString) {
        List<String> states = Lists.newArrayList(statesString.split(","));
        return states.stream().map(DeviceState::valueOf).collect(Collectors.toList());
    }
}
  
public class DeviceHistoryInState implements MyInterface<DeviceHistory> {
    private List<EventType> toStates(String statesString) {
        List<String> states = Lists.newArrayList(statesString.split(","));
        return states.stream().map(EventType::valueOf).collect(Collectors.toList());
    }
}
And these enums:
public enum EventType{
    NEW("N"), ACTIVE("A"), INACTIVE("I");
}
    
public enum DeviceState{
    REGISTRATED("R"), SUSPENDED("S"), DELETED("D");
}
The differences are:
- DeviceInState implements MyInterface<Device>; but- DeviceHistoryInState implements MyInterface<DeviceHistory>
- DeviceState::valueOfis called in- DeviceInState; but- EventTypes::valueOfis called in- DeviceHistoryInState
I have a couple of other classes like these so I would like to make a generic one. But I have no idea whether or not it is possible. How might I parameterize my classes or methods in a way that I can call the ::valueOf method?
Thanks in advance.
 
     
    