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

io.ebeaninternal.server.core.DiffHelp Maven / Gradle / Ivy

There is a newer version: 15.8.0
Show newest version
package io.ebeaninternal.server.core;

import io.ebean.ValuePair;
import io.ebean.bean.EntityBean;
import io.ebeaninternal.server.deploy.BeanDescriptor;

import java.util.Map;

/**
 * Helper to perform a diff given two beans of the same type.
 * 

* This intentionally does not include any OneToMany or ManyToMany properties. *

*/ public final class DiffHelp { private DiffHelp() { } /** * Return a map of the differences between a and b. *

* A and B must be of the same type. B can be null, in which case the 'dirty * values' of a is returned. *

*

* This intentionally does not include as OneToMany or ManyToMany properties. *

*/ public static Map diff(Object newBean, Object oldBean, BeanDescriptor desc) { if (!(newBean instanceof EntityBean)) { throw new IllegalArgumentException("First bean expected to be an enhanced EntityBean? bean:" + newBean); } if (oldBean != null) { if (!(oldBean instanceof EntityBean)) { throw new IllegalArgumentException("Second bean expected to be an enhanced EntityBean? bean:" + oldBean); } if (!newBean.getClass().isAssignableFrom(oldBean.getClass())) { throw new IllegalArgumentException("Second bean not assignable to the first bean?"); } } if (oldBean == null) { return ((EntityBean) newBean)._ebean_getIntercept().dirtyValues(); } return desc.diff((EntityBean) newBean, (EntityBean) oldBean); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy