@Override public QName getQName() { return path.getLastComponent(); }
protected ToStringHelper addToStringAttributes(final ToStringHelper toStringHelper) { return toStringHelper.add("path", getPathFromRoot()); } }
public static SchemaPath toPath(final QName rpc) { return SchemaPath.create(true, rpc); }
/** * Create a child path based on concatenation of this path and a relative path. * * @param relative Relative SchemaPath * @return A new child path */ public @NonNull SchemaPath createChild(final SchemaPath relative) { checkArgument(!relative.isAbsolute(), "Child creation requires relative path"); return createChild(relative.getPathFromRoot()); }
static final SchemaPath typeEffectiveSchemaPath(final StmtContext<?, ?, ?> stmtCtx) { final SchemaPath path = stmtCtx.getSchemaPath().get(); final SchemaPath parent = path.getParent(); final QName parentQName = parent.getLastComponent(); Preconditions.checkArgument(parentQName != null, "Path %s has an empty parent", path); final QName qname = stmtCtx.getFromNamespace(QNameCacheNamespace.class, QName.create(parentQName, path.getLastComponent().getLocalName())); return parent.createChild(qname); } }
public static Optional<NormalizedNode<?, ?>> findNode(final NormalizedNode<?, ?> parent, final SchemaPath relativePath) { checkArgument(!relativePath.isAbsolute(), "%s is not a relative path", relativePath); return findNode(Optional.ofNullable(parent), Iterables.transform(relativePath.getPathFromRoot(), NodeIdentifier::new)); }
/** * Create a child path based on concatenation of this path and additional * path elements. * * @param elements Relative SchemaPath elements * @return A new child path */ public @NonNull SchemaPath createChild(final QName... elements) { return createChild(Arrays.asList(elements)); }
final SchemaPath scPath = SchemaPath.create(FluentIterable.from(path.getPathArguments()).transform(new Function<PathArgument, QName>() { final NormalizedNodeStreamWriter domWriter; if(pretty) domWriter = JSONNormalizedNodeStreamWriter.createExclusiveWriter(JSONCodecFactory.create(context), scPath.getParent(), scPath.getLastComponent().getNamespace(), JsonWriterFactory.createJsonWriter(writer,2)); else domWriter = JSONNormalizedNodeStreamWriter.createExclusiveWriter(JSONCodecFactory.create(context), scPath.getParent(), scPath.getLastComponent().getNamespace(), JsonWriterFactory.createJsonWriter(writer)); final BindingStreamEventWriter bindingWriter = codecRegistry.newWriter(path, domWriter);
@Override public RpcResult<?> apply(final DOMRpcResult input) { final NormalizedNode<?, ?> domData = input.getResult(); final DataObject bindingResult; if (domData != null) { final SchemaPath rpcOutput = rpc.createChild(QName.create(rpc.getLastComponent(), "output")); bindingResult = codec.fromNormalizedNodeRpcData(rpcOutput, (ContainerNode) domData); } else { bindingResult = null; } return RpcResult.class.cast(RpcResultBuilder.success(bindingResult).build()); } });
private static boolean isInnerType(final LeafSchemaNode leaf, final TypeDefinition<?> type) { // New parser with encapsulated type if (leaf.getPath().equals(type.getPath())) { return true; } // Embedded type definition with new parser. Also takes care of the old parser with bits if (leaf.getPath().equals(type.getPath().getParent())) { return true; } return false; }
/** * Creates package name from specified <code>basePackageName</code> (package name for module) * and <code>schemaPath</code>. Resulting package name is concatenation of <code>basePackageName</code> * and all local names of YANG nodes which are parents of some node for which <code>schemaPath</code> is specified. * * @param basePackageName string with package name of the module, MUST be normalized, otherwise this method may * return an invalid string. * @param schemaPath list of names of YANG nodes which are parents of some node + name of this node * @return string with valid JAVA package name * @throws NullPointerException if any of the arguments are null */ public static String packageNameForGeneratedType(final String basePackageName, final SchemaPath schemaPath) { final int size = Iterables.size(schemaPath.getPathTowardsRoot()) - 1; if (size <= 0) { return basePackageName; } return generateNormalizedPackageName(basePackageName, schemaPath.getPathFromRoot(), size); }
@Override public boolean equals(final @Nullable Object obj) { if (this == obj) { return true; } if (!(obj instanceof DOMActionInstance)) { return false; } final DOMActionInstance other = (DOMActionInstance) obj; return getType().equals(other.type) && dataTrees.equals(other.dataTrees); }
final Iterable<DataSchemaNode> caseChildNodes = caseNode.getChildNodes(); if (caseChildNodes != null) { final SchemaPath choiceNodeParentPath = choiceNode.getPath().getParent(); if (!Iterables.isEmpty(choiceNodeParentPath.getPathFromRoot())) { SchemaNode parent = findDataSchemaNode(schemaContext, choiceNodeParentPath);
private GeneratedTypeBuilder findChildOfType(final ChoiceSchemaNode targetNode) { final SchemaPath nodePath = targetNode.getPath(); final SchemaPath parentSp = nodePath.getParent(); if (parentSp.getParent() == null) { return moduleContext(nodePath.getLastComponent().getModule()).getModuleNode(); } final SchemaNode parent = findDataSchemaNode(schemaContext, parentSp); GeneratedTypeBuilder childOfType = null; if (parent instanceof CaseSchemaNode) { childOfType = findCaseByPath(parent.getPath()); } else if (parent instanceof DataSchemaNode || parent instanceof NotificationDefinition) { childOfType = findChildNodeByPath(parent.getPath()); } else if (parent instanceof GroupingDefinition) { childOfType = findGroupingByPath(parent.getPath()); } if (childOfType == null) { throw new IllegalArgumentException("Failed to find parent type of choice " + targetNode); } return childOfType; }
public ImplicitCaseSchemaNode(final DataSchemaNode caseShorthandNode) { this.caseShorthandNode = requireNonNull(caseShorthandNode); this.path = requireNonNull(caseShorthandNode.getPath().getParent()); this.original = getOriginalIfPresent(caseShorthandNode); // We need to cache this, as it will be reset this.augmenting = caseShorthandNode.isAugmenting(); }
private ImmutableList<QName> getLegacyPath() { ImmutableList<QName> ret = legacyPath; if (ret == null) { final List<QName> tmp = new ArrayList<>(); for (QName item : getPathTowardsRoot()) { tmp.add(item); } ret = ImmutableList.copyOf(Lists.reverse(tmp)); LEGACYPATH_UPDATER.lazySet(this, ret); } return ret; }
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; }
/** * Create a child path based on concatenation of this path and a relative path. * * @param relative Relative SchemaPath * @return A new child path */ public @NonNull SchemaPath createChild(final SchemaPath relative) { checkArgument(!relative.isAbsolute(), "Child creation requires relative path"); return createChild(relative.getPathFromRoot()); }
/** * Creates package name from specified <code>basePackageName</code> (package name for module) * and <code>schemaPath</code> which crosses an augmentation. Resulting package name is concatenation * of <code>basePackageName</code> and all local names of YANG nodes which are parents of some node for which * <code>schemaPath</code> is specified. * * @param basePackageName string with package name of the module, MUST be normalized, otherwise this method may * return an invalid string. * @param schemaPath list of names of YANG nodes which are parents of some node + name of this node * @return string with valid JAVA package name * @throws NullPointerException if any of the arguments are null */ public static String packageNameForAugmentedGeneratedType(final String basePackageName, final SchemaPath schemaPath) { final int size = Iterables.size(schemaPath.getPathTowardsRoot()); if (size == 0) { return basePackageName; } return generateNormalizedPackageName(basePackageName, schemaPath.getPathFromRoot(), size); }