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

cocaine.msgpack.UUIDTemplate Maven / Gradle / Ivy

There is a newer version: 0.11.1.0
Show newest version
package cocaine.msgpack;

import java.io.IOException;
import java.util.UUID;

import org.msgpack.packer.Packer;
import org.msgpack.template.AbstractTemplate;
import org.msgpack.template.Template;
import org.msgpack.unpacker.Unpacker;

/**
 * @author Anton Bobukh 
 */
public final class UUIDTemplate extends AbstractTemplate {

    private static final UUIDTemplate instance = new UUIDTemplate();

    private UUIDTemplate() { }

    public static Template getInstance() {
        return instance;
    }

    @Override
    public void write(Packer packer, UUID uuid, boolean required) throws IOException {
        packer.write(uuid.toString());
    }

    @Override
    public UUID read(Unpacker unpacker, UUID uuid, boolean required) throws IOException {
        return UUID.fromString(unpacker.readString());
    }

}





© 2015 - 2025 Weber Informatics LLC | Privacy Policy