Hello,
I'm having problems implementing a non-generic interface that however contains a generic method:
public interface GeneticOperator {
public <I extends Individual<G>, G> Population<I, G> apply( Population<I, G> pop );
...
}
I want to use a generic class to implement this, but I can't find the proper way to implement the method from the interface. This seemed to me the way to do it:
public abstract class AbstractMutator<I extends Individual<G>, G> implements GeneticOperator {
public Population<I, G> apply( Population<I, G> pop ) { ... }
...
}
Eclipse compiler says:
Name clash: The method apply(Population<I,G>) of type AbstractMutator<I,G> has the same erasure as apply(Population<I,G>) of type GeneticOperator but does not override it
I think I sort of half understand why this happens, although this seems a legal way of implementing the method to me. The reason why GeneticOperator isn't generic is that it doesn't make sense for all implementing classes to be generic. It does make sense though for Mutators, so I want to make that a generic class. Any way this can be done?
Thanks.