Introduce formatting methods for SourceException
[yangtools.git] / yang / yang-parser-impl / src / main / java / org / opendaylight / yangtools / yang / parser / stmt / rfc6020 / effective / LeafEffectiveStatementImpl.java
index 70d80394699d89810ef8465ad303bd5cd33b12ea..113a5d49e909a1eefd30f37b5124300de1e3698e 100644 (file)
@@ -32,10 +32,9 @@ public final class LeafEffectiveStatementImpl extends AbstractEffectiveDataSchem
         super(ctx);
         this.original = ctx.getOriginalCtx() == null ? null : (LeafSchemaNode) ctx.getOriginalCtx().buildEffective();
 
-        final TypeEffectiveStatement<?> typeStmt = firstSubstatementOfType(TypeEffectiveStatement.class);
-        if (typeStmt == null) {
-            throw new SourceException("Leaf is missing a 'type' statement", ctx.getStatementSourceReference());
-        }
+        final TypeEffectiveStatement<?> typeStmt = SourceException.throwIfNull(
+                firstSubstatementOfType(TypeEffectiveStatement.class), ctx.getStatementSourceReference(),
+                "Leaf is missing a 'type' statement");
 
         String dflt = null;
         String units = null;