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

org.vertexium.inmemory.mutations.Mutation Maven / Gradle / Ivy

There is a newer version: 4.10.0
Show newest version
package org.vertexium.inmemory.mutations;

import org.vertexium.Visibility;

import java.io.Serializable;

public abstract class Mutation implements Comparable, Serializable {
    private final long timestamp;
    private final Visibility visibility;

    protected Mutation(long timestamp, Visibility visibility) {
        this.timestamp = timestamp;
        this.visibility = visibility;
    }

    public long getTimestamp() {
        return timestamp;
    }

    public Visibility getVisibility() {
        return visibility;
    }

    @Override
    public int compareTo(Mutation o) {
        int result = Long.compare(getTimestamp(), o.getTimestamp());
        if (result == 0) {
            result = getClass().getName().compareTo(o.getClass().getName());
            if (result == 0) {
                result = Integer.compare(System.identityHashCode(this), System.identityHashCode(o));
            }
        }
        return result;
    }

    @Override
    public String toString() {
        return this.getClass().getName() + "{" +
                "timestamp=" + timestamp +
                ", visibility=" + visibility +
                '}';
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy