Do not leak DataTree from backend actor
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / messages / LocalPrimaryShardFound.java
1 /*
2  * Copyright (c) 2015 Brocade Communications 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.datastore.messages;
9
10 import static java.util.Objects.requireNonNull;
11
12 import org.apache.commons.lang3.ObjectUtils;
13 import org.eclipse.jdt.annotation.NonNull;
14 import org.opendaylight.yangtools.yang.data.api.schema.tree.ReadOnlyDataTree;
15
16 /**
17  * Local message sent in reply to FindPrimaryShard to indicate the primary shard is local to the caller.
18  *
19  * @author Thomas Pantelis
20  */
21 public class LocalPrimaryShardFound {
22
23     private final String primaryPath;
24     private final ReadOnlyDataTree localShardDataTree;
25
26     public LocalPrimaryShardFound(@NonNull  String primaryPath, @NonNull ReadOnlyDataTree localShardDataTree) {
27         this.primaryPath = requireNonNull(primaryPath);
28         this.localShardDataTree = requireNonNull(localShardDataTree);
29     }
30
31     public @NonNull String getPrimaryPath() {
32         return primaryPath;
33     }
34
35     public @NonNull ReadOnlyDataTree getLocalShardDataTree() {
36         return localShardDataTree;
37     }
38
39     @Override
40     public String toString() {
41         return "LocalPrimaryShardFound [primaryPath=" + primaryPath
42                 + ", localShardDataTree=" + ObjectUtils.identityToString(localShardDataTree) + "]";
43     }
44 }