+ /**
+ * Check augments for mandatory nodes. If the target node is in another
+ * module, then nodes added by the augmentation MUST NOT be mandatory nodes.
+ * If mandatory node is found, throw an exception.
+ *
+ * @param augments
+ * augments to check
+ */
+ private void checkAugmentMandatoryNodes(Collection<AugmentationSchemaBuilder> augments) {
+ for (AugmentationSchemaBuilder augment : augments) {
+ String augmentPrefix = augment.getTargetPath().getPath().get(0).getPrefix();
+ ModuleBuilder module = ParserUtils.getParentModule(augment);
+ String modulePrefix = module.getPrefix();
+
+ if (augmentPrefix == null || augmentPrefix.isEmpty() || augmentPrefix.equals(modulePrefix)) {
+ continue;
+ }
+
+ for (DataSchemaNodeBuilder childNode : augment.getChildNodeBuilders()) {
+ if (childNode.getConstraints().isMandatory()) {
+ throw new YangParseException(augment.getModuleName(), augment.getLine(),
+ "Error in augment parsing: cannot augment mandatory node");
+ }
+ }
+ }
+ }
+