2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
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
9 package org.opendaylight.controller.cluster.datastore.identifiers;
11 import com.google.common.base.Preconditions;
13 public class ShardIdentifier {
14 private final String shardName;
15 private final String memberName;
16 private final String type;
19 public ShardIdentifier(String shardName, String memberName, String type) {
21 Preconditions.checkNotNull(shardName, "shardName should not be null");
22 Preconditions.checkNotNull(memberName, "memberName should not be null");
23 Preconditions.checkNotNull(type, "type should not be null");
25 this.shardName = shardName;
26 this.memberName = memberName;
31 public boolean equals(Object o) {
35 if (o == null || getClass() != o.getClass()) {
39 ShardIdentifier that = (ShardIdentifier) o;
41 if (!memberName.equals(that.memberName)) {
44 if (!shardName.equals(that.shardName)) {
47 if (!type.equals(that.type)) {
55 public int hashCode() {
56 int result = shardName.hashCode();
57 result = 31 * result + memberName.hashCode();
58 result = 31 * result + type.hashCode();
62 @Override public String toString() {
63 StringBuilder builder = new StringBuilder();
64 builder.append(memberName).append("-shard-").append(shardName).append("-").append(type);
65 return builder.toString();
68 public static Builder builder(){
72 public static class Builder {
73 private String shardName;
74 private String memberName;
77 public ShardIdentifier build(){
78 return new ShardIdentifier(shardName, memberName, type);
81 public Builder shardName(String shardName){
82 this.shardName = shardName;
86 public Builder memberName(String memberName){
87 this.memberName = memberName;
91 public Builder type(String type){