All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.umlg.runtime.adaptor.TransactionIdentifier Maven / Gradle / Ivy

There is a newer version: 2.0.15
Show newest version
package org.umlg.runtime.adaptor;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;

import java.util.UUID;

/**
 * Date: 2013/02/01
 * Time: 5:52 PM
 */
public final class TransactionIdentifier {

    private String uid;

    public TransactionIdentifier(String uid) {
        this.uid = uid;
    }

    public TransactionIdentifier() {
        uid = UUID.randomUUID().toString();
    }

    @Override
    public int hashCode() {
        return new HashCodeBuilder(17, 37).append(this.uid).toHashCode();
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (obj == this) {
            return true;
        }
        if (obj.getClass() != getClass()) {
            return false;
        }
        TransactionIdentifier rhs = (TransactionIdentifier) obj;
        return new EqualsBuilder().append(this.uid, rhs.uid).isEquals();
    }

    @Override
    public String toString() {
        return this.uid;
    }

    public String toJson() {
        return "{\"transactionIdentifier\": \"" + this.uid + "\"}";
    }


}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy