public static boolean needToCopyByUses(final StmtContext<?, ?, ?> stmtContext) { final StatementDefinition def = stmtContext.getPublicDefinition(); if (REUSED_DEF_SET.contains(def)) { LOG.trace("Will reuse {} statement {}", def, stmtContext); return false; } if (NOCOPY_FROM_GROUPING_SET.contains(def)) { return !YangStmtMapping.GROUPING.equals(stmtContext.coerceParentContext().getPublicDefinition()); } LOG.trace("Will copy {} statement {}", def, stmtContext); return true; }
private static boolean needToCopyByUses(final StmtContext<?, ?, ?> stmtContext) { final StatementDefinition def = stmtContext.getPublicDefinition(); if (REUSED_DEF_SET.contains(def)) { LOG.debug("Will reuse {} statement {}", def, stmtContext); return false; } if (NOCOPY_FROM_GROUPING_SET.contains(def)) { return !YangStmtMapping.GROUPING.equals(stmtContext.coerceParentContext().getPublicDefinition()); } LOG.debug("Will copy {} statement {}", def, stmtContext); return true; }
private static StmtContext<?, ?, ?> getSearchRoot(final StmtContext<?, ?, ?> augmentContext) { // Augment is in uses - we need to augment instantiated nodes in parent. final StmtContext<?, ?, ?> parent = augmentContext.coerceParentContext(); if (YangStmtMapping.USES == parent.getPublicDefinition()) { return parent.getParentContext(); } return parent; }
AnyxmlSchemaLocationEffectiveStatementImpl( final StmtContext<SchemaNodeIdentifier, AnyxmlSchemaLocationStatement, ?> ctx) { super(ctx); path = ctx.coerceParentContext().getSchemaPath().get().createChild(getNodeType()); }
AnyxmlSchemaLocationEffectiveStatementImpl( final StmtContext<SchemaNodeIdentifier, AnyxmlSchemaLocationStatement, ?> ctx) { super(ctx); path = ctx.coerceParentContext().getSchemaPath().get().createChild(getNodeType()); }
OpenConfigVersionEffectiveStatementImpl(final StmtContext<SemVer, OpenConfigVersionStatement, ?> ctx) { super(ctx); path = ctx.coerceParentContext().getSchemaPath().get().createChild(getNodeType()); }
Effective(final StmtContext<Void, DefaultDenyWriteStatement, ?> ctx) { super(ctx); path = ctx.coerceParentContext().getSchemaPath().get().createChild( ctx.getPublicDefinition().getStatementName()); }
Effective(final StmtContext<Void, DefaultDenyAllStatement, ?> ctx) { super(ctx); path = ctx.coerceParentContext().getSchemaPath().get().createChild( ctx.getPublicDefinition().getStatementName()); }
Effective(final StmtContext<Void, DefaultDenyWriteStatement, ?> ctx) { super(ctx); path = ctx.coerceParentContext().getSchemaPath().get().createChild( ctx.getPublicDefinition().getStatementName()); }
Effective(final StmtContext<Void, OpenConfigHashedValueStatement, ?> ctx) { super(ctx); path = ctx.coerceParentContext().getSchemaPath().get().createChild( ctx.getPublicDefinition().getStatementName()); }
Effective(final StmtContext<Void, DefaultDenyAllStatement, ?> ctx) { super(ctx); path = ctx.coerceParentContext().getSchemaPath().get().createChild( ctx.getPublicDefinition().getStatementName()); }
Effective(final StmtContext<Void, OpenConfigHashedValueStatement, ?> ctx) { super(ctx); path = ctx.coerceParentContext().getSchemaPath().get().createChild( ctx.getPublicDefinition().getStatementName()); }
public static boolean isInExtensionBody(final StmtContext<?, ?, ?> stmtCtx) { StmtContext<?, ?, ?> current = stmtCtx; while (current.coerceParentContext().getParentContext() != null) { current = current.getParentContext(); if (isUnknownStatement(current)) { return true; } } return false; }
/** * Checks whether all of StmtContext's ancestors of specified type have a child of specified type. * * @param ctx StmtContext to be checked * @param ancestorType type of ancestor to search for * @param ancestorChildType type of child to search for in the specified ancestor type * @return true if all of StmtContext's ancestors of specified type have a child of specified type, otherwise false */ public static <A, D extends DeclaredStatement<A>> boolean hasAncestorOfTypeWithChildOfType( final StmtContext<?, ?, ?> ctx, final StatementDefinition ancestorType, final StatementDefinition ancestorChildType) { requireNonNull(ctx); requireNonNull(ancestorType); requireNonNull(ancestorChildType); StmtContext<?, ?, ?> current = ctx.coerceParentContext(); StmtContext<?, ?, ?> parent = current.getParentContext(); while (parent != null) { if (ancestorType.equals(current.getPublicDefinition())) { @SuppressWarnings("unchecked") final Class<D> ancestorChildTypeClass = (Class<D>) ancestorChildType.getDeclaredRepresentationClass(); if (findFirstSubstatement(current, ancestorChildTypeClass) == null) { return false; } } current = parent; parent = current.getParentContext(); } return true; }
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; }
UnrecognizedEffectiveStatementImpl(final StmtContext<String, UnrecognizedStatement, ?> ctx) { super(ctx); // FIXME: Remove following section after fixing 4380 final UnknownSchemaNode original = (UnknownSchemaNode) ctx.getOriginalCtx().map(StmtContext::buildEffective) .orElse(null); if (original != null) { this.maybeQNameArgument = original.getQName(); } else { QName maybeQNameArgumentInit = null; try { maybeQNameArgumentInit = StmtContextUtils.qnameFromArgument(ctx, argument()); } catch (IllegalArgumentException e) { maybeQNameArgumentInit = getNodeType(); } this.maybeQNameArgument = maybeQNameArgumentInit; } path = ctx.coerceParentContext().getSchemaPath().get().createChild(maybeQNameArgument); }
YangDataEffectiveStatementImpl(final StmtContext<String, YangDataStatement, ?> ctx) { super(ctx); QName maybeQNameArgumentInit; try { maybeQNameArgumentInit = StmtContextUtils.parseIdentifier(ctx, argument()); } catch (IllegalArgumentException e) { maybeQNameArgumentInit = getNodeType(); } this.maybeQNameArgument = maybeQNameArgumentInit; path = ctx.coerceParentContext().getSchemaPath().get().createChild(maybeQNameArgument); container = findFirstEffectiveSubstatement(ContainerEffectiveStatement.class).get(); // TODO: this is strong binding of two API contracts. Unfortunately ContainerEffectiveStatement design is // incomplete. Verify.verify(container instanceof ContainerSchemaNode); }
YangDataEffectiveStatementImpl(final StmtContext<String, YangDataStatement, ?> ctx) { super(ctx); QName maybeQNameArgumentInit; try { maybeQNameArgumentInit = StmtContextUtils.parseIdentifier(ctx, argument()); } catch (IllegalArgumentException e) { maybeQNameArgumentInit = getNodeType(); } this.maybeQNameArgument = maybeQNameArgumentInit; path = ctx.coerceParentContext().getSchemaPath().get().createChild(maybeQNameArgument); container = findFirstEffectiveSubstatement(ContainerEffectiveStatement.class).get(); // TODO: this is strong binding of two API contracts. Unfortunately ContainerEffectiveStatement design is // incomplete. Verify.verify(container instanceof ContainerSchemaNode); }
Effective(final StmtContext<String, AnnotationStatement, ?> ctx) { super(ctx); path = ctx.coerceParentContext().getSchemaPath().get().createChild( StmtContextUtils.parseIdentifier(ctx, argument())); final TypeEffectiveStatement<?> typeStmt = SourceException.throwIfNull( firstSubstatementOfType(TypeEffectiveStatement.class), ctx.getStatementSourceReference(), "AnnotationStatementSupport %s is missing a 'type' statement", argument()); final ConcreteTypeBuilder<?> builder = ConcreteTypes.concreteTypeBuilder(typeStmt.getTypeDefinition(), path); final StmtContext<String, ?, ?> unitsStmt = StmtContextUtils.findFirstEffectiveSubstatement(ctx, UnitsStatement.class); if (unitsStmt != null) { builder.setUnits(unitsStmt.getStatementArgument()); } type = builder.build(); }