+ private static boolean reguiredCheckOfMandatoryNodes(StatementContextBase<?, ?, ?> sourceCtx,
+ StatementContextBase<?, ?, ?> targetCtx) {
+ /*
+ * If the statement argument is not QName, it cannot be mandatory statement,
+ * therefore return false and skip mandatory nodes validation
+ */
+ if(!(sourceCtx.getStatementArgument() instanceof QName)) {
+ return false;
+ }
+ QName sourceStmtQName = (QName) sourceCtx.getStatementArgument();
+
+ RootStatementContext<?, ?, ?> root = targetCtx.getRoot();
+ do {
+ Verify.verify(targetCtx.getStatementArgument() instanceof QName,
+ "Argument of augment target statement must be QName.");
+ QName targetStmtQName = (QName) targetCtx.getStatementArgument();
+ /*
+ * If target is from another module, return true and perform
+ * mandatory nodes validation
+ */
+ if (!Utils.belongsToTheSameModule(targetStmtQName, sourceStmtQName)) {
+ return true;
+ } else {
+ /*
+ * If target or one of its parent is a presence container from
+ * the same module, return false and skip mandatory nodes
+ * validation
+ */
+ if (Utils.isPresenceContainer(targetCtx)) {
+ return false;
+ }
+ }
+ } while ((targetCtx = targetCtx.getParentContext()) != root);
+
+ /*
+ * All target node's parents belong to the same module as source node,
+ * therefore return false and skip mandatory nodes validation.
+ */
+ return false;
+ }
+
+ private static final Set<Rfc6020Mapping> NOCOPY_DEF_SET = ImmutableSet.of(Rfc6020Mapping.USES, Rfc6020Mapping.WHEN,
+ Rfc6020Mapping.DESCRIPTION, Rfc6020Mapping.REFERENCE, Rfc6020Mapping.STATUS);