X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=yang%2Fyang-data-impl%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fyangtools%2Fyang%2Fdata%2Fimpl%2Fschema%2FInstanceIdToNodes.java;h=8590557411cde7e07f639c1199650a61837c1df6;hb=970923b5f47f7507ec78021965fa5df1a878af48;hp=43c13bba67d1be440022c28b85af176177794114;hpb=c8668229ad6e73d5ae03a52f4b87e8e4d2a67c6e;p=yangtools.git diff --git a/yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/InstanceIdToNodes.java b/yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/InstanceIdToNodes.java index 43c13bba67..8590557411 100644 --- a/yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/InstanceIdToNodes.java +++ b/yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/InstanceIdToNodes.java @@ -16,7 +16,8 @@ import java.util.List; import java.util.Optional; import javax.xml.transform.dom.DOMSource; import org.eclipse.jdt.annotation.NonNull; -import org.opendaylight.yangtools.concepts.AbstractIdentifiable; +import org.eclipse.jdt.annotation.Nullable; +import org.opendaylight.yangtools.concepts.AbstractSimpleIdentifiable; import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument; @@ -33,7 +34,7 @@ import org.opendaylight.yangtools.yang.model.api.AugmentationSchemaNode; import org.opendaylight.yangtools.yang.model.api.AugmentationTarget; import org.opendaylight.yangtools.yang.model.api.CaseSchemaNode; import org.opendaylight.yangtools.yang.model.api.ChoiceSchemaNode; -import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode; +import org.opendaylight.yangtools.yang.model.api.ContainerLike; import org.opendaylight.yangtools.yang.model.api.DataNodeContainer; import org.opendaylight.yangtools.yang.model.api.DataSchemaNode; import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode; @@ -44,7 +45,7 @@ import org.opendaylight.yangtools.yang.model.api.ListSchemaNode; * Base strategy for converting an instance identifier into a normalized node structure. * Use provided static methods for generic YangInstanceIdentifier -> NormalizedNode translation in ImmutableNodes. */ -abstract class InstanceIdToNodes extends AbstractIdentifiable { +abstract class InstanceIdToNodes extends AbstractSimpleIdentifiable { InstanceIdToNodes(final T identifier) { super(identifier); } @@ -55,7 +56,7 @@ abstract class InstanceIdToNodes extends AbstractIdentif * @param child child identifier * @return transformation strategy for a specific child */ - abstract InstanceIdToNodes getChild(PathArgument child); + abstract @Nullable InstanceIdToNodes getChild(PathArgument child); /** * Convert instance identifier into a NormalizedNode structure. @@ -65,8 +66,8 @@ abstract class InstanceIdToNodes extends AbstractIdentif * @param operation Optional modify operation to be set on the last child * @return NormalizedNode structure corresponding to submitted instance ID */ - abstract @NonNull NormalizedNode create(PathArgument first, Iterator others, - Optional> deepestChild); + abstract @NonNull NormalizedNode create(PathArgument first, Iterator others, + Optional deepestChild); abstract boolean isMixin(); @@ -116,16 +117,16 @@ abstract class InstanceIdToNodes extends AbstractIdentif } @Override - NormalizedNode create(final PathArgument first, final Iterator others, - final Optional> deepestChild) { + NormalizedNode create(final PathArgument first, final Iterator others, + final Optional deepestChild) { checkState(deepestChild.isPresent(), "Cannot instantiate anydata node without a value"); - final NormalizedNode child = deepestChild.get(); + final NormalizedNode child = deepestChild.get(); checkState(child instanceof AnydataNode, "Invalid child %s", child); return createAnydata((AnydataNode) child); } private AnydataNode createAnydata(final AnydataNode child) { - return Builders.anydataBuilder(child.getValueObjectModel()).withValue(child.getValue()) + return Builders.anydataBuilder(child.bodyObjectModel()).withValue(child.body()) .withNodeIdentifier(getIdentifier()).build(); } } @@ -136,15 +137,15 @@ abstract class InstanceIdToNodes extends AbstractIdentif } @Override - NormalizedNode create(final PathArgument first, final Iterator others, - final Optional> deepestChild) { + NormalizedNode create(final PathArgument first, final Iterator others, + final Optional deepestChild) { final NormalizedNodeBuilder builder = Builders.anyXmlBuilder() .withNodeIdentifier(getIdentifier()); if (deepestChild.isPresent()) { - final NormalizedNode child = deepestChild.get(); + final NormalizedNode child = deepestChild.get(); checkState(child instanceof DOMSourceAnyxmlNode, "Invalid child %s", child); - builder.withValue(((DOMSourceAnyxmlNode) child).getValue()); + builder.withValue(((DOMSourceAnyxmlNode) child).body()); } return builder.build(); @@ -157,7 +158,7 @@ abstract class InstanceIdToNodes extends AbstractIdentif findChoice(Iterables.filter(parent.getChildNodes(), ChoiceSchemaNode.class), child)); } - static InstanceIdToNodes fromSchemaAndQNameChecked(final DataNodeContainer schema, final QName child) { + static @Nullable InstanceIdToNodes fromSchemaAndQNameChecked(final DataNodeContainer schema, final QName child) { final Optional potential = findChildSchemaNode(schema, child); checkArgument(potential.isPresent(), "Supplied QName %s is not valid according to schema %s, potential children nodes: %s", child, schema, @@ -171,9 +172,9 @@ abstract class InstanceIdToNodes extends AbstractIdentif return fromDataSchemaNode(result); } - private static ChoiceSchemaNode findChoice(final Iterable choices, final QName child) { + private static @Nullable ChoiceSchemaNode findChoice(final Iterable choices, final QName child) { for (final ChoiceSchemaNode choice : choices) { - for (final CaseSchemaNode caze : choice.getCases().values()) { + for (final CaseSchemaNode caze : choice.getCases()) { if (findChildSchemaNode(caze, child).isPresent()) { return choice; } @@ -190,7 +191,7 @@ abstract class InstanceIdToNodes extends AbstractIdentif * otherwise returns a SchemaPathUtil for child as * call for {@link #fromDataSchemaNode(org.opendaylight.yangtools.yang.model.api.DataSchemaNode)}. */ - private static InstanceIdToNodes fromAugmentation(final DataNodeContainer parent, + private static @Nullable InstanceIdToNodes fromAugmentation(final DataNodeContainer parent, final AugmentationTarget parentAug, final DataSchemaNode child) { for (final AugmentationSchemaNode aug : parentAug.getAvailableAugmentations()) { final Optional potential = aug.findDataChildByName(child.getQName()); @@ -201,9 +202,9 @@ abstract class InstanceIdToNodes extends AbstractIdentif return fromDataSchemaNode(child); } - static InstanceIdToNodes fromDataSchemaNode(final DataSchemaNode potential) { - if (potential instanceof ContainerSchemaNode) { - return new InstanceIdToCompositeNodes.ContainerTransformation((ContainerSchemaNode) potential); + static @Nullable InstanceIdToNodes fromDataSchemaNode(final DataSchemaNode potential) { + if (potential instanceof ContainerLike) { + return new InstanceIdToCompositeNodes.ContainerTransformation((ContainerLike) potential); } else if (potential instanceof ListSchemaNode) { return fromListSchemaNode((ListSchemaNode) potential); } else if (potential instanceof LeafSchemaNode) {