/** * 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()); }
private Splittable nonCollectionEncode(Object obj) { if (obj instanceof Collection) { // TODO: Allow for the encoding of nested collections. See issue 5974. // Once we do this, this can turn into an assert. throw new RuntimeException( "Unable to encode request as JSON payload; Request methods must have parameters of the form List<T> or Set<T>, where T is a scalar (non-collection) type."); } Splittable value; if (obj instanceof Enum && getAutoBeanFactory() instanceof EnumMap) { value = ValueCodex.encode(((EnumMap) getAutoBeanFactory()).getToken((Enum<?>) obj)); } else if (ValueCodex.canDecode(obj.getClass())) { value = ValueCodex.encode(obj); } else { // XXX user-provided implementation of interface? value = AutoBeanCodex.encode(AutoBeanUtils.getAutoBean(obj)); } return value; } }
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; } }
/** * 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()); }
/** * 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()); }
private Splittable nonCollectionEncode(Object obj) { if (obj instanceof Collection) { // TODO: Allow for the encoding of nested collections. See issue 5974. // Once we do this, this can turn into an assert. throw new RuntimeException( "Unable to encode request as JSON payload; Request methods must have parameters of the form List<T> or Set<T>, where T is a scalar (non-collection) type."); } Splittable value; if (obj instanceof Enum && getAutoBeanFactory() instanceof EnumMap) { value = ValueCodex.encode(((EnumMap) getAutoBeanFactory()).getToken((Enum<?>) obj)); } else if (ValueCodex.canDecode(obj.getClass())) { value = ValueCodex.encode(obj); } else { // XXX user-provided implementation of interface? value = AutoBeanCodex.encode(AutoBeanUtils.getAutoBean(obj)); } return value; } }
private Splittable nonCollectionEncode(Object obj) { if (obj instanceof Collection) { // TODO: Allow for the encoding of nested collections. See issue 5974. // Once we do this, this can turn into an assert. throw new RuntimeException( "Unable to encode request as JSON payload; Request methods must have parameters of the form List<T> or Set<T>, where T is a scalar (non-collection) type."); } Splittable value; if (obj instanceof Enum && getAutoBeanFactory() instanceof EnumMap) { value = ValueCodex.encode(((EnumMap) getAutoBeanFactory()).getToken((Enum<?>) obj)); } else if (ValueCodex.canDecode(obj.getClass())) { value = ValueCodex.encode(obj); } else { // XXX user-provided implementation of interface? value = AutoBeanCodex.encode(AutoBeanUtils.getAutoBean(obj)); } return value; } }
private Splittable nonCollectionEncode(Object obj) { if (obj instanceof Collection) { // TODO: Allow for the encoding of nested collections. See issue 5974. // Once we do this, this can turn into an assert. throw new RuntimeException( "Unable to encode request as JSON payload; Request methods must have parameters of the form List<T> or Set<T>, where T is a scalar (non-collection) type."); } Splittable value; if (obj instanceof Enum && getAutoBeanFactory() instanceof EnumMap) { value = ValueCodex.encode(((EnumMap) getAutoBeanFactory()).getToken((Enum<?>) obj)); } else if (ValueCodex.canDecode(obj.getClass())) { value = ValueCodex.encode(obj); } else { // XXX user-provided implementation of interface? value = AutoBeanCodex.encode(AutoBeanUtils.getAutoBean(obj)); } return value; } }
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; } }