0

I have code in my project like this below:

public class CommandValidator extends AbstractValidator<CommandTransaction> {
    @Override
    public boolean validate(CommandTransaction object) {
        return false;
    }
}

public abstract class AbstractValidator<T> implements Validator<T>{
    @Override
    public boolean validate(T object) {
        return false;
    }
}

public interface Validator<T> {
     default boolean validate(T object) throws Exception {
         return false;
     }
}

I have error when I try to compile it:

[ERROR] error: name clash: validate(CommandTransaction) in CommandValidator overrides a method whose erasure is the same as another method, yet neither overrides the other
[ERROR] first method:  validate(Object) in Validator
[ERROR] second method: validate(T) in AbstractValidator
[ERROR] where T is a type-variable:
[ERROR] T extends Object declared in class AbstractValidator

Any idea what cause the error? Why first method has Object instead of generic validate(Object) ?

0 Answers0