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

org.javers.core.diff.changetype.container.ElementValueChange Maven / Gradle / Ivy

There is a newer version: 7.6.1
Show newest version
package org.javers.core.diff.changetype.container;

import java.util.Objects;

import org.javers.core.diff.changetype.Atomic;

/**
 * @author pawel szymczyk
 */
public class ElementValueChange extends ContainerElementChange {

    private final Atomic leftValue;
    private final Atomic rightValue;

    public ElementValueChange(int index, Object leftValue, Object rightValue) {
        super(index);
        this.leftValue = new Atomic(leftValue);
        this.rightValue = new Atomic(rightValue);
    }

    public Object getLeftValue() {
        return leftValue.unwrap();
    }

    public Object getRightValue() {
        return rightValue.unwrap();
    }

    @Override
    public String toString() {
        return "("+ getIndex() + ").'"+getLeftValue()+"'>>'"+getRightValue()+"'";
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj instanceof ElementValueChange) {
            ElementValueChange that = (ElementValueChange) obj;
            return super.equals(that)
                    && Objects.equals(this.getLeftValue(), that.getLeftValue())
                    && Objects.equals(this.getRightValue(), that.getRightValue());
        }
        return false;
    }

    @Override
    public int hashCode() {
        return Objects.hash(super.hashCode(), getLeftValue(), getRightValue());
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy