public final class

AutoBeanUtils

extends Object
java.lang.Object
   ↳ com.google.gwt.autobean.shared.AutoBeanUtils

Class Overview

Utility methods for working with AutoBeans.

Summary

Public Methods
static boolean deepEquals(AutoBean<?> a, AutoBean<?> b)
Compare two graphs of AutoBeans based on values.
static Map<StringObject> diff(AutoBean<?> a, AutoBean<?> b)
Returns a map of properties that differ (via equals(Object)) between two AutoBeans.
static Map<StringObject> 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 or null if the parameter is nullor not wrapped by an AutoBean.
[Expand]
Inherited Methods
From class java.lang.Object

Public Methods

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.

Parameters
a an AutoBean
b an AutoBean
Returns
  • false if any values in the graph reachable through a are different from those reachable from b

public static Map<StringObject> diff (AutoBean<?> a, AutoBean<?> b)

Returns a map of properties that differ (via equals(Object)) between two AutoBeans. The keys are property names and the values are the value of the property in b. Properties present in a but missing in b will be represented by null 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.

Parameters
a an AutoBean
b an AutoBean
Returns
  • a Map of differing properties

public static Map<StringObject> 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 an AutoBean
Returns
  • a Map of the bean's properties

public static AutoBean<T> getAutoBean (U delegate)

Return the single AutoBean wrapper that is observing the delegate object or null if the parameter is nullor not wrapped by an AutoBean.

Parameters
delegate a delegate object, or null
Returns
  • the AutoBean wrapper for the delegate, or null