private final Map<PathArgument, StoreMetadataNode> children;
- protected StoreMetadataNode(final NormalizedNode<?, ?> data, final UnsignedLong nodeVersion, final UnsignedLong subtreeVersion,
- final Map<PathArgument, StoreMetadataNode> children) {
+ protected StoreMetadataNode(final NormalizedNode<?, ?> data, final UnsignedLong nodeVersion,
+ final UnsignedLong subtreeVersion, final Map<PathArgument, StoreMetadataNode> children) {
this.nodeVersion = nodeVersion;
this.subtreeVersion = subtreeVersion;
this.data = data;
return Optional.absent();
}
- public static Optional<StoreMetadataNode> getChild(final Optional<StoreMetadataNode> parent, final PathArgument child) {
+ public static Optional<StoreMetadataNode> getChild(final Optional<StoreMetadataNode> 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<?, ?, NormalizedNode<?, ?>> nodeContainer = (NormalizedNodeContainer<?, ?, NormalizedNode<?, ?>>) 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();
public static class Builder {
- private Builder() {
+ private UnsignedLong nodeVersion;
+ private UnsignedLong subtreeVersion;
+ private NormalizedNode<?, ?> data;
+ private final ImmutableMap.Builder<PathArgument, StoreMetadataNode> children = ImmutableMap.builder();
- }
-
- UnsignedLong nodeVersion = UnsignedLong.valueOf(0);
- UnsignedLong subtreeVersion = UnsignedLong.valueOf(0);
- NormalizedNode<?, ?> data;
+ private Builder() {}
- final ImmutableMap.Builder<PathArgument, StoreMetadataNode> children = ImmutableMap.builder();
public UnsignedLong getVersion() {
return nodeVersion;
return this;
}
- public Builder setData(final NormalizedNode<?,?> data) {
+ public Builder setData(final NormalizedNode<?, ?> data) {
this.data = data;
return this;
}
}
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);
+ }
+
}