/* * Copyright 2014 NAVER Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.navercorp.pinpoint.common.util; /** * @author emeroad */ public class TransactionId { private String agentId; private long agentStartTime; private long transactionSequence; public TransactionId(String agentId, long agentStartTime, long transactionSequence) { if (agentId == null) { throw new NullPointerException("agentId must not be null"); } this.agentId = agentId; this.agentStartTime = agentStartTime; this.transactionSequence = transactionSequence; } public TransactionId(long agentStartTime, long transactionSequence) { this.agentStartTime = agentStartTime; this.transactionSequence = transactionSequence; } public String getAgentId() { return agentId; } public long getAgentStartTime() { return agentStartTime; } public long getTransactionSequence() { return transactionSequence; } @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; TransactionId that = (TransactionId) o; if (agentStartTime != that.agentStartTime) return false; if (transactionSequence != that.transactionSequence) return false; if (!agentId.equals(that.agentId)) return false; return true; } @Override public int hashCode() { int result = agentId.hashCode(); result = 31 * result + (int) (agentStartTime ^ (agentStartTime >>> 32)); result = 31 * result + (int) (transactionSequence ^ (transactionSequence >>> 32)); return result; } @Override public String toString() { final StringBuilder sb = new StringBuilder("TransactionId{"); sb.append("agentId='").append(agentId).append('\''); sb.append(", agentStartTime=").append(agentStartTime); sb.append(", transactionSequence=").append(transactionSequence); sb.append('}'); return sb.toString(); } }