X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-binding-broker%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fmd%2Fsal%2Fbinding%2Fimpl%2FLazyDataObjectModification.java;h=1a21b98d0475a557854a7c6618ac716a1957a521;hp=c3aff15e7a600f4fe83743e1ee77688273dc46db;hb=e8891e7fcf3cbf9de7217d6e7dee59be6e2bb2a6;hpb=69543467bb4960dca6723848a59d2509881b63a8 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 c3aff15e7a..1a21b98d04 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,7 +7,9 @@ */ package org.opendaylight.controller.md.sal.binding.impl; -import com.google.common.base.Preconditions; +import static java.util.Objects.requireNonNull; +import static org.opendaylight.yangtools.yang.data.api.schema.tree.ModificationType.UNMODIFIED; + import java.util.ArrayList; import java.util.Collection; import java.util.Iterator; @@ -54,14 +56,14 @@ final class LazyDataObjectModification implements DataObje private volatile ModificationType modificationType; private LazyDataObjectModification(final BindingCodecTreeNode codec, final DataTreeCandidateNode domData) { - this.codec = Preconditions.checkNotNull(codec); - this.domData = Preconditions.checkNotNull(domData); + this.codec = requireNonNull(codec); + this.domData = requireNonNull(domData); this.identifier = codec.deserializePathArgument(domData.getIdentifier()); } static LazyDataObjectModification create(final BindingCodecTreeNode codec, final DataTreeCandidateNode domData) { - return new LazyDataObjectModification<>(codec,domData); + return new LazyDataObjectModification<>(codec, domData); } private static Collection> from( @@ -74,22 +76,24 @@ final class LazyDataObjectModification implements DataObje private static void populateList(final List> result, final BindingCodecTreeNode parentCodec, final Collection domChildNodes) { for (final DataTreeCandidateNode domChildNode : domChildNodes) { - final BindingStructuralType type = BindingStructuralType.from(domChildNode); - if (type != BindingStructuralType.NOT_ADDRESSABLE) { - /* - * Even if type is UNKNOWN, from perspective of BindingStructuralType - * we try to load codec for it. We will use that type to further specify - * debug log. - */ - try { - final BindingCodecTreeNode childCodec = - parentCodec.yangPathArgumentChild(domChildNode.getIdentifier()); - populateList(result,type, childCodec, domChildNode); - } catch (final IllegalArgumentException e) { - if (type == BindingStructuralType.UNKNOWN) { - LOG.debug("Unable to deserialize unknown DOM node {}",domChildNode,e); - } else { - LOG.debug("Binding representation for DOM node {} was not found",domChildNode,e); + if (domChildNode.getModificationType() != UNMODIFIED) { + final BindingStructuralType type = BindingStructuralType.from(domChildNode); + if (type != BindingStructuralType.NOT_ADDRESSABLE) { + /* + * Even if type is UNKNOWN, from perspective of BindingStructuralType + * we try to load codec for it. We will use that type to further specify + * debug log. + */ + try { + final BindingCodecTreeNode childCodec = + parentCodec.yangPathArgumentChild(domChildNode.getIdentifier()); + populateList(result, type, childCodec, domChildNode); + } catch (final IllegalArgumentException e) { + if (type == BindingStructuralType.UNKNOWN) { + LOG.debug("Unable to deserialize unknown DOM node {}", domChildNode, e); + } else { + LOG.debug("Binding representation for DOM node {} was not found", domChildNode, e); + } } } } @@ -119,7 +123,9 @@ final class LazyDataObjectModification implements DataObje private static void populateListWithSingleCodec(final List> result, final BindingCodecTreeNode codec, final Collection childNodes) { for (final DataTreeCandidateNode child : childNodes) { - result.add(create(codec, child)); + if (child.getModificationType() != UNMODIFIED) { + result.add(create(codec, child)); + } } } @@ -234,10 +240,7 @@ final class LazyDataObjectModification implements DataObje while (toEnter.hasNext() && current != null) { current = current.getModifiedChild(toEnter.next()); } - if (current != null) { - return create(childCodec, current); - } - return null; + return current != null && current.getModificationType() != UNMODIFIED ? create(childCodec, current) : null; } @Override