BUG-5280: use MemberName instead of String
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / config / ModuleShardConfiguration.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.config;
9
10 import com.google.common.base.Preconditions;
11 import java.net.URI;
12 import java.util.Collection;
13 import javax.annotation.Nonnull;
14 import javax.annotation.Nullable;
15 import org.opendaylight.controller.cluster.access.concepts.MemberName;
16
17 /**
18  * Encapsulates information for adding a new module shard configuration.
19  *
20  * @author Thomas Pantelis
21  */
22 public class ModuleShardConfiguration {
23     private final URI namespace;
24     private final String moduleName;
25     private final String shardName;
26     private final String shardStrategyName;
27     private final Collection<MemberName> shardMemberNames;
28
29     /**
30      * Constructs a new instance.
31      *
32      * @param namespace the name space of the module.
33      * @param moduleName the name of the module.
34      * @param shardName the name of the shard.
35      * @param shardStrategyName the name of the sharding strategy (eg "module"). If null the default strategy
36      *                          is used.
37      * @param shardMemberNames the names of the shard's member replicas.
38      */
39     public ModuleShardConfiguration(@Nonnull URI namespace, @Nonnull String moduleName, @Nonnull String shardName,
40             @Nullable String shardStrategyName, @Nonnull Collection<MemberName> shardMemberNames) {
41         this.namespace = Preconditions.checkNotNull(namespace, "nameSpace should not be null");
42         this.moduleName = Preconditions.checkNotNull(moduleName, "moduleName should not be null");
43         this.shardName = Preconditions.checkNotNull(shardName, "shardName should not be null");
44         this.shardStrategyName = shardStrategyName;
45         this.shardMemberNames = Preconditions.checkNotNull(shardMemberNames, "shardMemberNames");
46     }
47
48     public URI getNamespace() {
49         return namespace;
50     }
51
52     public String getModuleName() {
53         return moduleName;
54     }
55
56     public String getShardName() {
57         return shardName;
58     }
59
60     public String getShardStrategyName() {
61         return shardStrategyName;
62     }
63
64     public Collection<MemberName> getShardMemberNames() {
65         return shardMemberNames;
66     }
67
68     @Override
69     public String toString() {
70         return "ModuleShardConfiguration [namespace=" + namespace + ", moduleName=" + moduleName + ", shardName="
71                 + shardName + ", shardMemberNames=" + shardMemberNames + ", shardStrategyName=" + shardStrategyName
72                 + "]";
73     }
74 }