use of org.opendaylight.yangtools.yang.model.api.AugmentationTarget in project yangtools by opendaylight.
the class NormalizedNodeStreamWriterStack method startAugmentationNode.
public AugmentationSchemaNode startAugmentationNode(final AugmentationIdentifier identifier) {
LOG.debug("Enter augmentation {}", identifier);
Object parent = getParent();
checkArgument(parent instanceof AugmentationTarget, "Augmentation not allowed under %s", parent);
if (parent instanceof ChoiceSchemaNode) {
final QName name = Iterables.get(identifier.getPossibleChildNames(), 0);
parent = findCaseByChild((ChoiceSchemaNode) parent, name);
}
checkArgument(parent instanceof DataNodeContainer, "Augmentation allowed only in DataNodeContainer", parent);
final AugmentationSchemaNode schema = findSchemaForAugment((AugmentationTarget) parent, identifier.getPossibleChildNames());
final AugmentationSchemaNode resolvedSchema = new EffectiveAugmentationSchema(schema, (DataNodeContainer) parent);
schemaStack.push(resolvedSchema);
return resolvedSchema;
}
use of org.opendaylight.yangtools.yang.model.api.AugmentationTarget in project netconf by opendaylight.
the class StreamingContext method fromSchemaAndQNameChecked.
static StreamingContext<?> 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()) {
for (final AugmentationSchemaNode aug : ((AugmentationTarget) schema).getAvailableAugmentations()) {
if (aug.dataChildByName(result.getQName()) != null) {
return new Augmentation(aug, schema);
}
}
}
return fromDataSchemaNode(result);
}
use of org.opendaylight.yangtools.yang.model.api.AugmentationTarget in project yangtools by opendaylight.
the class DataNodeContainerModificationStrategy method resolveChild.
private ModificationApplyOperation resolveChild(final PathArgument identifier) {
final T schema = getSchema();
if (identifier instanceof AugmentationIdentifier && schema instanceof AugmentationTarget) {
return SchemaAwareApplyOperation.from(schema, (AugmentationTarget) schema, (AugmentationIdentifier) identifier, treeConfig);
}
final QName qname = identifier.getNodeType();
final Optional<DataSchemaNode> child = schema.findDataChildByName(qname);
if (!child.isPresent()) {
LOG.trace("Child {} not present in container schema {} children {}", identifier, this, schema.getChildNodes());
return null;
}
try {
return SchemaAwareApplyOperation.from(child.get(), treeConfig);
} catch (ExcludedDataSchemaNodeException e) {
LOG.trace("Failed to instantiate child {} in container schema {} children {}", identifier, this, schema.getChildNodes(), e);
return null;
}
}
Aggregations