@Override public Object createExternal(Class<?> targetClass, ObjectInput input) throws IOException, ClassNotFoundException { return externalizer.readObject(input); } }
public static <K, V, TYPED_MAP extends Map<K, V>> TYPED_MAP readMap(ObjectInput input, Externalizer<K> keyExternalizer, Externalizer<V> valueExternalizer, MarshallUtil.MapBuilder<K, V, TYPED_MAP> mapBuilder) throws IOException, ClassNotFoundException { byte b = input.readByte(); if (b == 0) { return null; } else { int size = input.readInt(); TYPED_MAP map = mapBuilder.build(size); for (int i=0 ; i<size ; i++) { K key = keyExternalizer.readObject(input); V value = valueExternalizer.readObject(input); map.put(key, value); } return map; } }
public static <E, T extends Collection<E>> T readCollection(ObjectInput input, Externalizer<E> valueExternalizer, MarshallUtil.CollectionBuilder<E, T> colBuilder) throws ClassNotFoundException, IOException { byte b = input.readByte(); if (b == 0) { return null; } else { int size = input.readInt(); T col = colBuilder.build(size); for (int i=0 ; i<size ; i++) { E value = valueExternalizer.readObject(input); col.add(value); } return col; } }