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 ShardTransactionIdentifier {
14 private final String remoteTransactionId;
15 private final String stringRepresentation;
17 public ShardTransactionIdentifier(String remoteTransactionId) {
18 this.remoteTransactionId = Preconditions.checkNotNull(remoteTransactionId,
19 "remoteTransactionId should not be null");
21 stringRepresentation = new StringBuilder(remoteTransactionId.length() + 6).append("shard-").
22 append(remoteTransactionId).toString();
25 public String getRemoteTransactionId() {
26 return remoteTransactionId;
30 public boolean equals(Object o) {
34 if (o == null || getClass() != o.getClass()) {
38 ShardTransactionIdentifier that = (ShardTransactionIdentifier) o;
40 if (!remoteTransactionId.equals(that.remoteTransactionId)) {
48 public int hashCode() {
49 return remoteTransactionId.hashCode();
52 @Override public String toString() {
53 return stringRepresentation;