generics: AnalysisComponent.getRequiredCasInterface();

2009-08-19 Thread Jörn Kottmann

Is that the correct generification?
Class? extends AbstractCas getRequiredCasInterface();

Implementing classes can then specify the concrete return
type.

For example:
ClassJCas JCasAnnotator_ImplBase.getRequiredCasInterface()
ClassCAS CasAnnotator_ImplBase.getRequiredCasInterface()

Jörn



Re: generics: AnalysisComponent.getRequiredCasInterface();

2009-08-19 Thread Marshall Schor


Jörn Kottmann wrote:
 Is that the correct generification?
 Class? extends AbstractCas getRequiredCasInterface();

 Implementing classes can then specify the concrete return
 type.

 For example:
 ClassJCas JCasAnnotator_ImplBase.getRequiredCasInterface()
 ClassCAS CasAnnotator_ImplBase.getRequiredCasInterface()
I tried:
  public static void tgrci(AnalysisComponent ac) {
ClassJCas x = ac.getRequiredCasInterface();
  }

but it doesn't work, gives error:
// error, cannot convert from Classcapture#4-of ? extends AbstractCas
to ClassJCas

This is with the interface AnalysisComponent defining
getRequiredCasInterface as:
 Class? extends AbstractCas getRequiredCasInterface();

This works:
  public static void tgrci(AnalysisComponent ac) {
Class? extends AbstractCas x = ac.getRequiredCasInterface();
  }

and this works too:
  public static void tgrci(AnalysisComponent ac) {
ClassJCas x = ((JCasAnnotator_ImplBase)ac).getRequiredCasInterface();
  }

So, I think we have the correct generification in the interface
AnalysisComponent, of return ? extends AbstractCAS.

-Marshall.

 Jörn