I am writing a URL validator. The code is as follows
public ValidationResult validate(final Object data, final Object root, final String path, final ValidationContext validationContext, final EvaluationContext evaluationContext) {
ValidationResult validationResult = new ValidationResult();
@SuppressWarnings("unchecked")
List<URL> URLs = (List<URL>)data;
UrlValidator urlValidator = new UrlValidator();
boolean isValid = true;
for (URL websiteURL : URLs) {
if (urlValidator.isValid(websiteURL.getPath())) {
isValid = true;
} else {
isValid = false;
break;
}
System.out.println("websiteURL.getPath() " + websiteURL.getPath());
}
System.out.println("websiteURL.getPath() " + isValid);
return validationResult;
}
While debugging i found that for (URL websiteURL : URLs)
is giving java.lang.ClassCastException: java.net.URI cannot be cast to java.net.URL
error. How can i make my logic work?