X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-dom-broker%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fmd%2Fsal%2Fdom%2Fstore%2Fimpl%2Ftree%2FStoreMetadataNode.java;h=8ba0013eb8c0f20870e3a62cc1fa239e6d649f32;hb=a04257d357eccb69d9fda2c4ac171acdc5b76e28;hp=974f817c71776c1bb7a7a27437eba0920e993482;hpb=8b3405d23e3018afdc4cb5e99bab442ced26e304;p=controller.git diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/StoreMetadataNode.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/StoreMetadataNode.java index 974f817c71..8ba0013eb8 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/StoreMetadataNode.java +++ b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/StoreMetadataNode.java @@ -29,8 +29,8 @@ public class StoreMetadataNode implements Immutable, Identifiable, private final Map children; - protected StoreMetadataNode(final NormalizedNode data, final UnsignedLong nodeVersion, final UnsignedLong subtreeVersion, - final Map children) { + protected StoreMetadataNode(final NormalizedNode data, final UnsignedLong nodeVersion, + final UnsignedLong subtreeVersion, final Map children) { this.nodeVersion = nodeVersion; this.subtreeVersion = subtreeVersion; this.data = data; @@ -80,24 +80,26 @@ public class StoreMetadataNode implements Immutable, Identifiable, return Optional.absent(); } - public static Optional getChild(final Optional parent, final PathArgument child) { + public static Optional getChild(final Optional parent, + final PathArgument child) { if (parent.isPresent()) { return parent.get().getChild(child); } return Optional.absent(); } - public static final StoreMetadataNode createRecursivelly(final NormalizedNode node, final UnsignedLong version) { + public static final StoreMetadataNode createRecursivelly(final NormalizedNode node, + final UnsignedLong nodeVersion, final UnsignedLong subtreeVersion) { Builder builder = builder() // - .setNodeVersion(version) // - .setSubtreeVersion(version) // + .setNodeVersion(nodeVersion) // + .setSubtreeVersion(subtreeVersion) // .setData(node); - if(node instanceof NormalizedNodeContainer) { + if (node instanceof NormalizedNodeContainer) { @SuppressWarnings("unchecked") NormalizedNodeContainer> nodeContainer = (NormalizedNodeContainer>) node; - for(NormalizedNode subNode : nodeContainer.getValue()) { - builder.add(createRecursivelly(subNode, version)); + for (NormalizedNode subNode : nodeContainer.getValue()) { + builder.add(createRecursivelly(subNode, nodeVersion, subtreeVersion)); } } return builder.build(); @@ -105,15 +107,13 @@ public class StoreMetadataNode implements Immutable, Identifiable, public static class Builder { - private Builder() { + private UnsignedLong nodeVersion; + private UnsignedLong subtreeVersion; + private NormalizedNode data; + private final ImmutableMap.Builder children = ImmutableMap.builder(); - } - - UnsignedLong nodeVersion = UnsignedLong.valueOf(0); - UnsignedLong subtreeVersion = UnsignedLong.valueOf(0); - NormalizedNode data; + private Builder() {} - final ImmutableMap.Builder children = ImmutableMap.builder(); public UnsignedLong getVersion() { return nodeVersion; @@ -130,7 +130,7 @@ public class StoreMetadataNode implements Immutable, Identifiable, return this; } - public Builder setData(final NormalizedNode data) { + public Builder setData(final NormalizedNode data) { this.data = data; return this; } @@ -141,10 +141,15 @@ public class StoreMetadataNode implements Immutable, Identifiable, } public StoreMetadataNode build() { - checkState(data != null,"Data node should not be null."); - checkState(subtreeVersion.compareTo(nodeVersion) >= 0, "Subtree version must be equals or greater than node version."); + checkState(data != null, "Data node should not be null."); + checkState(subtreeVersion.compareTo(nodeVersion) >= 0, + "Subtree version must be equals or greater than node version."); return new StoreMetadataNode(data, nodeVersion, subtreeVersion, children.build()); } } + public static StoreMetadataNode createRecursivelly(final NormalizedNode node, final UnsignedLong version) { + return createRecursivelly(node, version, version); + } + }