I'm having trouble using Java Predicates.
I have an enum:
public enum ValidationErrors {
INCONSISTENT_IS_CITATION_ERROR((SacmElement element)->{
return !element.getCitedElement().isPresent() || element.getIsCitation();} );
private final Predicate<? extends SacmElement> isValid;
ValidationErrors(Predicate<? extends SacmElement> isValid) {
this.isValid = isValid;
}
public Predicate<? extends SacmElement> getIsValid() {
return isValid;
}
}
Now within a member of the class SacmElement
I try to do the test:
if (ValidationErrors.INCONSISTENT_IS_CITATION_ERROR.getIsValid().test(this))
That doesn't compile because "The method test(capture#1-of ? extends SacmElement) in the type Predicate is not applicable for the arguments (SacmElement).
I don't understand the error: I thought that for the purposes of Java generics a class is considered to extend itself. What am I doing wrong?