I'm getting the warning "Raw use of parameterized class 'MapperService' and "Unchecked call to 'mapSourceToBehandlerKrav(T)' as a member of raw type .. from IntelliJ. I'm not really grasping the concepts of generics in general, trying to figure it out. But some explanation and solution to these warnings might be helpful
Interface:
public interface MapperService<T> {
Behandlerkrav mapSourceToBehandlerkrav(T sourceInput) throws DataSourceException, MapperException;
}
Implementing class:
public class XMLToDomainMapper implements MapperService {
public Behandlerkrav mapSourceToBehandlerkrav(Object input) throws DataSourceException, MapperException {
if (!(input instanceof File)) {
throw new DataSourceException(
"Input er av ugyldig type: " + input.getClass() + " | tillat type = " + "File");
}
// More stuff
}
Calling of implemting class (where the warnings occur):
public class InnrapporteringServiceImpl implements InnrapporteringService {
MapperService kildesystemInputMapper; <-- IntelliJ WARNING HERE
public InnrapporteringServiceImpl(XMLToDomainMapper mapper) {
this.kildesystemInputMapper = mapper;
}
@ServiceActivator(inputChannel = "sftChannel")
public void init(Message<File> message) {
// call mapper service
// call persistence service
// call reporting service
var timestamp = message.getHeaders().getTimestamp();
Behandlerkrav behandlerkrav = kildesystemInputMapper.mapSourceToBehandlerkrav(message.getPayload()); <-- IntelliJ WARNING here
}
}