List of usage examples for com.google.gwt.core.client.impl WeakMapping setWeak
public static void setWeak(Object instance, String key, Object value)
From source file:com.google.web.bindery.autobean.shared.impl.AbstractAutoBean.java
License:Apache License
/** * Constructor that wraps an existing object. The parameters on this method * are reversed to avoid conflicting with the other two-arg constructor for * {@code AutoBean<Splittable>} instances. *///from w w w . ja v a 2s . co m protected AbstractAutoBean(T wrapped, AutoBeanFactory factory) { this.factory = factory; usingSimplePeer = false; data = null; this.wrapped = wrapped; // Used by AutoBeanUtils WeakMapping.setWeak(wrapped, AutoBean.class.getName(), this); }
From source file:com.google.web.bindery.autobean.vm.impl.JsonSplittable.java
License:Apache License
private synchronized JsonSplittable makeSplittable(Object object) { if (JSONObject.NULL.equals(object)) { return null; }//from w w w. jav a 2s . c om /* * Maintain a 1:1 mapping between object instances and JsonSplittables. * Doing this with a WeakHashMap doesn't work on Android, since its org.json * arrays appear to have value-based equality. */ JsonSplittable seen = (JsonSplittable) WeakMapping.get(object, JsonSplittable.class.getName()); if (seen == null) { if (object instanceof JSONObject) { seen = new JsonSplittable((JSONObject) object); WeakMapping.setWeak(object, JsonSplittable.class.getName(), seen); } else if (object instanceof JSONArray) { seen = new JsonSplittable((JSONArray) object); WeakMapping.setWeak(object, JsonSplittable.class.getName(), seen); } else if (object instanceof String) { seen = new JsonSplittable(object.toString()); } else if (object instanceof Number) { seen = new JsonSplittable(((Number) object).doubleValue()); } else if (object instanceof Boolean) { seen = new JsonSplittable((Boolean) object); } else { throw new RuntimeException("Unhandled type " + object.getClass()); } } return seen; }
From source file:com.google.web.bindery.autobean.vm.impl.ProxyAutoBean.java
License:Apache License
private T createShim() { T toReturn = ProxyAutoBean.makeProxy(beanType, new ShimHandler<T>(this, getWrapped())); WeakMapping.setWeak(toReturn, AutoBean.class.getName(), this); return toReturn; }