X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-binding-broker%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fmd%2Fsal%2Fbinding%2Fimpl%2FLazyDataObjectModification.java;h=c7f850e04e9edcf77672b9de1096fde73cb90049;hb=8a01ebe93fac21b1ae80dcfcc81c21543ec1a687;hp=1a21b98d0475a557854a7c6618ac716a1957a521;hpb=9d4ff4c4045fdef38e3940d336d2825df29c4d65;p=controller.git diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/LazyDataObjectModification.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/LazyDataObjectModification.java index 1a21b98d04..c7f850e04e 100644 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/LazyDataObjectModification.java +++ b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/LazyDataObjectModification.java @@ -7,6 +7,7 @@ */ package org.opendaylight.controller.md.sal.binding.impl; +import static com.google.common.base.Verify.verify; import static java.util.Objects.requireNonNull; import static org.opendaylight.yangtools.yang.data.api.schema.tree.ModificationType.UNMODIFIED; @@ -20,6 +21,7 @@ import java.util.stream.Stream; import org.opendaylight.controller.md.sal.binding.api.DataObjectModification; import org.opendaylight.mdsal.binding.dom.adapter.BindingStructuralType; import org.opendaylight.mdsal.binding.dom.codec.api.BindingCodecTreeNode; +import org.opendaylight.mdsal.binding.dom.codec.api.BindingDataObjectCodecTreeNode; import org.opendaylight.yangtools.yang.binding.Augmentation; import org.opendaylight.yangtools.yang.binding.ChildOf; import org.opendaylight.yangtools.yang.binding.ChoiceIn; @@ -44,37 +46,41 @@ import org.slf4j.LoggerFactory; * * @param Type of Binding Data Object */ +@Deprecated final class LazyDataObjectModification implements DataObjectModification { private static final Logger LOG = LoggerFactory.getLogger(LazyDataObjectModification.class); - private final BindingCodecTreeNode codec; + private final BindingDataObjectCodecTreeNode codec; private final DataTreeCandidateNode domData; private final PathArgument identifier; private volatile Collection> childNodesCache; private volatile ModificationType modificationType; - private LazyDataObjectModification(final BindingCodecTreeNode codec, final DataTreeCandidateNode domData) { + private LazyDataObjectModification(final BindingDataObjectCodecTreeNode codec, + final DataTreeCandidateNode domData) { this.codec = requireNonNull(codec); this.domData = requireNonNull(domData); this.identifier = codec.deserializePathArgument(domData.getIdentifier()); } - static LazyDataObjectModification create(final BindingCodecTreeNode codec, + static LazyDataObjectModification create(final BindingDataObjectCodecTreeNode codec, final DataTreeCandidateNode domData) { return new LazyDataObjectModification<>(codec, domData); } private static Collection> from( - final BindingCodecTreeNode parentCodec, final Collection domChildNodes) { + final BindingDataObjectCodecTreeNode parentCodec, + final Collection domChildNodes) { final List> result = new ArrayList<>(domChildNodes.size()); populateList(result, parentCodec, domChildNodes); return result; } private static void populateList(final List> result, - final BindingCodecTreeNode parentCodec, final Collection domChildNodes) { + final BindingDataObjectCodecTreeNode parentCodec, + final Collection domChildNodes) { for (final DataTreeCandidateNode domChildNode : domChildNodes) { if (domChildNode.getModificationType() != UNMODIFIED) { final BindingStructuralType type = BindingStructuralType.from(domChildNode); @@ -85,9 +91,11 @@ final class LazyDataObjectModification implements DataObje * debug log. */ try { - final BindingCodecTreeNode childCodec = - parentCodec.yangPathArgumentChild(domChildNode.getIdentifier()); - populateList(result, type, childCodec, domChildNode); + final BindingCodecTreeNode childCodec = parentCodec.yangPathArgumentChild( + domChildNode.getIdentifier()); + verify(childCodec instanceof BindingDataObjectCodecTreeNode, "Unhandled codec %s for type %s", + childCodec, type); + populateList(result, type, (BindingDataObjectCodecTreeNode) childCodec, domChildNode); } catch (final IllegalArgumentException e) { if (type == BindingStructuralType.UNKNOWN) { LOG.debug("Unable to deserialize unknown DOM node {}", domChildNode, e); @@ -101,7 +109,7 @@ final class LazyDataObjectModification implements DataObje } private static void populateList(final List> result, - final BindingStructuralType type, final BindingCodecTreeNode childCodec, + final BindingStructuralType type, final BindingDataObjectCodecTreeNode childCodec, final DataTreeCandidateNode domChildNode) { switch (type) { case INVISIBLE_LIST: @@ -121,7 +129,7 @@ final class LazyDataObjectModification implements DataObje } private static void populateListWithSingleCodec(final List> result, - final BindingCodecTreeNode codec, final Collection childNodes) { + final BindingDataObjectCodecTreeNode codec, final Collection childNodes) { for (final DataTreeCandidateNode child : childNodes) { if (child.getModificationType() != UNMODIFIED) { result.add(create(codec, child)); @@ -234,11 +242,11 @@ final class LazyDataObjectModification implements DataObje @Override public DataObjectModification getModifiedChild(final PathArgument arg) { final List domArgumentList = new ArrayList<>(); - final BindingCodecTreeNode childCodec = codec.bindingPathArgumentChild(arg, domArgumentList); + final BindingDataObjectCodecTreeNode childCodec = codec.bindingPathArgumentChild(arg, domArgumentList); final Iterator toEnter = domArgumentList.iterator(); DataTreeCandidateNode current = domData; while (toEnter.hasNext() && current != null) { - current = current.getModifiedChild(toEnter.next()); + current = current.getModifiedChild(toEnter.next()).orElse(null); } return current != null && current.getModificationType() != UNMODIFIED ? create(childCodec, current) : null; }