From df14ba8a01d2a53f764a42aa0daebf118be712cd Mon Sep 17 00:00:00 2001 From: Mira Leung Date: Fri, 6 Nov 2020 22:00:20 -0800 Subject: [PATCH] [ggj][ast][engx] fix: validate non-null elements for SynchronizedStatement (#465) * fix: swap assertEquals args in JavaWriterVisitorTest to match (expected, actusl) order * fix: swap assertEquals args in ImportWriterVisitorTest to match (expected, actusl) order * fix: add node validator to refactor/centralize null element checks * fix: validate non-null elements for IfStatement * fix: validate non-null elements for AnonymousClassExpr * fix: validate non-null elements for BlockStatement * fix: validate non-null elements for ClassDefinition * fix: validate non-null elements for ConcreteReference * fix: validate non-null elements for ForStatement * fix: validate non-null elements for GeneralForStatement * fix: validate non-null elements for MethodDefinition * fix: validate non-null elements for PackageInfoDefinition * fix: validate non-null elements for SynchronizedStatement --- .../generator/engine/ast/SynchronizedStatement.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/google/api/generator/engine/ast/SynchronizedStatement.java b/src/main/java/com/google/api/generator/engine/ast/SynchronizedStatement.java index 41a94ef351..5bd58d8d13 100644 --- a/src/main/java/com/google/api/generator/engine/ast/SynchronizedStatement.java +++ b/src/main/java/com/google/api/generator/engine/ast/SynchronizedStatement.java @@ -60,6 +60,14 @@ public Builder setBody(Statement... statements) { // Private. abstract Builder setLock(Expr expr); - public abstract SynchronizedStatement build(); + abstract ImmutableList body(); + + abstract SynchronizedStatement autoBuild(); + + public SynchronizedStatement build() { + NodeValidator.checkNoNullElements(body(), "body statements", "synchronized statement"); + + return autoBuild(); + } } }