Hi.
I have seen different questions regarding this, but I still find this topic to be very confusing.
All I want to do, is have an abstract class that implements an interface, and have a class extending this abstract class so that the hard class needs to implement getKommune()
and setKommune(Kommune kommune)
, but not the other method, because that is in the abstract class.
I have the following interface.
public interface KommuneFilter {
<E extends AbstractKommune<?>> void addKommuneFromCurrentUser(E e);
Kommune getKommune();
void setKommune(Kommune kommune);
}
And this Abstract class
public abstract class AbstractKommune<E extends AbstractKommune<?>> implements KommuneFilter {
@PrePersist
void addKommuneFromCurrentUser(E e) {
Kommune k = e.getKommune();
}
}
And I want to use it like this
public class Person extends AbstractKommune<Person> {
private Kommune kommune;
public void setKommune(Kommune kommune) {this.kommune=kommune;}
public Kommune getKommune() {return kommune;}
}
However, I get
Name clash: The method of has the same erasure of type but does not override it
Why isn't it correctly overriden?
UPDATE
Thanks to @Bozho, the solution is this:
public interface KommuneFilter<E extends AbstractKommune<?>> {
public void addKommuneFromCurrentUser(E e);
}
public abstract class AbstractKommune<E extends AbstractKommune<?>> implements KommuneFilter<E>
public class Person extends AbstractKommune<Person>