Eliminate ConstraintDefition.isMandatory()
[yangtools.git] / yang / yang-parser-impl / src / main / java / org / opendaylight / yangtools / yang / parser / stmt / rfc6020 / effective / LeafEffectiveStatementImpl.java
index 6b2076c6d6287f84bd29836366447ab9d43ccf5e..b963c7268bca4ad13d5079139b307688e58b94eb 100644 (file)
@@ -28,6 +28,7 @@ public final class LeafEffectiveStatementImpl extends AbstractEffectiveDataSchem
     private final TypeDefinition<?> type;
     private final String defaultStr;
     private final String unitsStr;
+    private final boolean mandatory;
 
     public LeafEffectiveStatementImpl(
             final StmtContext<QName, LeafStatement, EffectiveStatement<QName, LeafStatement>> ctx) {
@@ -66,6 +67,13 @@ public final class LeafEffectiveStatementImpl extends AbstractEffectiveDataSchem
         defaultStr = dflt;
         unitsStr = units;
         type = builder.build();
+        final MandatoryEffectiveStatement mandatoryStmt = firstEffective(MandatoryEffectiveStatement.class);
+        mandatory = mandatoryStmt == null ? false : mandatoryStmt.argument().booleanValue();
+    }
+
+    @Override
+    public boolean isMandatory() {
+        return mandatory;
     }
 
     @Override