All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.threerings.nexus.distrib.Streamer_DMap Maven / Gradle / Ivy

The newest version!
//
// Nexus Core - a framework for developing distributed applications
// http://github.com/threerings/nexus/blob/master/LICENSE

package com.threerings.nexus.distrib;

import com.threerings.nexus.io.Streamable;
import com.threerings.nexus.io.Streamer;

/**
 * Handles the streaming of {@link DMap} and/or nested classes.
 */
public class Streamer_DMap
{
    /**
     * Handles the streaming of {@link DMap.PutEvent} instances.
     */
    public static class PutEvent
        implements Streamer>
    {
        @Override
        public Class getObjectClass () {
            return DMap.PutEvent.class;
        }

        @Override
        public void writeObject (Streamable.Output out, DMap.PutEvent obj) {
            writeObjectImpl(out, obj);
        }

        @Override
        public DMap.PutEvent readObject (Streamable.Input in) {
            return new DMap.PutEvent(
                in.readInt(),
                in.readShort(),
                in.readValue(),
                in.readValue()
            );
        }

        public static  void writeObjectImpl (Streamable.Output out, DMap.PutEvent obj) {
            Streamer_DAttribute.Event.writeObjectImpl(out, obj);
            out.writeValue(obj._key);
            out.writeValue(obj._value);
        }
    }

    /**
     * Handles the streaming of {@link DMap.RemoveEvent} instances.
     */
    public static class RemoveEvent
        implements Streamer>
    {
        @Override
        public Class getObjectClass () {
            return DMap.RemoveEvent.class;
        }

        @Override
        public void writeObject (Streamable.Output out, DMap.RemoveEvent obj) {
            writeObjectImpl(out, obj);
        }

        @Override
        public DMap.RemoveEvent readObject (Streamable.Input in) {
            return new DMap.RemoveEvent(
                in.readInt(),
                in.readShort(),
                in.readValue()
            );
        }

        public static  void writeObjectImpl (Streamable.Output out, DMap.RemoveEvent obj) {
            Streamer_DAttribute.Event.writeObjectImpl(out, obj);
            out.writeValue(obj._key);
        }
    }

    // no streamer for non-Streamable enclosing class: DMap
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy