Hi,

You may use your custom collections as is - they will be deserialized in
correct type.
If you want to implement Binarylizable with additional serialization logic,
you can use something like follows (but this approach will need intermediate
object):

   private static class CustomList<T> extends ArrayList<T> implements
Binarylizable {
        @Override public void writeBinary(BinaryWriter writer) throws
BinaryObjectException {
            writer.rawWriter().writeObjectArray(toArray());
        }

        @Override public void readBinary(BinaryReader reader) throws
BinaryObjectException {
            Object[] arr = reader.rawReader().readObjectArray();

            for (Object o : arr)
                add((T)o);
        }
    }

    private static class CustomMap<K, V> extends LinkedHashMap<K, V>
implements Binarylizable {
        @Override public void writeBinary(BinaryWriter writer) throws
BinaryObjectException {
            writer.rawWriter().writeMap(new HashMap<>(this));
        }

        @Override public void readBinary(BinaryReader reader) throws
BinaryObjectException {
            putAll((Map<? extends K, ? extends
V>)reader.rawReader().readMap());
        }

    }



--
View this message in context: 
http://apache-ignite-users.70518.x6.nabble.com/Serializer-tp12359p12377.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Reply via email to