/** * Create a child path based on concatenation of this path and a relative path. * * @param relative Relative SchemaPath * @return A new child path */ public SchemaNodeIdentifier createChild(final SchemaNodeIdentifier relative) { checkArgument(!relative.isAbsolute(), "Child creation requires relative path"); return createChild(relative.getPathFromRoot()); }
private SchemaPath createSchemaPath() { final SchemaPath newPath; if (parent == null) { final SchemaPath parentPath = isAbsolute() ? SchemaPath.ROOT : SchemaPath.SAME; newPath = qname == null ? parentPath : parentPath.createChild(qname); } else { newPath = parent.asSchemaPath().createChild(qname); } return SCHEMAPATH_UPDATER.compareAndSet(this, null, newPath) ? newPath : schemaPath; }
/** * Constructs new instance of this class with the concrete path. * * @param absolute * boolean value which specifies if the path is absolute or * relative * @param path * one or more QName instances which specifies exact path to the * module node * * @return A SchemaPath instance. */ public static SchemaNodeIdentifier create(final boolean absolute, final QName... path) { return create(Arrays.asList(path), absolute); }
protected ToStringHelper addToStringAttributes(final ToStringHelper toStringHelper) { return toStringHelper.add("path", getPathFromRoot()); } }
final SchemaNodeIdentifier key) { final NamespaceStorageNode lookupStartStorage; if (key.isAbsolute() || storage.getStorageNodeType() == StorageNodeType.ROOT_STATEMENT_LOCAL) { lookupStartStorage = NamespaceBehaviour.findClosestTowardsRoot(storage, StorageNodeType.GLOBAL); } else { lookupStartStorage = storage; final Iterator<QName> iterator = key.getPathFromRoot().iterator(); if (!iterator.hasNext()) { if (lookupStartStorage instanceof StmtContext<?, ?, ?>) {
@Override public QName getSignificantKey(final SchemaNodeIdentifier key) { return key.getLastComponent(); } }
DeviationEffectiveStatementImpl(final StmtContext<SchemaNodeIdentifier, DeviationStatement, ?> ctx) { super(ctx); this.targetPath = ctx.getStatementArgument().asSchemaPath(); this.deviateDefinitions = ImmutableList.copyOf(allSubstatementsOfType(DeviateDefinition.class)); description = findFirstEffectiveSubstatementArgument(DescriptionEffectiveStatement.class).orElse(null); reference = findFirstEffectiveSubstatementArgument(ReferenceEffectiveStatement.class).orElse(null); List<UnknownSchemaNode> unknownSchemaNodesInit = new ArrayList<>(); for (final EffectiveStatement<?, ?> effectiveStatement : effectiveSubstatements()) { if (effectiveStatement instanceof UnknownSchemaNode) { unknownSchemaNodesInit.add((UnknownSchemaNode) effectiveStatement); } } unknownSchemaNodes = ImmutableList.copyOf(unknownSchemaNodesInit); }
private static Set<Relative> parseUniqueConstraintArgument(final StmtContext<?, ?, ?> ctx, final String argumentValue) { // deal with 'line-break' rule, which is either "\n" or "\r\n", but not "\r" final String nocrlf = CRLF_PATTERN.matcher(argumentValue).replaceAll("\n"); final Set<Relative> uniqueConstraintNodes = new HashSet<>(); for (final String uniqueArgToken : SEP_SPLITTER.split(nocrlf)) { final SchemaNodeIdentifier nodeIdentifier = ArgumentUtils.nodeIdentifierFromPath(ctx, uniqueArgToken); SourceException.throwIf(nodeIdentifier.isAbsolute(), ctx.getStatementSourceReference(), "Unique statement argument '%s' contains schema node identifier '%s' " + "which is not in the descendant node identifier form.", argumentValue, uniqueArgToken); uniqueConstraintNodes.add((Relative) nodeIdentifier); } return ImmutableSet.copyOf(uniqueConstraintNodes); } }
/** * Constructs new instance of this class with the concrete path. * * @param path * list of QName instances which specifies exact path to the * module node * @param absolute * boolean value which specifies if the path is absolute or * relative * * @return A SchemaNodeIdentifier instance. */ public static SchemaNodeIdentifier create(final Iterable<QName> path, final boolean absolute) { final SchemaNodeIdentifier parent = absolute ? ROOT : SAME; return parent.createChild(path); }
/** * Create the {@link SchemaPath} equivalent of this identifier. * * @return SchemaPath equivalent. */ public final SchemaPath asSchemaPath() { final SchemaPath ret = schemaPath; return ret != null ? ret : createSchemaPath(); }
/** * Returns the list of nodes which need to be traversed to get from the * starting point (root for absolute SchemaPaths) to the node represented * by this object. * * @return list of <code>qname</code> instances which represents * path from the root to the schema node. */ public Iterable<QName> getPathFromRoot() { return getLegacyPath(); }
@Override public final String toString() { return addToStringAttributes(MoreObjects.toStringHelper(this)).toString(); }
protected ToStringHelper addToStringAttributes(final ToStringHelper toStringHelper) { return toStringHelper.add("path", getPathFromRoot()); } }
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; }
AugmentEffectiveStatementImpl(final StmtContext<SchemaNodeIdentifier, AugmentStatement, EffectiveStatement<SchemaNodeIdentifier, AugmentStatement>> ctx) { super(ctx); this.targetPath = ctx.coerceStatementArgument().asSchemaPath(); final QNameModule rootModuleQName = StmtContextUtils.getRootModuleQName(ctx); this.namespace = rootModuleQName.getNamespace(); this.revision = rootModuleQName.getRevision().orElse(null); this.copyOf = (AugmentationSchemaNode) ctx.getOriginalCtx().map(StmtContext::buildEffective).orElse(null); whenCondition = findFirstEffectiveSubstatementArgument(WhenEffectiveStatement.class).orElse(null); // initSubstatementCollections final ImmutableSet.Builder<ActionDefinition> actionsBuilder = ImmutableSet.builder(); final ImmutableSet.Builder<NotificationDefinition> notificationsBuilder = ImmutableSet.builder(); final ImmutableList.Builder<UnknownSchemaNode> listBuilder = new ImmutableList.Builder<>(); for (final EffectiveStatement<?, ?> effectiveStatement : effectiveSubstatements()) { if (effectiveStatement instanceof ActionDefinition) { actionsBuilder.add((ActionDefinition) effectiveStatement); } else if (effectiveStatement instanceof NotificationDefinition) { notificationsBuilder.add((NotificationDefinition) effectiveStatement); } else if (effectiveStatement instanceof UnknownSchemaNode) { listBuilder.add((UnknownSchemaNode) effectiveStatement); } } this.actions = actionsBuilder.build(); this.notifications = notificationsBuilder.build(); this.unknownNodes = listBuilder.build(); }
/** * Constructs new instance of this class with the concrete path. * * @param path * list of QName instances which specifies exact path to the * module node * @param absolute * boolean value which specifies if the path is absolute or * relative * * @return A SchemaNodeIdentifier instance. */ public static SchemaNodeIdentifier create(final Iterable<QName> path, final boolean absolute) { final SchemaNodeIdentifier parent = absolute ? ROOT : SAME; return parent.createChild(path); }
/** * Create the {@link SchemaPath} equivalent of this identifier. * * @return SchemaPath equivalent. */ public final SchemaPath asSchemaPath() { final SchemaPath ret = schemaPath; return ret != null ? ret : createSchemaPath(); }
/** * Returns the list of nodes which need to be traversed to get from the * starting point (root for absolute SchemaPaths) to the node represented * by this object. * * @return list of <code>qname</code> instances which represents * path from the root to the schema node. */ public Iterable<QName> getPathFromRoot() { return getLegacyPath(); }
@Override public final String toString() { return addToStringAttributes(MoreObjects.toStringHelper(this)).toString(); }
/** * Create a child path based on concatenation of this path and a relative path. * * @param relative Relative SchemaPath * @return A new child path */ public SchemaNodeIdentifier createChild(final SchemaNodeIdentifier relative) { checkArgument(!relative.isAbsolute(), "Child creation requires relative path"); return createChild(relative.getPathFromRoot()); }