001package io.ebean.bean; 002 003/** 004 * Holds information on mutable values (like plain beans stored as json). 005 * <p> 006 * Used internally in EntityBeanIntercept for dirty detection on mutable values. 007 * Typically, mutation detection is based on a hash/checksum of json content or the 008 * original json content itself. 009 * <p> 010 * Refer to the mapping options {@code @DbJson(mutationDetection)}. 011 */ 012public interface MutableValueInfo { 013 014 /** 015 * Compares the given json returning null if deemed unchanged or returning 016 * the MutableValueNext to use if deemed dirty/changed. 017 * <p> 018 * Returning MutableValueNext allows an implementation based on hash/checksum 019 * to only perform that computation once. 020 * 021 * @return Null if deemed unchanged or the MutableValueNext if deemed changed. 022 */ 023 MutableValueNext nextDirty(String json); 024 025 /** 026 * Compares the given object to an internal value. 027 * <p> 028 * This is used to support changelog/beanState. The implementation can serialize the 029 * object into json form and compare it against the original json. 030 */ 031 boolean isEqualToObject(Object obj); 032 033 /** 034 * Creates a new instance from the internal json string. 035 * <p> 036 * This is used to provide an original/old value for change logging / persist listeners. 037 * This is only available for properties that have {@code @DbJson(keepSource=true)}. 038 */ 039 default Object get() { 040 return null; 041 } 042}