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

org.javers.core.diff.changetype.Atomic Maven / Gradle / Ivy

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

import org.javers.common.collections.Primitives;

import java.io.Serializable;
import java.util.Objects;

/**
 * Immutable wrapper for client's Primitives, Values and Id's
 * 

* * TODO refine dehydrate approach * Value needs to be dehydrated before persisting. Dehydration is simply serialization to JSON. * * @author bartosz walacik */ public class Atomic implements Serializable { private final Object value; public Atomic(Object value) { this.value = value; } public boolean isNull() { return value == null; } /** * @return true if value is not null and is primitive, box or String */ public boolean isJsonBasicType() { if(isNull()) { return false; } return Primitives.isJsonBasicType(value); } /** * original Value */ public Object unwrap() { return value; } @Override public String toString() { return "value:"+value; } @Override public boolean equals(Object obj) { if (!(obj instanceof Atomic)) { return false; } Atomic other = (Atomic)obj; return Objects.equals(value, other.value); } @Override public int hashCode() { if (value == null) { return 0; } return value.hashCode(); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy