static void set(EncodeState state, Splittable data, int index, Coder coder, Object value) { data.setReified(String.valueOf(index), value); if (value == null) { Splittable.NULL.assign(data, index); return; } Splittable backing = coder.extractSplittable(state, value); if (backing == null) { /* * External data type, such as an ArrayList or a concrete implementation * of a setter's interface type. This means that a slow serialization pass * is necessary. */ data.setReified(AbstractAutoBean.UNSPLITTABLE_VALUES_KEY, true); } else { backing.assign(data, index); } }
public void clear() { for (String key : data.getPropertyKeys()) { Splittable.NULL.assign(data, key); reified.setReified(key, null); } }
public V put(K key, V value) { V toReturn = get(key); String encodedKey = encodedKey(key); reified.setReified(encodedKey, value); Splittable encodedValue = valueCoder.extractSplittable(state, value); if (encodedValue == null) { // External datastructure reified.setReified(AbstractAutoBean.UNSPLITTABLE_VALUES_KEY, true); } else { encodedValue.assign(data, encodedKey); } return toReturn; }
static <Q> Q reify(EncodeState state, Splittable data, int index, Coder coder) { if (data.isNull(index)) { return null; } @SuppressWarnings("unchecked") Q toReturn = (Q) coder.decode(state, data.get(index)); data.setReified(String.valueOf(index), toReturn); 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; }
public V remove(Object key) { V toReturn = get(key); String encodedKey = encodedKey(key); reified.setReified(encodedKey, null); Splittable.NULL.assign(data, encodedKey); return toReturn; }
@Override public E remove(int index) { E toReturn = get(index); // XXX This is terrible, use Array.splice int newSize = data.size() - 1; for (int i = index; i < newSize; i++) { data.get(i + 1).assign(data, i); // reified value for index 'i' may needs to be updated if (data.isReified(String.valueOf(i + 1))) { data.setReified(String.valueOf(i), data.getReified(String.valueOf(i + 1))); } else if (data.isReified(String.valueOf(i))) { // Remove outdated value. Will be regenerated if needed. data.removeReified(String.valueOf(i)); } } // clean-up last entry as one element has been removed data.removeReified(String.valueOf(newSize)); data.setSize(newSize); return toReturn; }
protected void setProperty(String propertyName, Object value) { checkWrapped(); checkFrozen(); data.setReified(propertyName, value); if (value == null) { Splittable.NULL.assign(data, propertyName); return; } Coder coder = AutoBeanCodexImpl.doCoderFor(this, propertyName); Splittable backing = coder.extractSplittable(EncodeState.forDecode(factory), value); if (backing == null) { /* * External data type, such as an ArrayList or a concrete implementation * of a setter's interface type. This means that a slow serialization pass * is necessary. */ data.setReified(UNSPLITTABLE_VALUES_KEY, true); } else { backing.assign(data, propertyName); } }
/** * Native getters and setters for primitive properties are generated for each * type to ensure inlining. */ protected <Q> Q getOrReify(String propertyName) { checkWrapped(); if (data.isReified(propertyName)) { @SuppressWarnings("unchecked") Q temp = (Q) data.getReified(propertyName); return temp; } if (data.isNull(propertyName)) { return null; } data.setReified(propertyName, null); Coder coder = AutoBeanCodexImpl.doCoderFor(this, propertyName); @SuppressWarnings("unchecked") Q toReturn = (Q) coder.decode(EncodeState.forDecode(factory), data.get(propertyName)); data.setReified(propertyName, toReturn); return toReturn; }
private V getRaw(String encodedKey) { if (reified.isReified(encodedKey)) { @SuppressWarnings("unchecked") V toReturn = (V) reified.getReified(encodedKey); return toReturn; } // Both undefined or an explicit null should return null here if (data.isNull(encodedKey)) { return null; } Splittable value = data.get(encodedKey); @SuppressWarnings("unchecked") V toReturn = (V) valueCoder.decode(state, value); reified.setReified(encodedKey, toReturn); return toReturn; } }
public void clear() { for (String key : data.getPropertyKeys()) { Splittable.NULL.assign(data, key); reified.setReified(key, null); } }
public void clear() { for (String key : data.getPropertyKeys()) { Splittable.NULL.assign(data, key); reified.setReified(key, null); } }
public void clear() { for (String key : data.getPropertyKeys()) { Splittable.NULL.assign(data, key); reified.setReified(key, null); } }
public V put(K key, V value) { V toReturn = get(key); String encodedKey = encodedKey(key); reified.setReified(encodedKey, value); Splittable encodedValue = valueCoder.extractSplittable(state, value); if (encodedValue == null) { // External datastructure reified.setReified(AbstractAutoBean.UNSPLITTABLE_VALUES_KEY, true); } else { encodedValue.assign(data, encodedKey); } return toReturn; }
static <Q> Q reify(EncodeState state, Splittable data, int index, Coder coder) { if (data.isNull(index)) { return null; } @SuppressWarnings("unchecked") Q toReturn = (Q) coder.decode(state, data.get(index)); data.setReified(String.valueOf(index), toReturn); return toReturn; }
static <Q> Q reify(EncodeState state, Splittable data, int index, Coder coder) { if (data.isNull(index)) { return null; } @SuppressWarnings("unchecked") Q toReturn = (Q) coder.decode(state, data.get(index)); data.setReified(String.valueOf(index), toReturn); return toReturn; }
static <Q> Q reify(EncodeState state, Splittable data, int index, Coder coder) { if (data.isNull(index)) { return null; } @SuppressWarnings("unchecked") Q toReturn = (Q) coder.decode(state, data.get(index)); data.setReified(String.valueOf(index), toReturn); return toReturn; }
public V remove(Object key) { V toReturn = get(key); String encodedKey = encodedKey(key); reified.setReified(encodedKey, null); Splittable.NULL.assign(data, encodedKey); return toReturn; }
public V remove(Object key) { V toReturn = get(key); String encodedKey = encodedKey(key); reified.setReified(encodedKey, null); Splittable.NULL.assign(data, encodedKey); return toReturn; }
public V remove(Object key) { V toReturn = get(key); String encodedKey = encodedKey(key); reified.setReified(encodedKey, null); Splittable.NULL.assign(data, encodedKey); return toReturn; }