public Builder setRootPath(final YangInstanceIdentifier rootPath) { this.rootPath = rootPath.toOptimized(); return this; }
public Builder setRootPath(final YangInstanceIdentifier rootPath) { this.rootPath = rootPath.toOptimized(); return this; }
public DOMDataTreeIdentifier toOptimized() { final YangInstanceIdentifier opt = rootIdentifier.toOptimized(); return opt == rootIdentifier ? this : new DOMDataTreeIdentifier(datastoreType, opt); }
private static void findMandatoryNodes(final Builder<YangInstanceIdentifier> builder, final YangInstanceIdentifier id, final DataNodeContainer schema, final TreeType type) { for (final DataSchemaNode child : schema.getChildNodes()) { if (SchemaAwareApplyOperation.belongsToTree(type, child)) { if (child instanceof ContainerSchemaNode) { final ContainerSchemaNode container = (ContainerSchemaNode) child; if (!container.isPresenceContainer()) { findMandatoryNodes(builder, id.node(NodeIdentifier.create(child.getQName())), container, type); } } else { boolean needEnforce = child instanceof MandatoryAware && ((MandatoryAware) child).isMandatory(); if (!needEnforce && child instanceof ElementCountConstraintAware) { needEnforce = ((ElementCountConstraintAware) child) .getElementCountConstraint().map(constraint -> { final Integer min = constraint.getMinElements(); return min != null && min > 0; }).orElse(Boolean.FALSE).booleanValue(); } if (needEnforce) { final YangInstanceIdentifier childId = id.node(NodeIdentifier.create(child.getQName())); LOG.debug("Adding mandatory child {}", childId); builder.add(childId.toOptimized()); } } } } }
private static void findMandatoryNodes(final Builder<YangInstanceIdentifier> builder, final YangInstanceIdentifier id, final DataNodeContainer schema, final TreeType type) { for (final DataSchemaNode child : schema.getChildNodes()) { if (SchemaAwareApplyOperation.belongsToTree(type, child)) { if (child instanceof ContainerSchemaNode) { final ContainerSchemaNode container = (ContainerSchemaNode) child; if (!container.isPresenceContainer()) { findMandatoryNodes(builder, id.node(NodeIdentifier.create(child.getQName())), container, type); } } else { boolean needEnforce = child instanceof MandatoryAware && ((MandatoryAware) child).isMandatory(); if (!needEnforce && child instanceof ElementCountConstraintAware) { needEnforce = ((ElementCountConstraintAware) child) .getElementCountConstraint().map(constraint -> { final Integer min = constraint.getMinElements(); return min != null && min > 0; }).orElse(Boolean.FALSE).booleanValue(); } if (needEnforce) { final YangInstanceIdentifier childId = id.node(NodeIdentifier.create(child.getQName())); LOG.debug("Adding mandatory child {}", childId); builder.add(childId.toOptimized()); } } } } } }