Bump versions to 4.0.0-SNAPSHOT
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / sharding / DistributedShardModificationFactory.java
1 /*
2  * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.controller.cluster.sharding;
9
10 import static java.util.Objects.requireNonNull;
11
12 import com.google.common.annotations.VisibleForTesting;
13 import com.google.common.collect.ImmutableMap;
14 import java.util.Map;
15 import org.opendaylight.controller.cluster.databroker.actors.dds.ClientTransaction;
16 import org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier;
17 import org.opendaylight.mdsal.dom.spi.shard.ForeignShardModificationContext;
18 import org.opendaylight.mdsal.dom.spi.shard.WriteableModificationNode;
19 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
20
21 /**
22  * Factory for {@link DistributedShardModification}.
23  */
24 @Deprecated(forRemoval = true)
25 public final class DistributedShardModificationFactory {
26     private final Map<DOMDataTreeIdentifier, ForeignShardModificationContext> childShards;
27     private final Map<PathArgument, WriteableModificationNode> children;
28     private final DOMDataTreeIdentifier root;
29
30     DistributedShardModificationFactory(final DOMDataTreeIdentifier root,
31                                         final Map<PathArgument, WriteableModificationNode> children,
32                                         final Map<DOMDataTreeIdentifier, ForeignShardModificationContext> childShards) {
33         this.root = requireNonNull(root);
34         this.children = ImmutableMap.copyOf(children);
35         this.childShards = ImmutableMap.copyOf(childShards);
36     }
37
38     @VisibleForTesting
39     Map<PathArgument, WriteableModificationNode> getChildren() {
40         return children;
41     }
42
43     @VisibleForTesting
44     Map<DOMDataTreeIdentifier, ForeignShardModificationContext> getChildShards() {
45         return childShards;
46     }
47
48     DistributedShardModification createModification(final ClientTransaction transaction) {
49         return new DistributedShardModification(
50                 new DistributedShardModificationContext(transaction, root), children, childShards);
51     }
52 }