From: Robert Varga Date: Sun, 22 Mar 2015 21:16:36 +0000 (+0100) Subject: Do not use Iterables when we have a collection X-Git-Tag: release/lithium~205^2 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=commitdiff_plain;h=2b47681a5503e19c51e1774c67634f3f4fc27585;p=yangtools.git Do not use Iterables when we have a collection Ever since Ifa6260ebe157c9afde49bbb58043d6ec2fecd189 normalized node containers and lists expose children as a collection, not iterable. That means we have direct access to Collection#size(), so let's use that instead of redirecting through Iterables. Change-Id: I01c245b6b9daa9512e246213dd346f66c77a5a94 Signed-off-by: Robert Varga --- diff --git a/yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/NormalizedNodeContainerModificationStrategy.java b/yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/NormalizedNodeContainerModificationStrategy.java index 5b924d78d5..053d0b0227 100644 --- a/yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/NormalizedNodeContainerModificationStrategy.java +++ b/yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/NormalizedNodeContainerModificationStrategy.java @@ -10,7 +10,7 @@ package org.opendaylight.yangtools.yang.data.impl.schema.tree; import static com.google.common.base.Preconditions.checkArgument; import com.google.common.base.Optional; import com.google.common.collect.ImmutableMap; -import com.google.common.collect.Iterables; +import java.util.Collection; import java.util.Map; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode; @@ -79,7 +79,7 @@ abstract class NormalizedNodeContainerModificationStrategy extends SchemaAwareAp final NormalizedNode newValue = modification.getWrittenValue(); final TreeNode newValueMeta = TreeNodeFactory.createTreeNode(newValue, version); - if (Iterables.isEmpty(modification.getChildren())) { + if (modification.getChildren().isEmpty()) { return newValueMeta; } @@ -158,8 +158,8 @@ abstract class NormalizedNodeContainerModificationStrategy extends SchemaAwareAp * The user has issued an empty merge operation. In this case we do not perform * a data tree mutation, do not pass GO, and do not collect useless garbage. */ - final Iterable children = modification.getChildren(); - if (Iterables.isEmpty(children)) { + final Collection children = modification.getChildren(); + if (children.isEmpty()) { newMeta.setData(currentMeta.getData()); return newMeta.seal(); } diff --git a/yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/UnkeyedListModificationStrategy.java b/yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/UnkeyedListModificationStrategy.java index ace568fd21..23140b86a6 100644 --- a/yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/UnkeyedListModificationStrategy.java +++ b/yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/UnkeyedListModificationStrategy.java @@ -8,7 +8,6 @@ package org.opendaylight.yangtools.yang.data.impl.schema.tree; import com.google.common.base.Optional; -import com.google.common.collect.Iterables; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument; @@ -54,7 +53,7 @@ final class UnkeyedListModificationStrategy extends SchemaAwareApplyOperation { final NormalizedNode newValue = modification.getWrittenValue(); final TreeNode newValueMeta = TreeNodeFactory.createTreeNode(newValue, version); - if (Iterables.isEmpty(modification.getChildren())) { + if (modification.getChildren().isEmpty()) { return newValueMeta; } @@ -130,4 +129,4 @@ final class UnkeyedListModificationStrategy extends SchemaAwareApplyOperation { final Optional current) throws IncorrectDataStructureException { throw new IncorrectDataStructureException(path, "Subtree modification is not allowed."); } -} \ No newline at end of file +}