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(); }
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); } }
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; }
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);
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; }
isDataRoot = true; } else { schemaPath = schemaPath.getParent();
nodePath = dataSchemaContextTree.getChild(path).getDataSchemaNode().getPath(); } else { nodePath = dataSchemaContextTree.getChild(path).getDataSchemaNode().getPath().getParent();
parent = findDataSchemaNode(schemaContext, nodeSp.getParent());
jsonWriter.endObject(); } else { path = path.getParent();
final Iterable<DataSchemaNode> caseChildNodes = caseNode.getChildNodes(); if (caseChildNodes != null) { final SchemaPath choiceNodeParentPath = choiceNode.getPath().getParent();
final Iterable<DataSchemaNode> caseChildNodes = caseNode.getChildNodes(); if (caseChildNodes != null) { final SchemaPath choiceNodeParentPath = choiceNode.getPath().getParent();
isDataRoot = true; } else { path = path.getParent();
private void writeNormalizedNode(XMLStreamWriter xmlWriter, SchemaPath schemaPath, InstanceIdentifierContext<?> pathContext, NormalizedNode<?, ?> data, Optional<Integer> depth) throws IOException { final RestconfNormalizedNodeWriter nnWriter; final SchemaContext schemaCtx = pathContext.getSchemaContext(); if (SchemaPath.ROOT.equals(schemaPath)) { nnWriter = createNormalizedNodeWriter(xmlWriter, schemaCtx, schemaPath, depth); writeElements(xmlWriter, nnWriter, (ContainerNode) data); } else if (pathContext.getSchemaNode() instanceof RpcDefinition) { nnWriter = createNormalizedNodeWriter(xmlWriter, schemaCtx, ((RpcDefinition) pathContext.getSchemaNode()).getOutput().getPath(), depth); writeElements(xmlWriter, nnWriter, (ContainerNode) data); } else { nnWriter = createNormalizedNodeWriter(xmlWriter, schemaCtx, schemaPath.getParent(), depth); if (data instanceof MapEntryNode) { // Restconf allows returning one list item. We need to wrap it // in map node in order to serialize it properly data = ImmutableNodes.mapNodeBuilder(data.getNodeType()).addChild((MapEntryNode) data).build(); } nnWriter.write(data); } nnWriter.flush(); }
checkArgument(baseType != null, "Leaf %s has type for leaf, but no base type", leaf); if (leaf.getPath().equals(baseType.getPath().getParent())) {
checkArgument(baseType != null, "Leaf %s has type for leaf, but no base type", leaf); if (leaf.getPath().equals(baseType.getPath().getParent())) {