0

I have such code:

public abstract class IsValidator<M> implements HasValidation.Validator {
    public final ValidationResult validate(ValidatorBase<M> validator, M model) {
        ValidationResult result = validator.validate(model);
        return new ValidationResult(result.isValid(), result.getErrorMessage());
    }
}

This is validator abstraction used for each validation. This method needs to be final, as it can not be changed. It is why I use abstract class instead of interface.

But sonar points me this as an issue:

Abstract classes without fields should be converted to interfaces
 
Code smell
 
Minor
java:S1610

https://rules.sonarsource.com/java/RSPEC-1610

I tried with interface, but default method can not be finalized.

Am I missing something? Can You help?

masterdany88
  • 4,479
  • 9
  • 54
  • 124
  • Are you sure you want to use inheritance to introduce a one utility method? It doesn't sound form me like a correct approach. https://stackoverflow.com/q/269496/4944847 – agabrys Sep 15 '21 at 18:13

0 Answers0