Class AutoBeanUtils
- java.lang.Object
-
- com.google.web.bindery.autobean.shared.AutoBeanUtils
-
public final class AutoBeanUtils extends java.lang.Object
Utility methods for working with AutoBeans.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static boolean
deepEquals(AutoBean<?> a, AutoBean<?> b)
Compare two graphs of AutoBeans based on values.static java.util.Map<java.lang.String,java.lang.Object>
diff(AutoBean<?> a, AutoBean<?> b)
Returns a map of properties that differ (viaObject.equals(Object)
) between two AutoBeans.static java.util.Map<java.lang.String,java.lang.Object>
getAllProperties(AutoBean<?> bean)
Returns a map that is a copy of the properties contained in an AutoBean.static <T,U extends T>
AutoBean<T>getAutoBean(U delegate)
Return the single AutoBean wrapper that is observing the delegate object ornull
if the parameter isnull
or not wrapped by an AutoBean.(package private) static boolean
sameOrEquals(java.lang.Object value, java.lang.Object otherValue, java.util.Map<com.google.web.bindery.autobean.shared.AutoBeanUtils.PendingComparison,com.google.web.bindery.autobean.shared.AutoBeanUtils.Comparison> pending)
Compare two AutoBeans, this method has the type fan-out.
-
-
-
Method Detail
-
deepEquals
public static boolean deepEquals(AutoBean<?> a, AutoBean<?> b)
Compare two graphs of AutoBeans based on values.- AutoBeans are compared based on type and property values
- Lists are compared with element-order equality
- Sets and all other Collection types are compare with bag equality
- Maps are compared as a lists of keys-value pairs
Splittables
are compared by value
This will work for both simple and wrapper AutoBeans.
This method may crawl the entire object graph reachable from the input parameters and may be arbitrarily expensive to compute.
-
diff
public static java.util.Map<java.lang.String,java.lang.Object> diff(AutoBean<?> a, AutoBean<?> b)
Returns a map of properties that differ (viaObject.equals(Object)
) between two AutoBeans. The keys are property names and the values are the value of the property inb
. Properties present ina
but missing inb
will be represented bynull
values. This implementation will compare AutoBeans of different parameterizations, although the diff produced is likely meaningless.This will work for both simple and wrapper AutoBeans.
-
getAllProperties
public static java.util.Map<java.lang.String,java.lang.Object> getAllProperties(AutoBean<?> bean)
Returns a map that is a copy of the properties contained in an AutoBean. The returned map is mutable, but editing it will not have any effect on the bean that produced it.- Parameters:
bean
- anAutoBean
- Returns:
- a
Map
of the bean's properties
-
getAutoBean
public static <T,U extends T> AutoBean<T> getAutoBean(U delegate)
Return the single AutoBean wrapper that is observing the delegate object ornull
if the parameter isnull
or not wrapped by an AutoBean.- Parameters:
delegate
- a delegate object, ornull
- Returns:
- the
AutoBean
wrapper for the delegate, ornull
-
sameOrEquals
static boolean sameOrEquals(java.lang.Object value, java.lang.Object otherValue, java.util.Map<com.google.web.bindery.autobean.shared.AutoBeanUtils.PendingComparison,com.google.web.bindery.autobean.shared.AutoBeanUtils.Comparison> pending)
Compare two AutoBeans, this method has the type fan-out.
-
-