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 TransactionIdentifier {
14 private final String memberName;
15 private final long counter;
18 public TransactionIdentifier(String memberName, long counter) {
19 this.memberName = Preconditions.checkNotNull(memberName, "memberName should not be null");
20 this.counter = counter;
23 public static Builder builder(){
28 public boolean equals(Object o) {
32 if (o == null || getClass() != o.getClass()) {
36 TransactionIdentifier that = (TransactionIdentifier) o;
38 if (counter != that.counter) {
41 if (!memberName.equals(that.memberName)) {
49 public int hashCode() {
50 int result = memberName.hashCode();
51 result = 31 * result + (int) (counter ^ (counter >>> 32));
55 @Override public String toString() {
56 final StringBuilder sb =
58 sb.append(memberName).append("-txn-").append(counter);
62 public static class Builder {
63 private String memberName;
66 public TransactionIdentifier build(){
67 return new TransactionIdentifier(memberName, counter);
70 public Builder memberName(String memberName){
71 this.memberName = memberName;
75 public Builder counter(long counter){
76 this.counter = counter;