X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-dom-broker%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fmd%2Fsal%2Fdom%2Fstore%2Fimpl%2Ftree%2Fdata%2FStoreMetadataNode.java;h=695a1f1dd3b2becd6088432ab153f220640c9ff9;hp=77186a6509913742c97a9606f2e89f7691e941a8;hb=8ff71ab96c3c6b79954946b633284daa0628f564;hpb=803d525860fbb1974b65ba5605ba5a9dfe1928a4 diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/StoreMetadataNode.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/StoreMetadataNode.java index 77186a6509..695a1f1dd3 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/StoreMetadataNode.java +++ b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/StoreMetadataNode.java @@ -49,11 +49,11 @@ class StoreMetadataNode implements Immutable, Identifiable { Collections.emptyMap()); } - public static Builder builder() { - return new Builder(); + public static Builder builder(final UnsignedLong version) { + return new Builder(version); } - public static Builder builder(StoreMetadataNode node) { + public static Builder builder(final StoreMetadataNode node) { return new Builder(node); } @@ -83,33 +83,17 @@ class StoreMetadataNode implements Immutable, Identifiable { return "StoreMetadataNode [identifier=" + getIdentifier() + ", nodeVersion=" + nodeVersion + "]"; } - public static Optional getVersion(final Optional currentMetadata) { - if (currentMetadata.isPresent()) { - return Optional.of(currentMetadata.get().getNodeVersion()); - } - return Optional.absent(); - } - - 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 createRecursively(final NormalizedNode node, - final UnsignedLong nodeVersion, final UnsignedLong subtreeVersion) { - Builder builder = builder() // - .setNodeVersion(nodeVersion) // - .setSubtreeVersion(subtreeVersion) // + final UnsignedLong version) { + Builder builder = builder(version) // + .setSubtreeVersion(version) // .setData(node); if (node instanceof NormalizedNodeContainer) { @SuppressWarnings("unchecked") NormalizedNodeContainer> nodeContainer = (NormalizedNodeContainer>) node; for (NormalizedNode subNode : nodeContainer.getValue()) { - builder.add(createRecursively(subNode, nodeVersion, subtreeVersion)); + builder.add(createRecursively(subNode, version)); } } return builder.build(); @@ -117,30 +101,22 @@ class StoreMetadataNode implements Immutable, Identifiable { public static class Builder { - private UnsignedLong nodeVersion; + private final UnsignedLong nodeVersion; private UnsignedLong subtreeVersion; private NormalizedNode data; private Map children; private boolean dirty = false; - private Builder() { + private Builder(final UnsignedLong version) { + this.nodeVersion = Preconditions.checkNotNull(version); children = new HashMap<>(); } - private Builder(StoreMetadataNode node) { + private Builder(final StoreMetadataNode node) { + this.nodeVersion = node.getNodeVersion(); children = new HashMap<>(node.children); } - public UnsignedLong getVersion() { - return nodeVersion; - - } - - public Builder setNodeVersion(final UnsignedLong version) { - this.nodeVersion = version; - return this; - } - public Builder setSubtreeVersion(final UnsignedLong version) { this.subtreeVersion = version; return this; @@ -178,7 +154,4 @@ class StoreMetadataNode implements Immutable, Identifiable { } } - public static StoreMetadataNode createRecursively(final NormalizedNode node, final UnsignedLong version) { - return createRecursively(node, version, version); - } }