@SuppressWarnings({ "rawtypes", "unchecked" }) private <K, C extends Mutable<?, ?, ?>, N extends IdentifierNamespace<K, ? extends StmtContext<?, ?, ?>>> AbstractPrerequisite<C> mutatesCtxImpl(final StmtContext<?, ?, ?> context, final Class<N> namespace, final K key, final ModelProcessingPhase phase) { checkNotRegistered(); final PhaseModificationInNamespace<C> mod = new PhaseModificationInNamespace<>(EFFECTIVE_MODEL); addReq(mod); addMutation(mod); contextImpl(context).onNamespaceItemAddedAction((Class) namespace, key, mod); return mod; }
/** * Ends declared section of current node. */ void endDeclared(final ModelProcessingPhase phase) { definition().onDeclarationFinished(this, phase); }
@SuppressWarnings("unchecked") PhaseMutation(final StatementContextBase<?, ?, ?> context, final ModelProcessingPhase phase) { context.addMutation(phase, this); resolvePrereq((C) context); }
@Override public <K, E extends EffectiveStatement<?, ?>, N extends IdentifierNamespace<K, ? extends StmtContext<?, ?, ?>>> AbstractPrerequisite<Mutable<?, ?, E>> mutatesEffectiveCtxPath(final StmtContext<?, ?, ?> context, final Class<N> namespace, final Iterable<K> keys) { checkNotRegistered(); final PhaseModificationInNamespacePath<Mutable<?, ?, E>, K, N> ret = new PhaseModificationInNamespacePath<>( EFFECTIVE_MODEL, keys); addReq(ret); addMutation(ret); ret.hookOnto(context, namespace); return ret; }
@SuppressWarnings({ "unchecked", "rawtypes" }) private <K, V, N extends IdentifierNamespace<K, V>> NamespaceBehaviourWithListeners<K, V, N> createNamespaceContext( final NamespaceBehaviour<K, V, N> potentialRaw) { if (potentialRaw instanceof DerivedNamespaceBehaviour) { final VirtualNamespaceContext derivedContext = new VirtualNamespaceContext( (DerivedNamespaceBehaviour) potentialRaw); getNamespaceBehaviour(((DerivedNamespaceBehaviour) potentialRaw).getDerivedFrom()).addDerivedNamespace( derivedContext); return derivedContext; } return new SimpleNamespaceContext<>(potentialRaw); }
@Override public <K, V, N extends IdentifierNamespace<K, V>> V putToLocalStorageIfAbsent(final Class<N> type, final K key, final V value) { // RootStatementContext takes care of IncludedModuleContext and the rest... final V ret = getRoot().putToLocalStorageIfAbsent(type, key, value); if (ret == null) { updateImportedNamespaces(type, value); } return ret; }
@Override public <C extends Mutable<?, ?, ?>, T extends C> Prerequisite<C> mutatesCtx(final T context, final ModelProcessingPhase phase) { return addMutation(new PhaseMutation<>(contextImpl(context), phase)); }
@Override public <K, V, N extends IdentifierNamespace<K, V>> V putToLocalStorage(final Class<N> type, final K key, final V value) { // RootStatementContext takes care of IncludedModuleContext and the rest... final V ret = getRoot().putToLocalStorage(type, key, value); // FIXME: what about duplicates? updateImportedNamespaces(type, value); return ret; }
@Override public <N extends IdentifierNamespace<?, ?>> Prerequisite<Mutable<?, ?, ?>> mutatesNs( final Mutable<?, ?, ?> context, final Class<N> namespace) { return addMutation(new NamespaceMutation<>(contextImpl(context), namespace)); }
@Override public ModelActionBuilder newInferenceAction(final ModelProcessingPhase phase) { return getRoot().getSourceContext().newInferenceAction(phase); }
@Override public <K, D extends DeclaredStatement<?>, N extends StatementNamespace<K, ? extends D, ?>> Prerequisite<D> requiresDeclared(final StmtContext<?, ?, ?> context, final Class<N> namespace, final K key) { final AbstractPrerequisite<StmtContext<?, D, ?>> rawContext = requiresCtxImpl(context, namespace, key, FULL_DECLARATION); return rawContext.transform(StmtContext::buildDeclared); }
@Override protected boolean isIgnoringConfig() { if (OptionalBoolean.isPresent(ignoreConfig)) { return OptionalBoolean.get(ignoreConfig); } final boolean ret = definition().isIgnoringConfig() || parent.isIgnoringConfig(); ignoreConfig = OptionalBoolean.of(ret); return ret; }
@SuppressWarnings("unchecked") @Override public void namespaceItemAdded(final StatementContextBase<?, ?, ?> context, final Class<?> namespace, final Object key, final Object value) { StatementContextBase<?, ?, ?> targetCtx = contextImpl(value); targetCtx.addMutation(modPhase, this); resolvePrereq((C) targetCtx); }
@SuppressWarnings("checkstyle:illegalCatch") private void loadPhaseStatementsFor(final Set<SourceSpecificContext> srcs) throws ReactorException { for (final SourceSpecificContext source : srcs) { try { source.loadStatements(); } catch (final RuntimeException ex) { throw propagateException(source, ex); } } }
/** * See {@link StatementSupport#getPublicView()}. */ @Override public StatementDefinition getPublicDefinition() { return definition().getPublicView(); }
@Override public YangVersion getRootVersion() { return getRoot().getRootVersion(); }
@Override public void setRootVersion(final YangVersion version) { getRoot().setRootVersion(version); }
@Override public <K, E extends EffectiveStatement<?, ?>, N extends StatementNamespace<K, ?, ? extends E>> Prerequisite<E> requiresEffective(final StmtContext<?, ?, ?> context, final Class<N> namespace, final K key) { final AbstractPrerequisite<StmtContext<?, ?, E>> rawContext = requiresCtxImpl(context, namespace, key, EFFECTIVE_MODEL); return rawContext.transform(StmtContext::buildEffective); }
@Override public <D extends DeclaredStatement<?>> Prerequisite<D> requiresDeclared( final StmtContext<?, ? extends D, ?> context) { return requiresCtxImpl(context, FULL_DECLARATION).transform(StmtContext::buildDeclared); }
@Override public <E extends EffectiveStatement<?, ?>> Prerequisite<E> requiresEffective( final StmtContext<?, ?, ? extends E> stmt) { return requiresCtxImpl(stmt, EFFECTIVE_MODEL).transform(StmtContext::buildEffective); }