@Override public QName apply(final DataSchemaNode input) { return input.getQName(); } });
private boolean emitCheck(final DataSchemaNode schemaChild) { if (schemaChild.isAugmenting()) { QName root = schemaChild.getPath().getPathFromRoot().iterator().next(); return root.getModule().equals(schemaChild.getQName().getModule()); } return true; }
private static Optional<DataNodeContainer> findDataNodeContainer(final DataNodeContainer ctx, final QName targetQName) { for (final DataSchemaNode child : ctx.getChildNodes()) { if (child instanceof ChoiceSchemaNode) { final DataNodeContainer potential = findInCases((ChoiceSchemaNode) child, targetQName); if (potential != null) { return Optional.of(potential); } } else if (child instanceof DataNodeContainer && child.getQName().equals(targetQName)) { return Optional.of((DataNodeContainer) child); } else if (child instanceof DataNodeContainer // && child.isAddedByUses() // && child.getQName().getLocalName().equals(targetQName.getLocalName())) { return Optional.of((DataNodeContainer) child); } } return Optional.empty(); }
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 void emitBodyOfDataSchemaNode(final DataSchemaNode dataSchemaNode) { dataSchemaNode.getWhenCondition().ifPresent(this::emitWhen); // FIXME: BUG-2444: *(ifFeatureNode ) if (dataSchemaNode instanceof MustConstraintAware) { ((MustConstraintAware) dataSchemaNode).getMustConstraints().forEach(this::emitMust); } emitConfigNode(dataSchemaNode.isConfiguration()); emitDocumentedNode(dataSchemaNode); emitUnknownStatementNodes(dataSchemaNode.getUnknownSchemaNodes()); }
private static String getGetterName(final DataSchemaNode node) { final TypeDefinition<?> type; if (node instanceof TypedDataSchemaNode) { type = ((TypedDataSchemaNode) node).getType(); } else { type = null; } final String prefix; // Bug 8903: If it is a derived type of boolean, not a built-in type, then the return type // of method would be the generated type and the prefix should be 'get'. if (type instanceof BooleanTypeDefinition && (type.getPath().equals(node.getPath()) || type.getBaseType() == null)) { prefix = "is"; } else { prefix = "get"; } return prefix + JavaIdentifierNormalizer.normalizeSpecificIdentifier(node.getQName().getLocalName(), JavaIdentifier.CLASS); }
@Override protected DataNormalizationOperation<?> fromLocalSchemaAndQName(final DataNodeContainer schema, final QName child) { final Optional<DataSchemaNode> potential = findChildSchemaNode(schema, child); if (!potential.isPresent()) { return null; } final DataSchemaNode result = potential.get(); // We try to look up if this node was added by augmentation if (schema instanceof DataSchemaNode && result.isAugmenting()) { return fromAugmentation(schema, (AugmentationTarget) schema, result); } return fromDataSchemaNode(result); }
public static QName getAugmentationQName(final AugmentationSchemaNode augmentation) { checkNotNull(augmentation, "Augmentation must not be null."); final QName identifier = getAugmentationIdentifier(augmentation); if (identifier != null) { return identifier; } URI namespace = null; Optional<Revision> revision = null; if (augmentation instanceof NamespaceRevisionAware) { namespace = ((NamespaceRevisionAware) augmentation).getNamespace(); revision = ((NamespaceRevisionAware) augmentation).getRevision(); } if (namespace == null || revision == null) { for (DataSchemaNode child : augmentation.getChildNodes()) { // Derive QName from child nodes if (!child.isAugmenting()) { namespace = child.getQName().getNamespace(); revision = child.getQName().getRevision(); break; } } } checkState(namespace != null, "Augmentation namespace must not be null"); checkState(revision != null, "Augmentation revision must not be null"); // FIXME: Always return a qname with module namespace. return QName.create(namespace, revision, "foo_augment"); }
private GeneratedTypeBuilder processDataSchemaNode(final Module module, final String basePackageName, final GeneratedTypeBuilder childOf, final DataSchemaNode node) { if (node.isAugmenting() || node.isAddedByUses()) { return null; } final String packageName = packageNameForGeneratedType(basePackageName, node.getPath()); final GeneratedTypeBuilder genType = addDefaultInterfaceDefinition(packageName, node, childOf, module); genType.addComment(node.getDescription()); genType.setDescription(createDescription(node, genType.getFullyQualifiedName())); genType.setModuleName(module.getName()); genType.setReference(node.getReference()); genType.setSchemaPath(node.getPath().getPathFromRoot()); if (node instanceof DataNodeContainer) { genCtx.get(module).addChildNodeType(node, genType); groupingsToGenTypes(module, ((DataNodeContainer) node).getGroupings()); processUsesAugments((DataNodeContainer) node, module); } return genType; }
public Get(DataSchemaNode node, boolean isConfig) { this.schemaNode = node; spec = new Operation(); spec.setMethod(METHOD_NAME); spec.setNickname(METHOD_NAME + "-" + node.getQName().getLocalName()); spec.setType((isConfig ? CONFIG : OPERATIONAL) + node.getQName().getLocalName()); spec.setNotes(node.getDescription()); }
private GeneratedTypeBuilder processDataSchemaNode(final ModuleContext context, final Type baseInterface, final DataSchemaNode node) { if (node.isAugmenting() || node.isAddedByUses()) { return null; } final GeneratedTypeBuilder genType = addDefaultInterfaceDefinition(context, node, baseInterface); annotateDeprecatedIfNecessary(node.getStatus(), genType); final Module module = context.module(); genType.setModuleName(module.getName()); addCodegenInformation(genType, module, node); genType.setSchemaPath(node.getPath()); if (node instanceof DataNodeContainer) { context.addChildNodeType(node, genType); groupingsToGenTypes(context, ((DataNodeContainer) node).getGroupings()); processUsesAugments((DataNodeContainer) node, context); } return genType; }
private static AbstractDOMRpcRoutingTableEntry createRpcEntry(final SchemaContext context, final SchemaPath key, final Map<YangInstanceIdentifier, List<DOMRpcImplementation>> implementations) { final RpcDefinition rpcDef = findRpcDefinition(context, key); if (rpcDef != null) { final ContainerSchemaNode input = rpcDef.getInput(); if (input != null) { for (DataSchemaNode c : input.getChildNodes()) { for (UnknownSchemaNode extension : c.getUnknownSchemaNodes()) { if (CONTEXT_REFERENCE.equals(extension.getNodeType())) { final YangInstanceIdentifier keyId = YangInstanceIdentifier.of(c.getQName()); return new RoutedDOMRpcRoutingTableEntry(rpcDef, keyId, implementations); } } } } return new GlobalDOMRpcRoutingTableEntry(rpcDef, implementations); } else { return new UnknownDOMRpcRoutingTableEntry(key, implementations); } }
if (schemaNodes != null && parent != null) { for (final DataSchemaNode schemaNode : schemaNodes) { if (!schemaNode.isAugmenting() && !schemaNode.isAddedByUses()) { addSchemaNodeToBuilderAsMethod(basePackageName, schemaNode, parent, childOf, module);
@Override public final Optional<ModificationApplyOperation> getChild(final PathArgument child) { throw new UnsupportedOperationException("Node " + schema.getPath() + " is leaf type node. Child nodes not allowed"); }
@Deprecated @Override public boolean isAddedByUses() { return caseShorthandNode.isAddedByUses(); }
public static ModificationApplyOperation from(final DataSchemaNode schemaNode, final DataTreeConfiguration treeConfig) { if (treeConfig.getTreeType() == TreeType.CONFIGURATION) { checkArgument(schemaNode.isConfiguration(), "Supplied %s does not belongs to configuration tree.", schemaNode.getPath()); } if (schemaNode instanceof ContainerSchemaNode) { return ContainerModificationStrategy.of((ContainerSchemaNode) schemaNode, treeConfig); } else if (schemaNode instanceof ListSchemaNode) { return fromListSchemaNode((ListSchemaNode) schemaNode, treeConfig); } else if (schemaNode instanceof ChoiceSchemaNode) { return new ChoiceModificationStrategy((ChoiceSchemaNode) schemaNode, treeConfig); } else if (schemaNode instanceof LeafListSchemaNode) { return fromLeafListSchemaNode((LeafListSchemaNode) schemaNode, treeConfig); } else if (schemaNode instanceof LeafSchemaNode) { return new LeafModificationStrategy((LeafSchemaNode) schemaNode); } throw new IllegalArgumentException("Not supported schema node type for " + schemaNode.getClass()); }
/** * Attempt to find a {@link DefaultDenyWriteSchemaNode} in a parent {@link DataSchemaNode}. * * @param parent Parent to search * @return {@link DefaultDenyWriteSchemaNode} child, if present. */ static Optional<DefaultDenyWriteSchemaNode> findIn(final DataSchemaNode parent) { return parent.getUnknownSchemaNodes().stream().filter(DefaultDenyWriteSchemaNode.class::isInstance).findAny() .map(DefaultDenyWriteSchemaNode.class::cast); } }
if (node.isConfiguration() == isConfig) { property.putOpt(DESCRIPTION_KEY, node.getDescription()); properties.put(name, property);
@Override public Optional<String> getDescription() { return caseShorthandNode.getDescription(); }
final String caseLocalName = caseNode.getQName().getLocalName(); if (caseNode instanceof CaseSchemaNode) { node = (CaseSchemaNode) caseNode; for (DataSchemaNode dataSchemaNode : usesNodeParent.getChildNodes()) { if (dataSchemaNode instanceof ChoiceSchemaNode && targetNodeLocalName.equals(dataSchemaNode.getQName().getLocalName())) { node = findNamedCase((ChoiceSchemaNode) dataSchemaNode, caseLocalName); break; resolveDataSchemaNodes(context, caseTypeBuilder, findChildOfType(targetNode), childNodes); context.addCaseType(caseNode.getPath(), caseTypeBuilder); context.addChoiceToCaseMapping(targetType, caseTypeBuilder, node);