public static <T> AutoBean<T> doDecode(EncodeState state, Class<T> clazz, Splittable data) { /* * If we decode the same Splittable twice, re-use the ProxyAutoBean to * maintain referential integrity. If we didn't do this, either facade would * update the same backing data, yet not be the same object via == * comparison. */ @SuppressWarnings("unchecked") AutoBean<T> toReturn = (AutoBean<T>) data.getReified(AutoBeanCodexImpl.class.getName()); if (toReturn != null) { return toReturn; } toReturn = state.factory.create(clazz); data.setReified(AutoBeanCodexImpl.class.getName(), toReturn); if (toReturn == null) { throw new IllegalArgumentException(clazz.getName()); } ((AbstractAutoBean<T>) toReturn).setData(data); return toReturn; }
/** * Creates a new proxy with an assigned ID. * * @param clazz The proxy type * @param id The id to be assigned to the new proxy * @param useAppendedContexts if {@code true} use the AutoBeanFactory types associated with any * contexts that have been passed into {@link #append(RequestContext)}. If {@code false}, * this method will only create proxy types reachable from the implemented RequestContext * interface. * @throws IllegalArgumentException if the requested proxy type cannot be created */ protected <T extends BaseProxy> AutoBean<T> createProxy(Class<T> clazz, SimpleProxyId<T> id, boolean useAppendedContexts) { AutoBean<T> created = null; if (useAppendedContexts) { for (AbstractRequestContext ctx : state.appendedContexts) { created = ctx.getAutoBeanFactory().create(clazz); if (created != null) { break; } } } else { created = getAutoBeanFactory().create(clazz); } if (created != null) { created.setTag(STABLE_ID, id); return created; } throw new IllegalArgumentException("Unknown proxy type " + clazz.getName()); }
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; } }
AutoBean<T> clone = toClone.getFactory().create(toClone.getType()); clone.setTag(STABLE_ID, toClone.getTag(STABLE_ID)); clone.setTag(Constants.VERSION_PROPERTY_B64, toClone.getTag(Constants.VERSION_PROPERTY_B64));
public static <T> AutoBean<T> doDecode(EncodeState state, Class<T> clazz, Splittable data) { /* * If we decode the same Splittable twice, re-use the ProxyAutoBean to * maintain referential integrity. If we didn't do this, either facade would * update the same backing data, yet not be the same object via == * comparison. */ @SuppressWarnings("unchecked") AutoBean<T> toReturn = (AutoBean<T>) data.getReified(AutoBeanCodexImpl.class.getName()); if (toReturn != null) { return toReturn; } toReturn = state.factory.create(clazz); data.setReified(AutoBeanCodexImpl.class.getName(), toReturn); if (toReturn == null) { throw new IllegalArgumentException(clazz.getName()); } ((AbstractAutoBean<T>) toReturn).setData(data); return toReturn; }
/** * Creates a new proxy with an assigned ID. * * @param clazz The proxy type * @param id The id to be assigned to the new proxy * @param useAppendedContexts if {@code true} use the AutoBeanFactory types associated with any * contexts that have been passed into {@link #append(RequestContext)}. If {@code false}, * this method will only create proxy types reachable from the implemented RequestContext * interface. * @throws IllegalArgumentException if the requested proxy type cannot be created */ protected <T extends BaseProxy> AutoBean<T> createProxy(Class<T> clazz, SimpleProxyId<T> id, boolean useAppendedContexts) { AutoBean<T> created = null; if (useAppendedContexts) { for (AbstractRequestContext ctx : state.appendedContexts) { created = ctx.getAutoBeanFactory().create(clazz); if (created != null) { break; } } } else { created = getAutoBeanFactory().create(clazz); } if (created != null) { created.setTag(STABLE_ID, id); return created; } throw new IllegalArgumentException("Unknown proxy type " + clazz.getName()); }
public static <T> AutoBean<T> doDecode(EncodeState state, Class<T> clazz, Splittable data) { /* * If we decode the same Splittable twice, re-use the ProxyAutoBean to * maintain referential integrity. If we didn't do this, either facade would * update the same backing data, yet not be the same object via == * comparison. */ @SuppressWarnings("unchecked") AutoBean<T> toReturn = (AutoBean<T>) data.getReified(AutoBeanCodexImpl.class.getName()); if (toReturn != null) { return toReturn; } toReturn = state.factory.create(clazz); data.setReified(AutoBeanCodexImpl.class.getName(), toReturn); if (toReturn == null) { throw new IllegalArgumentException(clazz.getName()); } ((AbstractAutoBean<T>) toReturn).setData(data); return toReturn; }
public static <T> AutoBean<T> doDecode(EncodeState state, Class<T> clazz, Splittable data) { /* * If we decode the same Splittable twice, re-use the ProxyAutoBean to * maintain referential integrity. If we didn't do this, either facade would * update the same backing data, yet not be the same object via == * comparison. */ @SuppressWarnings("unchecked") AutoBean<T> toReturn = (AutoBean<T>) data.getReified(AutoBeanCodexImpl.class.getName()); if (toReturn != null) { return toReturn; } toReturn = state.factory.create(clazz); data.setReified(AutoBeanCodexImpl.class.getName(), toReturn); if (toReturn == null) { throw new IllegalArgumentException(clazz.getName()); } ((AbstractAutoBean<T>) toReturn).setData(data); return toReturn; }
/** * Creates a new proxy with an assigned ID. * * @param clazz The proxy type * @param id The id to be assigned to the new proxy * @param useAppendedContexts if {@code true} use the AutoBeanFactory types associated with any * contexts that have been passed into {@link #append(RequestContext)}. If {@code false}, * this method will only create proxy types reachable from the implemented RequestContext * interface. * @throws IllegalArgumentException if the requested proxy type cannot be created */ protected <T extends BaseProxy> AutoBean<T> createProxy(Class<T> clazz, SimpleProxyId<T> id, boolean useAppendedContexts) { AutoBean<T> created = null; if (useAppendedContexts) { for (AbstractRequestContext ctx : state.appendedContexts) { created = ctx.getAutoBeanFactory().create(clazz); if (created != null) { break; } } } else { created = getAutoBeanFactory().create(clazz); } if (created != null) { created.setTag(STABLE_ID, id); return created; } throw new IllegalArgumentException("Unknown proxy type " + clazz.getName()); }
/** * Creates a new proxy with an assigned ID. * * @param clazz The proxy type * @param id The id to be assigned to the new proxy * @param useAppendedContexts if {@code true} use the AutoBeanFactory types associated with any * contexts that have been passed into {@link #append(RequestContext)}. If {@code false}, * this method will only create proxy types reachable from the implemented RequestContext * interface. * @throws IllegalArgumentException if the requested proxy type cannot be created */ protected <T extends BaseProxy> AutoBean<T> createProxy(Class<T> clazz, SimpleProxyId<T> id, boolean useAppendedContexts) { AutoBean<T> created = null; if (useAppendedContexts) { for (AbstractRequestContext ctx : state.appendedContexts) { created = ctx.getAutoBeanFactory().create(clazz); if (created != null) { break; } } } else { created = getAutoBeanFactory().create(clazz); } if (created != null) { created.setTag(STABLE_ID, id); return created; } throw new IllegalArgumentException("Unknown proxy type " + clazz.getName()); }
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; } }
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; } }
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; } }
AutoBean<T> clone = toClone.getFactory().create(toClone.getType()); clone.setTag(STABLE_ID, toClone.getTag(STABLE_ID)); clone.setTag(Constants.VERSION_PROPERTY_B64, toClone.getTag(Constants.VERSION_PROPERTY_B64));
AutoBean<T> clone = toClone.getFactory().create(toClone.getType()); clone.setTag(STABLE_ID, toClone.getTag(STABLE_ID)); clone.setTag(Constants.VERSION_PROPERTY_B64, toClone.getTag(Constants.VERSION_PROPERTY_B64));
AutoBean<T> clone = toClone.getFactory().create(toClone.getType()); clone.setTag(STABLE_ID, toClone.getTag(STABLE_ID)); clone.setTag(Constants.VERSION_PROPERTY_B64, toClone.getTag(Constants.VERSION_PROPERTY_B64));