@SuppressWarnings("unchecked") @Override protected void updateFromSnapshot(ObjectInput in, PersistentCollectionSnapshot snapshot) { if (snapshot.isInitialized()) init(new HashMap<K, V>((Map<K, V>)snapshot.getElementsAsMap()), snapshot.getDetachedState(), snapshot.isDirty()); else init(null, snapshot.getDetachedState(), false); }
@SuppressWarnings("unchecked") @Override protected void updateFromSnapshot(ObjectInput in, PersistentCollectionSnapshot snapshot) { if (snapshot.isInitialized()) { Comparator<? super K> comparator = null; try { comparator = snapshot.newComparator(in); } catch (Exception e) { throw new RuntimeException("Could not create instance of comparator", e); } SortedMap<K, V> map = new TreeMap<K, V>(comparator); map.putAll((Map<K, V>)snapshot.getElementsAsMap()); init(map, snapshot.getDetachedState(), snapshot.isDirty()); } else init(null, snapshot.getDetachedState(), false); }
@SuppressWarnings("unchecked") @Override protected void updateFromSnapshot(ObjectInput in, PersistentCollectionSnapshot snapshot) { if (snapshot.isInitialized()) init(new HashMap<K, V>((Map<K, V>)snapshot.getElementsAsMap()), snapshot.getDetachedState(), snapshot.isDirty()); else init(null, snapshot.getDetachedState(), false); }
@SuppressWarnings("unchecked") @Override protected void updateFromSnapshot(ObjectInput in, PersistentCollectionSnapshot snapshot) { if (snapshot.isInitialized()) { Comparator<? super K> comparator = null; try { comparator = snapshot.newComparator(in); } catch (Exception e) { throw new RuntimeException("Could not create instance of comparator", e); } SortedMap<K, V> map = new TreeMap<K, V>(comparator); map.putAll((Map<K, V>)snapshot.getElementsAsMap()); init(map, snapshot.getDetachedState(), snapshot.isDirty()); } else init(null, snapshot.getDetachedState(), false); }
@SuppressWarnings("unchecked") @Override protected void updateFromSnapshot(ObjectInput in, PersistentCollectionSnapshot snapshot) { if (snapshot.isInitialized()) { Comparator<? super K> comparator = null; try { comparator = snapshot.newComparator(in); } catch (Exception e) { throw new RuntimeException("Could not create instance of comparator", e); } SortedMap<K, V> map = new TreeMap<K, V>(comparator); map.putAll((Map<K, V>)snapshot.getElementsAsMap()); init(map, snapshot.getDetachedState(), snapshot.isDirty()); } else init(null, snapshot.getDetachedState(), false); }
@SuppressWarnings("unchecked") @Override protected void updateFromSnapshot(ObjectInput in, PersistentCollectionSnapshot snapshot) { if (snapshot.isInitialized()) init(new HashMap<K, V>((Map<K, V>)snapshot.getElementsAsMap()), snapshot.getDetachedState(), snapshot.isDirty()); else init(null, snapshot.getDetachedState(), false); }
@SuppressWarnings("unchecked") public void decode(ExtendedObjectInput in, Object v) throws IOException, ClassNotFoundException, IllegalAccessException { PersistentCollection collection = (PersistentCollection)v; if (collection.wasInitialized()) { boolean sorted = (collection instanceof SortedSet || collection instanceof SortedMap); PersistentCollectionSnapshot snapshot = new JMFPersistentCollectionSnapshot(sorted, null); snapshot.readCoreData(in); if (collection instanceof Map) ((Map<Object, Object>)collection).putAll(snapshot.getElementsAsMap()); else ((Collection<Object>)collection).addAll(snapshot.getElementsAsCollection()); if (snapshot.isDirty()) collection.dirty(); else collection.clearDirty(); } } }