Forum Stats

  • 3,752,284 Users
  • 2,250,483 Discussions
  • 7,867,783 Comments

Discussions

Type Mismatch

dadams07
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);

    ENM.execute(dao);

   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?

Answers

This discussion has been closed.