private static boolean areFeaturesSupported(final StmtContext<?, ?, ?> subStmtCtx) { /* * In case of Yang 1.1, checks whether features are supported. */ return !YangVersion.VERSION_1_1.equals(subStmtCtx.getRootVersion()) || subStmtCtx.isSupportedByFeatures(); }
@Override public YangVersion parseArgumentValue(final StmtContext<?, ?, ?> ctx, final String value) { return SourceException.unwrap(YangVersion.parse(value), ctx.getStatementSourceReference(), "Unsupported YANG version %s", value); }
private void emitYangVersionNode(final YangVersion input) { super.writer.startYangVersionNode(input.toString()); super.writer.endNode(); }
@Override public Predicate<Set<QName>> parseArgumentValue(final StmtContext<?, ?, ?> ctx, final String value) { if (YangVersion.VERSION_1_1.equals(ctx.getRootVersion())) { return IfFeaturePredicateVisitor.parseIfFeatureExpression(ctx, value); } final QName qname = StmtContextUtils.parseNodeIdentifier(ctx, value); return setQNames -> setQNames.contains(qname); }
private static boolean isRelevantForIfFeatureAndWhenOnListKeysCheck(final StmtContext<?, ?, ?> ctx) { return YangVersion.VERSION_1_1.equals(ctx.getRootVersion()) && StmtContextUtils.hasParentOfType(ctx, YangStmtMapping.LIST) && StmtContextUtils.findFirstDeclaredSubstatement(ctx.coerceParentContext(), KeyStatement.class) != null; }
static void copyFromSourceToTarget(final StatementContextBase<?, ?, ?> sourceCtx, final StatementContextBase<?, ?, ?> targetCtx) { final CopyType typeOfCopy = UsesStatement.class.equals(sourceCtx.coerceParentContext().getPublicDefinition() .getDeclaredRepresentationClass()) ? CopyType.ADDED_BY_USES_AUGMENTATION : CopyType.ADDED_BY_AUGMENTATION; /* * Since Yang 1.1, if an augmentation is made conditional with a * "when" statement, it is allowed to add mandatory nodes. */ final boolean skipCheckOfMandatoryNodes = YangVersion.VERSION_1_1.equals(sourceCtx.getRootVersion()) && isConditionalAugmentStmt(sourceCtx); final Collection<? extends Mutable<?, ?, ?>> declared = sourceCtx.mutableDeclaredSubstatements(); final Collection<? extends Mutable<?, ?, ?>> effective = sourceCtx.mutableEffectiveSubstatements(); final Collection<Mutable<?, ?, ?>> buffer = new ArrayList<>(declared.size() + effective.size()); for (final Mutable<?, ?, ?> originalStmtCtx : declared) { if (originalStmtCtx.isSupportedByFeatures()) { copyStatement(originalStmtCtx, targetCtx, typeOfCopy, buffer, skipCheckOfMandatoryNodes); } } for (final Mutable<?, ?, ?> originalStmtCtx : effective) { copyStatement(originalStmtCtx, targetCtx, typeOfCopy, buffer, skipCheckOfMandatoryNodes); } targetCtx.addEffectiveSubstatements(buffer); }
} else if (!RootStatementContext.DEFAULT_VERSION.equals(root.getRootVersion()) && inProgressPhase == ModelProcessingPhase.SOURCE_LINKAGE) { root = new RootStatementContext<>(this, def, ref, argument, root.getRootVersion(),