if (!(astNodes[0] instanceof AnnotationNode) || !(astNodes[1] instanceof AnnotatedNode)) {
throw new RuntimeException("Internal error: wrong types: $node.class / $parent.class");
}
AnnotatedNode parent = (AnnotatedNode) astNodes[1];
AnnotationNode node = (AnnotationNode) astNodes[0];
if (!VALIDATEABLE_CLASS_NODE.equals(node.getClassNode())) {
return;
}
ClassNode cNode = (ClassNode) parent;
String cName = cNode.getName();
if (cNode.isInterface()) {
throw new RuntimeException("Error processing interface '" + cName + "'. @Validateable not allowed for interfaces.");
}
// GRAILS-11416 - Allow override of default nullability
boolean defaultNullable = false;
Expression nullable = node.getMember("nullable");
if (nullable != null) {
defaultNullable = Boolean.parseBoolean(nullable.getText());
}
new DefaultASTValidateableHelper().injectValidateableCode(cNode, defaultNullable);