use of org.opendaylight.yangtools.yang.model.api.AnyxmlSchemaNode in project yangtools by opendaylight.
the class CompositeNodeDataWithSchema method addSimpleChild.
private AbstractNodeDataWithSchema<?> addSimpleChild(final DataSchemaNode schema, final ChildReusePolicy policy) {
final SimpleNodeDataWithSchema<?> newChild;
if (schema instanceof LeafSchemaNode) {
newChild = new LeafNodeDataWithSchema((LeafSchemaNode) schema);
} else if (schema instanceof AnyxmlSchemaNode) {
newChild = new AnyXmlNodeDataWithSchema((AnyxmlSchemaNode) schema);
} else if (schema instanceof AnydataSchemaNode) {
newChild = new AnydataNodeDataWithSchema((AnydataSchemaNode) schema);
} else {
return null;
}
final AugmentationSchemaNode augSchema;
if (schema.isAugmenting()) {
augSchema = findCorrespondingAugment(getSchema(), schema);
} else {
augSchema = null;
}
if (augSchema != null) {
augmentationsToChild.put(augSchema, newChild);
} else {
addChild(newChild);
}
return newChild;
}
use of org.opendaylight.yangtools.yang.model.api.AnyxmlSchemaNode in project mdsal by opendaylight.
the class DataContainerCodecPrototype method computeChildAddressabilitySummary.
private static ChildAddressabilitySummary computeChildAddressabilitySummary(final Object nodeSchema) {
// FIXME: rework this to work on EffectiveStatements
if (nodeSchema instanceof DataNodeContainer) {
boolean haveAddressable = false;
boolean haveUnaddressable = false;
for (DataSchemaNode child : ((DataNodeContainer) nodeSchema).getChildNodes()) {
if (child instanceof ContainerSchemaNode || child instanceof AugmentationSchemaNode) {
haveAddressable = true;
} else if (child instanceof ListSchemaNode) {
if (((ListSchemaNode) child).getKeyDefinition().isEmpty()) {
haveUnaddressable = true;
} else {
haveAddressable = true;
}
} else if (child instanceof AnydataSchemaNode || child instanceof AnyxmlSchemaNode || child instanceof TypedDataSchemaNode) {
haveUnaddressable = true;
} else if (child instanceof ChoiceSchemaNode) {
switch(computeChildAddressabilitySummary(child)) {
case ADDRESSABLE:
haveAddressable = true;
break;
case MIXED:
haveAddressable = true;
haveUnaddressable = true;
break;
case UNADDRESSABLE:
haveUnaddressable = true;
break;
default:
throw new IllegalStateException("Unhandled accessibility summary for " + child);
}
} else {
LOG.warn("Unhandled child node {}", child);
}
}
if (!haveAddressable) {
// Empty or all are unaddressable
return ChildAddressabilitySummary.UNADDRESSABLE;
}
return haveUnaddressable ? ChildAddressabilitySummary.MIXED : ChildAddressabilitySummary.ADDRESSABLE;
} else if (nodeSchema instanceof ChoiceSchemaNode) {
boolean haveAddressable = false;
boolean haveUnaddressable = false;
for (CaseSchemaNode child : ((ChoiceSchemaNode) nodeSchema).getCases()) {
switch(computeChildAddressabilitySummary(child)) {
case ADDRESSABLE:
haveAddressable = true;
break;
case UNADDRESSABLE:
haveUnaddressable = true;
break;
case MIXED:
// A child is mixed, which means we are mixed, too
return ChildAddressabilitySummary.MIXED;
default:
throw new IllegalStateException("Unhandled accessibility summary for " + child);
}
}
if (!haveAddressable) {
// Empty or all are unaddressable
return ChildAddressabilitySummary.UNADDRESSABLE;
}
return haveUnaddressable ? ChildAddressabilitySummary.MIXED : ChildAddressabilitySummary.ADDRESSABLE;
}
// No child nodes possible: return unaddressable
return ChildAddressabilitySummary.UNADDRESSABLE;
}
Aggregations