/** * Note: the method would be overrided by {@link AbstractAugmentSerializerSource#getChildNodes()}, * since all augmentation schema nodes of same target would be grouped into sort of one node, * so call {@link AbstractAugmentSerializerSource#getChildNodes()} to get all these children * nodes of same target augmentation schemas. */ protected Collection<DataSchemaNode> getChildNodes() { return schemaNode.getChildNodes(); }
@Override public boolean hasNext() { if (container.getChildNodes() != null) { final Collection<DataSchemaNode> childNodes = container.getChildNodes(); if (childNodes != null && !childNodes.isEmpty()) { return childNodes.iterator().hasNext(); } } return false; }
@Override public final Optional<ModificationApplyOperation> getChild(final PathArgument identifier) { try { return Optional.ofNullable(childCache.get(identifier)); } catch (ExecutionException | UncheckedExecutionException e) { LOG.trace("Child {} not present in container schema {} children {}", identifier, this, schema.getChildNodes(), e); return Optional.empty(); } }
@Override public final Optional<ModificationApplyOperation> getChild(final PathArgument identifier) { try { return Optional.ofNullable(childCache.get(identifier)); } catch (ExecutionException | UncheckedExecutionException e) { LOG.trace("Child {} not present in container schema {} children {}", identifier, this, schema.getChildNodes(), e); return Optional.empty(); } }
private static int getChildNodeSizeWithoutUses(final DataNodeContainer csn) { int result = 0; for (DataSchemaNode dsn : csn.getChildNodes()) { if (dsn.isAddedByUses() == false) { result++; } } return result; }
/** * Recursively find all child nodes that come from choices. * * @param schema schema * @return Map with all child nodes, to their most top augmentation */ public static Map<QName, ChoiceSchemaNode> mapChildElementsFromChoices(final DataNodeContainer schema) { return mapChildElementsFromChoices(schema, schema.getChildNodes()); }
private static DataSchemaNode searchInChoices(final DataNodeContainer node, final QName arg) { for (DataSchemaNode child : node.getChildNodes()) { if (child instanceof ChoiceSchemaNode) { ChoiceSchemaNode choiceNode = (ChoiceSchemaNode) child; DataSchemaNode potential = searchInCases(choiceNode, arg); if (potential != null) { return potential; } } } return null; }
private static final void getAllTheNodesHelper(DataNodeContainer dcn, Set<DataSchemaNode> nodes) { for (DataSchemaNode dsn : dcn.getChildNodes()) { if (dsn instanceof DataNodeContainer) { getAllTheNodesHelper((DataNodeContainer) dsn, nodes); } nodes.add(dsn); } }
private static Optional<DataSchemaNode> findChildSchemaNode(final DataNodeContainer parent, final QName child) { DataSchemaNode potential = parent.getDataChildByName(child); if (potential == null) { final Iterable<ChoiceSchemaNode> choices = FluentIterable.from(parent.getChildNodes()) .filter(ChoiceSchemaNode.class); potential = findChoice(choices, child); } return Optional.fromNullable(potential); }
@Nullable public static DataSchemaNode findSchemaForChild(final DataNodeContainer schema, final QName qname, final boolean strictMode) { if (strictMode) { return findSchemaForChild(schema, qname); } final Optional<DataSchemaNode> childSchemaOptional = findFirstSchema(qname, schema.getChildNodes()); if (!childSchemaOptional.isPresent()) { return null; } return childSchemaOptional.get(); }
@Nullable public static DataSchemaNode findSchemaForChild(final DataNodeContainer schema, final QName qname, final boolean strictMode) { if (strictMode) { return findSchemaForChild(schema, qname); } final Optional<DataSchemaNode> childSchemaOptional = findFirstSchema(qname, schema.getChildNodes()); if (!childSchemaOptional.isPresent()) { return null; } return childSchemaOptional.get(); }
private static Optional<DataSchemaNode> findChildSchemaNode(final DataNodeContainer parent, final QName child) { DataSchemaNode potential = parent.getDataChildByName(child); if (potential == null) { potential = findChoice(Iterables.filter(parent.getChildNodes(), ChoiceSchemaNode.class), child); } return Optional.ofNullable(potential); }
private static Optional<DataSchemaNode> findChildSchemaNode(final DataNodeContainer parent, final QName child) { DataSchemaNode potential = parent.getDataChildByName(child); if (potential == null) { potential = findChoice(Iterables.filter(parent.getChildNodes(), ChoiceSchemaNode.class), child); } return Optional.ofNullable(potential); }
@Override public ImmutableMap<String, LeafNodeCodecContext<?>> getLeafNodes(final Class<?> parentClass, final DataNodeContainer childSchema) { final Map<String, DataSchemaNode> getterToLeafSchema = new HashMap<>(); for (final DataSchemaNode leaf : childSchema.getChildNodes()) { if (leaf instanceof TypedDataSchemaNode) { getterToLeafSchema.put(BindingSchemaMapping.getGetterMethodName((TypedDataSchemaNode) leaf), leaf); } } return getLeafNodesUsingReflection(parentClass, getterToLeafSchema); }
private static Map<String, AttributeIfc> fillConfiguration(final DataNodeContainer dataNodeContainer, final Module currentModule, final TypeProviderWrapper typeProviderWrapper, final Map<QName, ServiceInterfaceEntry> qNamesToSIEs, final SchemaContext schemaContext, final String packageName) { Map<String, AttributeIfc> yangToAttributes = new HashMap<>(); for (DataSchemaNode attrNode : dataNodeContainer.getChildNodes()) { AttributeIfc attributeValue = getAttributeValue(attrNode, currentModule, qNamesToSIEs, typeProviderWrapper, schemaContext, packageName); yangToAttributes.put(attributeValue.getAttributeYangName(), attributeValue); } return yangToAttributes; }
static DataSchemaNode findChildSchemaNode(final DataNodeContainer parent, final QName child) { final DataSchemaNode potential = parent.getDataChildByName(child); return potential == null ? findChoice(Iterables.filter(parent.getChildNodes(), ChoiceSchemaNode.class), child) : potential; }
@Override public ImmutableMap<String, AnyxmlNodeCodecContext<?>> getAnyxmlNodes(final Class<?> parentClass, final DataNodeContainer childSchema) { final Map<String, DataSchemaNode> getterToAnyxmlSchema = new HashMap<>(); for (final DataSchemaNode anyxml : childSchema.getChildNodes()) { if (anyxml instanceof AnyXmlSchemaNode) { getterToAnyxmlSchema.put(getGetterName(anyxml.getQName(), false), anyxml); } } return getAnyxmlNodesUsingReflection(parentClass, getterToAnyxmlSchema); }
@Override public ImmutableMap<String, LeafNodeCodecContext<?>> getLeafNodes(final Class<?> parentClass, final DataNodeContainer childSchema) { final Map<String, DataSchemaNode> getterToLeafSchema = new HashMap<>(); for (final DataSchemaNode leaf : childSchema.getChildNodes()) { if (leaf instanceof TypedDataSchemaNode) { getterToLeafSchema.put(getGetterName(leaf, ((TypedDataSchemaNode) leaf).getType()), leaf); } } return getLeafNodesUsingReflection(parentClass, getterToLeafSchema); }
static InstanceIdToNodes<?> fromSchemaAndQNameChecked(final DataNodeContainer schema, final QName child) { final Optional<DataSchemaNode> potential = findChildSchemaNode(schema, child); checkArgument(potential.isPresent(), "Supplied QName %s is not valid according to schema %s, potential children nodes: %s", child, schema, schema.getChildNodes()); 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); }
static InstanceIdToNodes<?> fromSchemaAndQNameChecked(final DataNodeContainer schema, final QName child) { final Optional<DataSchemaNode> potential = findChildSchemaNode(schema, child); checkArgument(potential.isPresent(), "Supplied QName %s is not valid according to schema %s, potential children nodes: %s", child, schema, schema.getChildNodes()); 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); }