@Override public Set<ChoiceCaseNode> apply(final ChoiceSchemaNode node) { return node.getCases(); } };
ChoiceNodeNormalization(final ChoiceSchemaNode schema) { super(NodeIdentifier.create(schema.getQName())); final ImmutableMap.Builder<PathArgument, InstanceIdToNodes<?>> byArgBuilder = ImmutableMap.builder(); for (final CaseSchemaNode caze : schema.getCases().values()) { for (final DataSchemaNode cazeChild : caze.getChildNodes()) { final InstanceIdToNodes<?> childOp = fromDataSchemaNode(cazeChild); byArgBuilder.put(childOp.getIdentifier(), childOp); } } byArg = byArgBuilder.build(); }
private static CaseSchemaNode findNamedCase(final ChoiceSchemaNode choice, final String caseName) { final List<CaseSchemaNode> cases = choice.findCaseNodes(caseName); return cases.isEmpty() ? null : cases.get(0); }
private void emitChoice(final ChoiceSchemaNode choice) { super.writer.startChoiceNode(choice.getQName()); choice.getWhenCondition().ifPresent(this::emitWhen); // FIXME: BUG-2444: *(ifFeatureNode ) // FIXME: BUG-2444: defaultNode //Optional emitConfigNode(choice.isConfiguration()); emitMandatoryNode(choice.isMandatory()); emitDocumentedNode(choice); for (final CaseSchemaNode caze : choice.getCases().values()) { // TODO: emit short case? emitCaseNode(caze); } emitUnknownStatementNodes(choice.getUnknownSchemaNodes()); super.writer.endNode(); }
foundNode = ((ChoiceSchemaNode) parent).getCaseNodeByName(current); for (final CaseSchemaNode caseNode : ((ChoiceSchemaNode) parent).getCases().values()) { final DataSchemaNode maybeChild = caseNode.getDataChildByName(current); if (maybeChild != null) {
checkArgument(choiceNode != null, "ChoiceNode cannot be NULL."); final Set<ChoiceCaseNode> caseNodes = choiceNode.getCases(); if (caseNodes == null) { return; final Iterable<DataSchemaNode> caseChildNodes = caseNode.getChildNodes(); if (caseChildNodes != null) { final SchemaPath choiceNodeParentPath = choiceNode.getPath().getParent();
for (final ChoiceCaseNode caseNode : choiceNode.getCases()) { final Deque<Object> resultFromRecursion = findPathToSchemaNodeByName(caseNode, elementName); if (!resultFromRecursion.isEmpty()) { resultFromRecursion.push(choiceNode); if (choiceNode.isAugmenting()) { final AugmentationSchema augment = findCorrespondingAugment(schemaNode, choiceNode); if (augment != null) {
@Override protected QName getQName(final ChoiceSchemaNode schema) { return schema.getQName(); }
checkArgument(choiceNode != null, "Choice Schema Node cannot be NULL."); if (!choiceNode.isAddedByUses()) { final String packageName = packageNameForGeneratedType(basePackageName, choiceNode.getPath()); final GeneratedTypeBuilder choiceTypeBuilder = addRawInterfaceDefinition(packageName, choiceNode); constructGetter(parent, choiceNode.getQName().getLocalName(), choiceNode.getDescription(), choiceTypeBuilder); choiceTypeBuilder.addImplementsType(typeForClass(DataContainer.class));
checkArgument(choiceNode != null, "Choice Schema Node cannot be NULL."); if (!choiceNode.isAddedByUses()) { final GeneratedTypeBuilder choiceTypeBuilder = addRawInterfaceDefinition( JavaTypeName.create(packageNameForGeneratedType(context.modulePackageName(), choiceNode.getPath()), BindingMapping.getClassName(choiceNode.getQName())), choiceNode); choiceTypeBuilder.addImplementsType(choiceIn(parent)); annotateDeprecatedIfNecessary(choiceNode.getStatus(), choiceTypeBuilder); context.addChildNodeType(choiceNode, choiceTypeBuilder);
public static Optional<ChoiceCaseNode> findInstantiatedCase(final ChoiceSchemaNode instantiatedChoice, final ChoiceCaseNode originalDefinition) { ChoiceCaseNode potential = instantiatedChoice.getCaseNodeByName(originalDefinition.getQName()); if(originalDefinition.equals(potential)) { return Optional.of(potential); } if (potential != null) { SchemaNode potentialRoot = SchemaNodeUtils.getRootOriginalIfPossible(potential); if (originalDefinition.equals(potentialRoot)) { return Optional.of(potential); } } // We try to find case by name, then lookup its root definition // and compare it with original definition // This solves case, if choice was inside grouping // which was used in different module and thus namespaces are // different, but local names are still same. // // Still we need to check equality of definition, because local name is not // sufficient to uniquelly determine equality of cases // potential = instantiatedChoice.getCaseNodeByName(originalDefinition.getQName().getLocalName()); if(potential != null && (originalDefinition.equals(SchemaNodeUtils.getRootOriginalIfPossible(potential)))) { return Optional.of(potential); } return Optional.absent(); }
final CaseSchemaNode potential = instantiatedChoice.getCaseNodeByName(qname); if (originalDefinition.equals(potential)) { return Optional.of(potential); for (CaseSchemaNode found : instantiatedChoice.findCaseNodes(qname.getLocalName())) { if (originalDefinition.equals(SchemaNodeUtils.getRootOriginalIfPossible(found))) { return Optional.of(found);
final SchemaPath nodeSp = targetNode.getPath(); parent = findDataSchemaNode(schemaContext, nodeSp.getParent()); node = (ChoiceCaseNode) caseNode; } else { node = targetNode.getCaseNodeByName(caseNode.getQName().getLocalName());
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; }
foundNode = ((ChoiceSchemaNode) parent).getCaseNodeByName(current); for (final CaseSchemaNode caseNode : ((ChoiceSchemaNode) parent).getCases().values()) { final DataSchemaNode maybeChild = caseNode.getDataChildByName(current); if (maybeChild != null) {
checkArgument(choiceNode != null, "ChoiceNode cannot be NULL."); for (final CaseSchemaNode caseNode : choiceNode.getCases().values()) { if (caseNode != null && !caseNode.isAddedByUses() && !caseNode.isAugmenting()) { final GeneratedTypeBuilder caseTypeBuilder = addDefaultInterfaceDefinition(context, caseNode); final Iterable<DataSchemaNode> caseChildNodes = caseNode.getChildNodes(); if (caseChildNodes != null) { final SchemaPath choiceNodeParentPath = choiceNode.getPath().getParent();
protected ImmutableChoiceNodeSchemaAwareBuilder(final ChoiceSchemaNode schema) { this.schema = requireNonNull(schema, "Schema was null"); super.withNodeIdentifier(NodeIdentifier.create(schema.getQName())); }
final QName caseQName = arguments.next(); Preconditions.checkArgument(arguments.hasNext(), "Path must not refer case only."); currentNode = ((ChoiceSchemaNode) child).getCaseNodeByName(caseQName); } else {
public static Optional<CaseSchemaNode> findInstantiatedCase(final ChoiceSchemaNode instantiatedChoice, final CaseSchemaNode originalDefinition) { CaseSchemaNode potential = instantiatedChoice.getCaseNodeByName(originalDefinition.getQName()); if (originalDefinition.equals(potential)) { return Optional.of(potential); } if (potential != null) { SchemaNode potentialRoot = SchemaNodeUtils.getRootOriginalIfPossible(potential); if (originalDefinition.equals(potentialRoot)) { return Optional.of(potential); } } // We try to find case by name, then lookup its root definition // and compare it with original definition // This solves case, if choice was inside grouping // which was used in different module and thus namespaces are // different, but local names are still same. // // Still we need to check equality of definition, because local name is not // sufficient to uniquelly determine equality of cases // for (CaseSchemaNode caze : instantiatedChoice.findCaseNodes(originalDefinition.getQName().getLocalName())) { if (originalDefinition.equals(SchemaNodeUtils.getRootOriginalIfPossible(caze))) { return Optional.of(caze); } } return Optional.empty(); }
/** * Returns the concrete case according to specified QName. * * @param qname * QName of sought Choice Case Node * @return child case node of this Choice if child with given name is present, <code>null</code> otherwise. * * @deprecated Use either {@code getCases().get(name)} or #findCase(QName) */ @Deprecated default CaseSchemaNode getCaseNodeByName(final QName qname) { return getCases().get(qname); }