I'm converting people's data into condensed form. So I have a bunch of interfaces:
public interface Brief {}
public interface Detail {}
public interface DetailToBriefConverter<T extends Detail, R extends Brief> {
R convert(T detail);
}
, a bunch of pojos:
public class StudentBrief implements Brief {...}
public class StudentDetail implements Detail {...}
public class EmployeeBrief implements Brief {...}
public class EmployeeDetail implements Detail {...}
and converters:
public class StudentDetailToBriefConverter implements DetailToBriefConverter<StudentDetail, StudentBrief> {
@Override
public StudentBrief convert(StudentDetail detail) {
// logic here
}
}
etc.
My main class looks roughly like this:
public class MainApp {
private Map<String, DetailToBriefConverter> map = ImmutableMap.<String, DetailToBriefConverter>builder()
.put("employee", new EmployeeDetailToBriefConverter())
.put("student", new StudentDetailToBriefConverter())
.build();
public static void main(String[] args) {
MainApp mainApp = new MainApp();
String type = "employee"; // comes from the request actually
Detail detail = new EmployeeDetail(); // comes from the request
DetailToBriefConverter detailToBriefConverter = mainApp.map.get(type);
detailToBriefConverter.convert(detail);
}
}
And this works, but I get a warning unchecked call to convert(T) as a member of a raw type DetailToBriefConverter
.
How can I get rid of this warning or do I have to live with it?