package com.jstarcraft.core.storage.berkeley;

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

/**
 * Berkeley标识
 * 
 * @author Birdy
 *
 */
class BerkeleyIdentification {

    private final Class<?> clazz;

    private final Object id;

    private final int hash;

    BerkeleyIdentification(Class<?> clazz, Object id) {
        this.clazz = clazz;
        this.id = id;
        HashCodeBuilder hash = new HashCodeBuilder();
        hash.append(clazz);
        hash.append(id);
        this.hash = hash.toHashCode();
    }

    @Override
    public boolean equals(Object object) {
        if (this == object)
            return true;
        if (object == null)
            return false;
        if (getClass() != object.getClass())
            return false;
        BerkeleyIdentification that = (BerkeleyIdentification) object;
        EqualsBuilder equal = new EqualsBuilder();
        equal.append(this.clazz, that.clazz);
        equal.append(this.id, that.id);
        return equal.isEquals();
    }

    @Override
    public int hashCode() {
        return hash;
    }

}

{'avg_line_length': 23.9, 'max_line_length': 71, 'alphanum_fraction': 0.5899581589958159, 'licenses': ['Apache-2.0'], 'repository_name': 'HongZhaoHua/jstarcraft-core', 'path': 'jstarcraft-core-storage/src/main/java/com/jstarcraft/core/storage/berkeley/BerkeleyIdentification.java', 'size': 1199, 'lang': 'Java'}