@Override public <X, Y extends DeclaredStatement<X>, Z extends EffectiveStatement<X, Y>> Mutable<X, Y, Z> childCopyOf( final StmtContext<X, Y, Z> stmt, final CopyType type, final QNameModule targetModule) { checkState(stmt.getCompletedPhase() == ModelProcessingPhase.EFFECTIVE_MODEL, "Attempted to copy statement %s which has completed phase %s", stmt, stmt.getCompletedPhase()); checkArgument(stmt instanceof SubstatementContext, "Unsupported statement %s", stmt); final SubstatementContext<X, Y, Z> original = (SubstatementContext<X, Y, Z>)stmt; final SubstatementContext<X, Y, Z> copy = new SubstatementContext<>(original, this, type, targetModule); original.definition().onStatementAdded(copy); original.copyTo(copy, type, targetModule); return copy; }
@Override public Optional<SchemaPath> getSchemaPath() { SchemaPath local = schemaPath; if (local == null) { synchronized (this) { local = schemaPath; if (local == null) { local = createSchemaPath(); schemaPath = local; } } } return Optional.ofNullable(local); }
private boolean isSupportedAsShorthandCase() { final Collection<?> supportedCaseShorthands = getFromNamespace(ValidationBundlesNamespace.class, ValidationBundleType.SUPPORTED_CASE_SHORTHANDS); return supportedCaseShorthands == null || supportedCaseShorthands.contains(getPublicDefinition()); }
return parentPath.createChild(getPublicDefinition().getStatementName()); if ((StmtContextUtils.producesDeclared(parent, ChoiceStatement.class) || Boolean.TRUE.equals(parent.getFromNamespace(AugmentToChoiceNamespace.class, parent))) && isSupportedAsShorthandCase()) { path = parentPath.createChild(qname); } else { final Optional<StmtContext<?, ?, ?>> originalCtx = getOriginalCtx(); final QName qname = StmtContextUtils.qnameFromArgument(originalCtx.orElse(this), (String) argument); return parentPath.createChild(qname);
@Override public void addRequiredSource(final SourceIdentifier dependency) { getRoot().addRequiredSource(dependency); }
@Override public boolean isConfiguration() { if (isIgnoringConfig()) { return true; } if (OptionalBoolean.isPresent(configuration)) { return OptionalBoolean.get(configuration); } final StmtContext<Boolean, ?, ?> configStatement = StmtContextUtils.findFirstSubstatement(this, ConfigStatement.class); final boolean parentIsConfig = parent.isConfiguration(); final boolean isConfig; if (configStatement != null) { isConfig = configStatement.coerceStatementArgument(); // Validity check: if parent is config=false this cannot be a config=true InferenceException.throwIf(isConfig && !parentIsConfig, getStatementSourceReference(), "Parent node has config=false, this node must not be specifed as config=true"); } else { // If "config" statement is not specified, the default is the same as the parent's "config" value. isConfig = parentIsConfig; } // Resolved, make sure we cache this return configuration = OptionalBoolean.of(isConfig); return isConfig; }
@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; }
/** * Create a new substatement at the specified offset. * * @param offset Substatement offset * @param def definition context * @param ref source reference * @param argument statement argument * @param <X> new substatement argument type * @param <Y> new substatement declared type * @param <Z> new substatement effective type * @return A new substatement */ @SuppressWarnings("checkstyle:methodTypeParameterName") public final <X, Y extends DeclaredStatement<X>, Z extends EffectiveStatement<X, Y>> StatementContextBase<X, Y, Z> createSubstatement(final int offset, final StatementDefinitionContext<X, Y, Z> def, final StatementSourceReference ref, final String argument) { final ModelProcessingPhase inProgressPhase = getRoot().getSourceContext().getInProgressPhase(); checkState(inProgressPhase != ModelProcessingPhase.EFFECTIVE_MODEL, "Declared statement cannot be added in effective phase at: %s", getStatementSourceReference()); final Optional<StatementSupport<?, ?, ?>> implicitParent = definition.getImplicitParentFor(def.getPublicView()); if (implicitParent.isPresent()) { return createImplicitParent(offset, implicitParent.get(), ref, argument).createSubstatement(offset, def, ref, argument); } final StatementContextBase<X, Y, Z> ret = new SubstatementContext<>(this, def, ref, argument); substatements = substatements.put(offset, ret); def.onStatementAdded(ret); return ret; }
@Override public void setRootVersion(final YangVersion version) { getRoot().setRootVersion(version); }
@Override protected boolean isIgnoringIfFeatures() { if (OptionalBoolean.isPresent(ignoreIfFeature)) { return OptionalBoolean.get(ignoreIfFeature); } final boolean ret = definition().isIgnoringIfFeatures() || parent.isIgnoringIfFeatures(); ignoreIfFeature = OptionalBoolean.of(ret); return ret; }
@Override public YangVersion getRootVersion() { return getRoot().getRootVersion(); }
@Override public void addMutableStmtToSeal(final MutableStatement mutableStatement) { getRoot().addMutableStmtToSeal(mutableStatement); }
@Override public void setRootIdentifier(final SourceIdentifier identifier) { getRoot().setRootIdentifier(identifier); }