import java.util.HashMap;
import java.util.Map;
-import org.opendaylight.controller.md.sal.dom.store.impl.tree.StoreTreeNode;
import org.opendaylight.yangtools.concepts.Identifiable;
import org.opendaylight.yangtools.concepts.Immutable;
import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument;
import com.google.common.base.Preconditions;
import com.google.common.primitives.UnsignedLong;
-// FIXME: this should not be public
-public class StoreMetadataNode implements Immutable, Identifiable<PathArgument>, StoreTreeNode<StoreMetadataNode> {
-
+class StoreMetadataNode implements Immutable, Identifiable<PathArgument> {
+ private final Map<PathArgument, StoreMetadataNode> children;
private final UnsignedLong nodeVersion;
private final UnsignedLong subtreeVersion;
private final NormalizedNode<?, ?> data;
- private final Map<PathArgument, StoreMetadataNode> children;
-
/**
*
* @param data
* @param subtreeVersion
* @param children Map of children, must not be modified externally
*/
- protected StoreMetadataNode(final NormalizedNode<?, ?> data, final UnsignedLong nodeVersion,
+ private StoreMetadataNode(final NormalizedNode<?, ?> data, final UnsignedLong nodeVersion,
final UnsignedLong subtreeVersion, final Map<PathArgument, StoreMetadataNode> children) {
- this.nodeVersion = nodeVersion;
- this.subtreeVersion = subtreeVersion;
- this.data = data;
+ this.nodeVersion = Preconditions.checkNotNull(nodeVersion);
+ this.subtreeVersion = Preconditions.checkNotNull(subtreeVersion);
+ this.data = Preconditions.checkNotNull(data);
this.children = Preconditions.checkNotNull(children);
}
Collections.<PathArgument, StoreMetadataNode>emptyMap());
}
- public StoreMetadataNode(final NormalizedNode<?, ?> data, final UnsignedLong nodeVersion,
- final UnsignedLong subtreeVersion) {
- this(data, nodeVersion, subtreeVersion, Collections.<PathArgument, StoreMetadataNode>emptyMap());
- }
-
public static Builder builder() {
return new Builder();
}
return this.data;
}
- @Override
- public Optional<StoreMetadataNode> getChild(final PathArgument key) {
+ Optional<StoreMetadataNode> getChild(final PathArgument key) {
return Optional.fromNullable(children.get(key));
}
children = new HashMap<>();
}
- public Builder(StoreMetadataNode node) {
+ private Builder(StoreMetadataNode node) {
children = new HashMap<>(node.children);
}