Forum Stats

  • 3,826,348 Users
  • 2,260,632 Discussions


Type Mismatch

dadams07 Member Posts: 1,310
edited Jul 22, 2014 3:44PM in Generics

I have a class defined as follows:

public class MultiFacilitySearchDataProvider <T extends Facility & MilepostValue & Copyable<T>>

The class has this method:

protected T getFacility(final FacilityInstance instance) {

    final MultiFacilitySearchDAO dao = new MultiFacilitySearchDAO(instance);


   return dao.getResultModel();  // Compile error here


The DAO method called above looks like this:

public MultiFacilitySearchModel getResultModel() {

    return resultModel;


And MultiFacilitySearchModel is defined as follows:

public class MultiFacilitySearchModel implements Copyable<MultiFacilitySearchModel>, Facility,

     Serializable, MilepostValue, MenuDisplayValues

The problem is that the line return dao.getResultModel() generates a compile error "Type mismatch: cannot convert from MultiFacilitySearchModel to T". I don't understand why I'm getting this error, since MultiFacilitySearchModel implements the three interfaces specified for the generic type T. What am I missing?


This discussion has been closed.