Apache Commons EmailValidator Override isValidDomain

I'm using the Apache Commons Email validator

I want to override the isValidDomain method, but I can't because this class has defined it with a non public constructor.

Is there anyway I can get around this besides re-writing the whole class again?

1 answer

  • answered 2018-11-08 07:10 user7294900

    Method has protected access so you can create and use your own class extending it and override the method:

    public class MyEmailValidator extends EmailValidator {
    
       private static final long serialVersionUID = 1L; // Should be Serializable 
       @Override
       protected boolean isValidDomain(String domain) {