@Override public void apply(final InferenceContext ctx) { StmtContext<?, ?, ?> belongsToModuleCtx = belongsToPrereq.resolve(ctx); belongsToCtx.addToNs(BelongsToModuleContext.class, belongsToSourceIdentifier, belongsToModuleCtx); belongsToCtx.addToNs(BelongsToPrefixToModuleCtx.class, findFirstDeclaredSubstatement(belongsToCtx, PrefixStatement.class).coerceStatementArgument(), belongsToModuleCtx); }
@Override public void prerequisiteFailed(final Collection<? extends Prerequisite<?>> failed) { throw new InferenceException(deviateStmtCtx.coerceParentContext().getStatementSourceReference(), "Deviation target '%s' not found.", deviationTarget); } });
@Override public void onFullDefinitionDeclared( final Mutable<QName, LeafStatement, EffectiveStatement<QName, LeafStatement>> ctx) { super.onFullDefinitionDeclared(ctx); StmtContextUtils.validateIfFeatureAndWhenOnListKeys(ctx); }
private YangDataStatementSupport(final StatementDefinition definition) { super(definition); validator = SubstatementValidator.builder(definition) .addMandatory(YangStmtMapping.CONTAINER) .addOptional(YangStmtMapping.USES) .build(); }
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; }
@Override public void apply(final InferenceContext ctx) { final StmtContext<?, ?, ?> importedModule = imported.resolve(ctx); linkageTarget.resolve(ctx).addToNs(ImportedModuleContext.class, stmt.getFromNamespace(ModuleCtxToSourceIdentifier.class, importedModule), importedModule); final String impPrefix = firstAttributeOf(stmt.declaredSubstatements(), PrefixStatement.class); final URI modNs = firstAttributeOf(importedModule.declaredSubstatements(), NamespaceStatement.class); stmt.addToNs(ImportPrefixToModuleCtx.class, impPrefix, importedModule); stmt.addToNs(URIStringToImportPrefix.class, modNs.toString(), impPrefix); }
@Override public void onFullDefinitionDeclared(final Mutable<SchemaNodeIdentifier, AnyxmlSchemaLocationStatement, EffectiveStatement<SchemaNodeIdentifier, AnyxmlSchemaLocationStatement>> stmt) { super.onFullDefinitionDeclared(stmt); stmt.coerceParentContext().addToNs(AnyxmlSchemaLocationNamespace.class, ANYXML_SCHEMA_LOCATION, stmt); }
@Override public void prerequisiteFailed(final Collection<? extends Prerequisite<?>> failed) { throw new InferenceException(baseStmtCtx.getStatementSourceReference(), "Unable to resolve identity %s and base identity %s", baseParentCtx.getStatementArgument(), baseStmtCtx.getStatementArgument()); } });
/** * Checks whether statement context is a non-presence container or not. * * @param stmtCtx * statement context * @return true if it is a non-presence container */ public static boolean isNonPresenceContainer(final StmtContext<?, ?, ?> stmtCtx) { return stmtCtx.getPublicDefinition() == YangStmtMapping.CONTAINER && !containsPresenceSubStmt(stmtCtx); }
@SuppressWarnings("unchecked") public static <A, D extends DeclaredStatement<A>> A firstAttributeOf(final StmtContext<?, ?, ?> ctx, final Class<D> declaredType) { return producesDeclared(ctx, declaredType) ? (A) ctx.getStatementArgument() : null; }
@Override public QName getFrom(final NamespaceStorageNode storage, final QName key) { final NamespaceStorageNode root = getRoot(storage); final QName stored = root.getFromLocalStorage(QNameCacheNamespace.class, key); if (stored != null) { return stored; } root.putToLocalStorage(QNameCacheNamespace.class, key, key); return key; }
@SuppressWarnings("unchecked") public static <A, D extends DeclaredStatement<A>> StmtContext<A, ?, ?> findFirstDeclaredSubstatement( final StmtContext<?, ?, ?> stmtContext, final Class<D> declaredType) { for (final StmtContext<?, ?, ?> subStmtContext : stmtContext.declaredSubstatements()) { if (producesDeclared(subStmtContext, declaredType)) { return (StmtContext<A, ?, ?>) subStmtContext; } } return null; }
@SuppressWarnings("unchecked") public static <A, D extends DeclaredStatement<A>> StmtContext<A, ?, ?> findFirstEffectiveSubstatement( final StmtContext<?, ?, ?> stmtContext, final Class<D> declaredType) { for (final StmtContext<?, ?, ?> subStmtContext : stmtContext.effectiveSubstatements()) { if (producesDeclared(subStmtContext, declaredType)) { return (StmtContext<A, ?, ?>) subStmtContext; } } return null; }
@Override public V getFrom(final NamespaceStorageNode storage, final K key) { NamespaceStorageNode current = storage; while (current != null) { final V val = getFromLocalStorage(current, key); if (val != null) { return val; } current = current.getParentNamespaceStorage(); } return null; }
@Override public Map<K, V> getAllFrom(final NamespaceStorageNode storage) { NamespaceStorageNode current = storage; while (current != null) { final Map<K, V> val = getAllFromLocalStorage(current); if (val != null) { return val; } current = current.getParentNamespaceStorage(); } return null; }
@Override public StatementSupport<?, ?, ?> getSupportSpecificForArgument(final String argument) { return delegate().getSupportSpecificForArgument(argument); } }
private YangDataStatementSupport(final StatementDefinition definition) { super(definition); validator = SubstatementValidator.builder(definition) .addMandatory(YangStmtMapping.CONTAINER) .addOptional(YangStmtMapping.USES) .build(); }
/** * Checks whether statement context is a presence container or not. * * @param stmtCtx * statement context * @return true if it is a presence container */ public static boolean isPresenceContainer(final StmtContext<?, ?, ?> stmtCtx) { return stmtCtx.getPublicDefinition() == YangStmtMapping.CONTAINER && containsPresenceSubStmt(stmtCtx); }