diff --git a/src/main/java/com/google/api/generator/engine/ast/ClassDefinition.java b/src/main/java/com/google/api/generator/engine/ast/ClassDefinition.java index 76c797c7d3..ec8f4f7b43 100644 --- a/src/main/java/com/google/api/generator/engine/ast/ClassDefinition.java +++ b/src/main/java/com/google/api/generator/engine/ast/ClassDefinition.java @@ -137,6 +137,7 @@ public ClassDefinition build() { setClassIdentifier(classIdentifier); ClassDefinition classDef = autoBuild(); + performNullChecks(classDef); // Only nested classes can forego having a package. if (!classDef.isNested()) { @@ -201,5 +202,19 @@ public ClassDefinition build() { return classDef; } + + void performNullChecks(ClassDefinition classDef) { + String contextInfo = String.format("class definition of %s", name()); + NodeValidator.checkNoNullElements( + classDef.headerCommentStatements(), "header comments", contextInfo); + NodeValidator.checkNoNullElements(classDef.annotations(), "annotations", contextInfo); + + NodeValidator.checkNoNullElements( + classDef.implementsTypes(), "implemented types", contextInfo); + NodeValidator.checkNoNullElements(classDef.statements(), "statements", contextInfo); + + NodeValidator.checkNoNullElements(classDef.methods(), "methods", contextInfo); + NodeValidator.checkNoNullElements(classDef.nestedClasses(), "nested classes", contextInfo); + } } }