public static DataSchemaNode findSchemaForChild(final ChoiceSchemaNode schema, final QName childPartialQName) { for (final CaseSchemaNode choiceCaseNode : schema.getCases().values()) { final Optional<DataSchemaNode> childSchema = findFirstSchema(childPartialQName, choiceCaseNode.getChildNodes()); if (childSchema.isPresent()) { return childSchema.get(); } } throw new IllegalStateException(String.format("Unknown child(ren) node(s) detected, identified by: %s, in: %s", childPartialQName, schema)); }
public static DataSchemaNode findSchemaForChild(final ChoiceSchemaNode schema, final QName childPartialQName) { for (final CaseSchemaNode choiceCaseNode : schema.getCases().values()) { final Optional<DataSchemaNode> childSchema = findFirstSchema(childPartialQName, choiceCaseNode.getChildNodes()); if (childSchema.isPresent()) { return childSchema.get(); } } throw new IllegalStateException(String.format("Unknown child(ren) node(s) detected, identified by: %s, in: %s", childPartialQName, schema)); }
protected ChoiceNodeContextNode(final ChoiceSchemaNode schema) { super(NodeIdentifier.create(schema.getQName()), schema); ImmutableMap.Builder<QName, DataSchemaContextNode<?>> byQNameBuilder = ImmutableMap.builder(); ImmutableMap.Builder<PathArgument, DataSchemaContextNode<?>> byArgBuilder = ImmutableMap.builder(); for (CaseSchemaNode caze : schema.getCases().values()) { for (DataSchemaNode cazeChild : caze.getChildNodes()) { DataSchemaContextNode<?> childOp = fromDataSchemaNode(cazeChild); byArgBuilder.put(childOp.getIdentifier(), childOp); for (QName qname : childOp.getQNameIdentifiers()) { byQNameBuilder.put(qname, childOp); } } } byQName = byQNameBuilder.build(); byArg = byArgBuilder.build(); }
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(); }
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(); }
protected ChoiceNodeContextNode(final ChoiceSchemaNode schema) { super(NodeIdentifier.create(schema.getQName()), schema); ImmutableMap.Builder<QName, DataSchemaContextNode<?>> byQNameBuilder = ImmutableMap.builder(); ImmutableMap.Builder<PathArgument, DataSchemaContextNode<?>> byArgBuilder = ImmutableMap.builder(); for (CaseSchemaNode caze : schema.getCases().values()) { for (DataSchemaNode cazeChild : caze.getChildNodes()) { DataSchemaContextNode<?> childOp = fromDataSchemaNode(cazeChild); byArgBuilder.put(childOp.getIdentifier(), childOp); for (QName qname : childOp.getQNameIdentifiers()) { byQNameBuilder.put(qname, childOp); } } } byQName = byQNameBuilder.build(); byArg = byArgBuilder.build(); }
protected ChoiceNodeNormalization(final ChoiceSchemaNode schema) { super(new NodeIdentifier(schema.getQName()),schema); final ImmutableMap.Builder<QName, DataNormalizationOperation<?>> byQNameBuilder = ImmutableMap.builder(); final ImmutableMap.Builder<PathArgument, DataNormalizationOperation<?>> byArgBuilder = ImmutableMap.builder(); for (final CaseSchemaNode caze : schema.getCases().values()) { for (final DataSchemaNode cazeChild : caze.getChildNodes()) { final DataNormalizationOperation<?> childOp = fromDataSchemaNode(cazeChild); byArgBuilder.put(childOp.getIdentifier(), childOp); for (final QName qname : childOp.getQNameIdentifiers()) { byQNameBuilder.put(qname, childOp); } } } byQName = byQNameBuilder.build(); byArg = byArgBuilder.build(); }
private AugmentationSchemaNode findAugmentation(Object currentNode, final YangInstanceIdentifier.AugmentationIdentifier identifier) { if (currentNode != null) { // check if identifier points to some augmentation of currentNode if (currentNode instanceof AugmentationTarget) { Optional<AugmentationSchemaNode> augmentationSchema = ((AugmentationTarget) currentNode).getAvailableAugmentations().stream() .filter(aug -> identifier.equals(new YangInstanceIdentifier.AugmentationIdentifier( aug.getChildNodes().stream() .map(SchemaNode::getQName) .collect(Collectors.toSet())))) .findFirst(); if (augmentationSchema.isPresent()) { return augmentationSchema.get(); } } // continue search: Collection<DataSchemaNode> childNodes = Collections.emptyList(); if (currentNode instanceof DataNodeContainer) { childNodes = ((DataNodeContainer) currentNode).getChildNodes(); } else if (currentNode instanceof ChoiceSchemaNode) { childNodes = ((ChoiceSchemaNode) currentNode).getCases().values().stream() .flatMap(cas -> cas.getChildNodes().stream()).collect(Collectors.toList()); } return childNodes.stream().map(n -> findAugmentation(n, identifier)).filter(n -> n != null).findFirst() .orElse(null); } else { return null; } }
static CaseEnforcer forTree(final CaseSchemaNode schema, final DataTreeConfiguration treeConfig) { final TreeType type = treeConfig.getTreeType(); final Builder<NodeIdentifier, DataSchemaNode> childrenBuilder = ImmutableMap.builder(); final Builder<AugmentationIdentifier, AugmentationSchemaNode> augmentationsBuilder = ImmutableMap.builder(); if (SchemaAwareApplyOperation.belongsToTree(type, schema)) { for (final DataSchemaNode child : schema.getChildNodes()) { if (SchemaAwareApplyOperation.belongsToTree(type, child)) { childrenBuilder.put(NodeIdentifier.create(child.getQName()), child); } } for (final AugmentationSchemaNode augment : schema.getAvailableAugmentations()) { if (augment.getChildNodes().stream() .anyMatch(child -> SchemaAwareApplyOperation.belongsToTree(type, child))) { augmentationsBuilder.put(DataSchemaContextNode.augmentationIdentifierFrom(augment), augment); } } } final ImmutableMap<NodeIdentifier, DataSchemaNode> children = childrenBuilder.build(); return children.isEmpty() ? null : new CaseEnforcer(children, augmentationsBuilder.build(), MandatoryLeafEnforcer.forContainer(schema, treeConfig)); }
static CaseEnforcer forTree(final CaseSchemaNode schema, final DataTreeConfiguration treeConfig) { final TreeType type = treeConfig.getTreeType(); final Builder<NodeIdentifier, DataSchemaNode> childrenBuilder = ImmutableMap.builder(); final Builder<AugmentationIdentifier, AugmentationSchemaNode> augmentationsBuilder = ImmutableMap.builder(); if (SchemaAwareApplyOperation.belongsToTree(type, schema)) { for (final DataSchemaNode child : schema.getChildNodes()) { if (SchemaAwareApplyOperation.belongsToTree(type, child)) { childrenBuilder.put(NodeIdentifier.create(child.getQName()), child); } } for (final AugmentationSchemaNode augment : schema.getAvailableAugmentations()) { if (augment.getChildNodes().stream() .anyMatch(child -> SchemaAwareApplyOperation.belongsToTree(type, child))) { augmentationsBuilder.put(DataSchemaContextNode.augmentationIdentifierFrom(augment), augment); } } } final ImmutableMap<NodeIdentifier, DataSchemaNode> children = childrenBuilder.build(); if (children.isEmpty()) { return null; } final ImmutableMap<AugmentationIdentifier, AugmentationSchemaNode> augmentations = augmentationsBuilder.build(); final Optional<MandatoryLeafEnforcer> enforcer = MandatoryLeafEnforcer.forContainer(schema, treeConfig); return enforcer.isPresent() ? new EnforcingMandatory(children, augmentations, enforcer.get()) : new CaseEnforcer(children, augmentations); }
.flatMap(cas -> cas.getChildNodes().stream()) .filter(child -> child.getQName().equals(identifier.getNodeType())) .findFirst();
for (final DataSchemaNode cazeChild : cazeDef.getSchema().getChildNodes()) { if (cazeChild.isAugmenting()) { final AugmentationSchemaNode augment =
for (final DataSchemaNode cazeChild : cazeDef.getSchema().getChildNodes()) { if (cazeChild.isAugmenting()) { final AugmentationSchemaNode augment = SchemaUtils.findCorrespondingAugment(cazeDef.getSchema(),
return Optional.of(dataChildByName); final Optional<DataSchemaNode> foundDsn = findFirstSchema(qname, choiceCase.getChildNodes()); if (foundDsn.isPresent()) { return foundDsn;
return Optional.of(dataChildByName); final Optional<DataSchemaNode> foundDsn = findFirstSchema(qname, choiceCase.getChildNodes()); if (foundDsn.isPresent()) { return foundDsn;
node = findNamedCase(targetNode, caseLocalName); final Iterable<DataSchemaNode> childNodes = node.getChildNodes(); if (childNodes != null) { resolveDataSchemaNodes(context, caseTypeBuilder, findChildOfType(targetNode), childNodes);
context.addCaseType(caseNode.getPath(), caseTypeBuilder); context.addChoiceToCaseMapping(refChoiceType, caseTypeBuilder, caseNode); final Iterable<DataSchemaNode> caseChildNodes = caseNode.getChildNodes(); if (caseChildNodes != null) { final SchemaPath choiceNodeParentPath = choiceNode.getPath().getParent();
for (final DataSchemaNode dsn : ccNode.getChildNodes()) { if (qNameToNodes.containsKey(dsn.getQName())) { write(qNameToNodes.get(dsn.getQName()), dsn);
for (final DataSchemaNode dsn : ccNode.getChildNodes()) { if (qNameToNodes.containsKey(dsn.getQName())) { write(qNameToNodes.get(dsn.getQName()), dsn);