protected boolean isWrapped(Object obj) { return AutoBeanUtils.getAutoBean(obj) != null; }
public boolean isChanged() { /* * NB: Don't use the presence of ephemeral objects for this test. * * Diff the objects until one is found to be different. It's not just a * simple flag-check because of the possibility of "unmaking" a change, per * the JavaDoc. * * TODO: try to get rid of the 'diffing' flag and optimize the diffing of * objects: http://code.google.com/p/google-web-toolkit/issues/detail?id=7379 */ assert !state.diffing; state.diffing = true; try { for (AutoBean<? extends BaseProxy> bean : state.editedProxies.values()) { AutoBean<?> previous = bean.getTag(Constants.PARENT_OBJECT); if (previous == null) { // Compare to empty object Class<?> proxyClass = stableId(bean).getProxyClass(); previous = getAutoBeanFactory().create(proxyClass); } if (!AutoBeanUtils.diff(previous, bean).isEmpty()) { return true; } } return false; } finally { state.diffing = false; } }
/** * ValueProxies are equal if they are from the same RequestContext and all of * their properties are equal. */ public static boolean equals(AutoBean<? extends ValueProxy> bean, Object o) { if (!(o instanceof ValueProxy)) { return false; } AutoBean<ValueProxy> other = AutoBeanUtils.getAutoBean((ValueProxy) o); if (other == null) { // Unexpected, could be an user-provided implementation? return false; } if (!stableId(bean).getProxyClass().equals(stableId(other).getProxyClass())) { // Compare AppleProxies to AppleProxies return false; } // Compare the entire object graph return AutoBeanUtils.deepEquals(bean, other); }
return sameOrEquals((Collection<?>) value, (Collection<?>) otherValue, pending, null); return sameOrEquals((Map<?, ?>) value, (Map<?, ?>) otherValue, pending); return sameOrEquals((Splittable) value, (Splittable) otherValue, pending); AutoBean<?> maybeValue = AutoBeanUtils.getAutoBean(value); AutoBean<?> maybeOther = AutoBeanUtils.getAutoBean(otherValue); if (maybeValue != null && maybeOther != null) { value = maybeValue; return sameOrEquals((AutoBean<?>) value, (AutoBean<?>) otherValue, pending);
Map<String, Object> beanProperties = AutoBeanUtils.getAllProperties(value); Map<String, Object> otherProperties = AutoBeanUtils.getAllProperties(otherValue); for (Map.Entry<String, Object> entry : beanProperties.entrySet()) { Object property = entry.getValue(); Object otherProperty = otherProperties.get(entry.getKey()); if (!sameOrEquals(property, otherProperty, pending)) { pending.put(key, Comparison.FALSE); return false;
useDelta ? AutoBeanUtils.diff(parent, proxyBean) : AutoBeanUtils .getAllProperties(proxyBean); } else if (isValueType(stableId.getProxyClass())) { diff = AutoBeanUtils.getAllProperties(proxyBean);
Map<String, Object> diff = AutoBeanUtils.diff( AutoBeanUtils.getAutoBean(editedEntity), AutoBeanUtils.getAutoBean(updatedEntity) );
/** * Hashcode depends on property values. */ public static int hashCode(AutoBean<? extends ValueProxy> bean) { return AutoBeanUtils.getAllProperties(bean).hashCode(); } }
/** * Compare two graphs of AutoBeans based on values. * <p> * <ul> * <li>AutoBeans are compared based on type and property values</li> * <li>Lists are compared with element-order equality</li> * <li>Sets and all other Collection types are compare with bag equality</li> * <li>Maps are compared as a lists of keys-value pairs</li> * <li>{@link Splittable Splittables} are compared by value</li> * </ul> * <p> * This will work for both simple and wrapper AutoBeans. * <p> * This method may crawl the entire object graph reachable from the input * parameters and may be arbitrarily expensive to compute. * * @param a an {@link AutoBean} * @param b an {@link AutoBean} * @return {@code false} if any values in the graph reachable through * <code>a</code> are different from those reachable from * <code>b</code> */ public static boolean deepEquals(AutoBean<?> a, AutoBean<?> b) { return sameOrEquals(a, b, new HashMap<PendingComparison, Comparison>()); }
return sameOrEquals((Collection<?>) value, (Collection<?>) otherValue, pending, null); return sameOrEquals((Map<?, ?>) value, (Map<?, ?>) otherValue, pending); return sameOrEquals((Splittable) value, (Splittable) otherValue, pending); AutoBean<?> maybeValue = AutoBeanUtils.getAutoBean(value); AutoBean<?> maybeOther = AutoBeanUtils.getAutoBean(otherValue); if (maybeValue != null && maybeOther != null) { value = maybeValue; return sameOrEquals((AutoBean<?>) value, (AutoBean<?>) otherValue, pending);
useDelta ? AutoBeanUtils.diff(parent, proxyBean) : AutoBeanUtils .getAllProperties(proxyBean); } else if (isValueType(stableId.getProxyClass())) { diff = AutoBeanUtils.getAllProperties(proxyBean);
return Collections.emptyMap(); final Map<String, Object> toReturn = getAllProperties(b);
/** * Compare two Maps by size, and key-value pairs. */ private static boolean sameOrEquals(Map<?, ?> map, Map<?, ?> otherMap, Map<PendingComparison, Comparison> pending) { if (map.size() != otherMap.size()) { return false; } Map<Object, Object> pairs = new IdentityHashMap<Object, Object>(); if (!sameOrEquals(map.keySet(), otherMap.keySet(), pending, pairs)) { return false; } for (Map.Entry<?, ?> entry : map.entrySet()) { Object otherValue = otherMap.get(pairs.get(entry.getKey())); if (!sameOrEquals(entry.getValue(), otherValue, pending)) { return false; } } return true; }
Map<String, Object> beanProperties = AutoBeanUtils.getAllProperties(value); Map<String, Object> otherProperties = AutoBeanUtils.getAllProperties(otherValue); for (Map.Entry<String, Object> entry : beanProperties.entrySet()) { Object property = entry.getValue(); Object otherProperty = otherProperties.get(entry.getKey()); if (!sameOrEquals(property, otherProperty, pending)) { pending.put(key, Comparison.FALSE); return false;
public void encode(EncodeState state, Object value) { if (value == null) { state.sb.append("null"); return; } doEncode(state, AutoBeanUtils.getAutoBean(value)); }
/** * ValueProxies are equal if they are from the same RequestContext and all of * their properties are equal. */ public static boolean equals(AutoBean<? extends ValueProxy> bean, Object o) { if (!(o instanceof ValueProxy)) { return false; } AutoBean<ValueProxy> other = AutoBeanUtils.getAutoBean((ValueProxy) o); if (other == null) { // Unexpected, could be an user-provided implementation? return false; } if (!stableId(bean).getProxyClass().equals(stableId(other).getProxyClass())) { // Compare AppleProxies to AppleProxies return false; } // Compare the entire object graph return AutoBeanUtils.deepEquals(bean, other); }
return sameOrEquals((Collection<?>) value, (Collection<?>) otherValue, pending, null); return sameOrEquals((Map<?, ?>) value, (Map<?, ?>) otherValue, pending); return sameOrEquals((Splittable) value, (Splittable) otherValue, pending); AutoBean<?> maybeValue = AutoBeanUtils.getAutoBean(value); AutoBean<?> maybeOther = AutoBeanUtils.getAutoBean(otherValue); if (maybeValue != null && maybeOther != null) { value = maybeValue; return sameOrEquals((AutoBean<?>) value, (AutoBean<?>) otherValue, pending);
useDelta ? AutoBeanUtils.diff(parent, proxyBean) : AutoBeanUtils .getAllProperties(proxyBean); } else if (isValueType(stableId.getProxyClass())) { diff = AutoBeanUtils.getAllProperties(proxyBean);
/** * Hashcode depends on property values. */ public static int hashCode(AutoBean<? extends ValueProxy> bean) { return AutoBeanUtils.getAllProperties(bean).hashCode(); } }
Object element = it.next(); Object otherElement = otherIt.next(); if (!sameOrEquals(element, otherElement, pending)) { return false; for (Iterator<Object> otherIt = otherValues.iterator(); otherIt.hasNext();) { Object otherValue = otherIt.next(); if (sameOrEquals(value, otherValue, pending)) { if (pairs != null) { pairs.put(value, otherValue);