@Override public QName getSignificantKey(final SchemaNodeIdentifier key) { return key.getLastComponent(); } }
private static boolean isListKey(final StmtContext<?, ?, ?> leafStmtCtx, final StmtContext<Collection<SchemaNodeIdentifier>, ?, ?> keyStmtCtx) { for (final SchemaNodeIdentifier keyIdentifier : keyStmtCtx.coerceStatementArgument()) { if (leafStmtCtx.getStatementArgument().equals(keyIdentifier.getLastComponent())) { return true; } } return false; }
RefineEffectiveStatementImpl(final StmtContext<SchemaNodeIdentifier, RefineStatement, ?> ctx) { super(ctx); qname = verifyNotNull(ctx.coerceStatementArgument().getLastComponent()); path = ctx.getSchemaPath().get(); refineTargetNode = (SchemaNode) ctx.getEffectOfStatement().iterator().next().buildEffective(); // initSubstatementCollectionsAndFields this.unknownNodes = ImmutableList.copyOf(effectiveSubstatements().stream() .filter(UnknownSchemaNode.class::isInstance) .map(UnknownSchemaNode.class::cast) .collect(Collectors.toList())); }
private static boolean isDeviationSupported(final Mutable<DeviateKind, DeviateStatement, EffectiveStatement<DeviateKind, DeviateStatement>> deviateStmtCtx, final SchemaNodeIdentifier deviationTarget) { final SetMultimap<QNameModule, QNameModule> modulesDeviatedByModules = deviateStmtCtx.getFromNamespace( ModulesDeviatedByModules.class, SupportedModules.SUPPORTED_MODULES); if (modulesDeviatedByModules == null) { return true; } final QNameModule currentModule = deviateStmtCtx.getFromNamespace(ModuleCtxToModuleQName.class, deviateStmtCtx.getRoot()); final QNameModule targetModule = deviationTarget.getLastComponent().getModule(); final Set<QNameModule> deviationModulesSupportedByTargetModule = modulesDeviatedByModules.get(targetModule); if (deviationModulesSupportedByTargetModule != null) { return deviationModulesSupportedByTargetModule.contains(currentModule); } return false; }
final QName keyQName = key.getLastComponent();
@Override public Collection<SchemaNodeIdentifier> adaptArgumentValue( final StmtContext<Collection<SchemaNodeIdentifier>, KeyStatement, EffectiveStatement<Collection<SchemaNodeIdentifier>, KeyStatement>> ctx, final QNameModule targetModule) { final Builder<SchemaNodeIdentifier> builder = ImmutableSet.builder(); boolean replaced = false; for (final SchemaNodeIdentifier arg : ctx.coerceStatementArgument()) { final QName qname = arg.getLastComponent(); if (!targetModule.equals(qname.getModule())) { final QName newQname = ctx.getFromNamespace(QNameCacheNamespace.class, qname.withModule(targetModule)); builder.add(SchemaNodeIdentifier.SAME.createChild(newQname)); replaced = true; } else { builder.add(arg); } } // This makes sure we reuse the collection when a grouping is // instantiated in the same module return replaced ? builder.build() : ctx.getStatementArgument(); }
@Override public void onFullDefinitionDeclared(final StmtContext.Mutable<SchemaNodeIdentifier, DeviationStatement, EffectiveStatement<SchemaNodeIdentifier, DeviationStatement>> ctx) { final QNameModule currentModule = ctx.getFromNamespace(ModuleCtxToModuleQName.class, ctx.getRoot()); final QNameModule targetModule = ctx.coerceStatementArgument().getLastComponent().getModule(); if (currentModule.equals(targetModule)) { throw new InferenceException(ctx.getStatementSourceReference(), "Deviation must not target the same module as the one it is defined in: %s", currentModule); } }