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

com.esotericsoftware.kryo.serialize.BooleanSerializer Maven / Gradle / Ivy

Go to download

Kryo is a fast and efficient object graph serialization framework for Java. The goals of the project are speed, efficiency, and an easy to use API. The project is useful any time objects need to be persisted, whether to a file, database, or over the network.

The newest version!

package com.esotericsoftware.kryo.serialize;

import static com.esotericsoftware.minlog.Log.*;

import java.nio.ByteBuffer;

import com.esotericsoftware.kryo.Serializer;

/**
 * Writes a 1 byte boolean.
 * @author Nathan Sweet 
 */
public class BooleanSerializer extends Serializer {
	public Boolean readObjectData (ByteBuffer buffer, Class type) {
		boolean b = buffer.get() == 1;
		if (TRACE) trace("kryo", "Read boolean: " + b);
		return b;
	}

	public void writeObjectData (ByteBuffer buffer, Object object) {
		buffer.put((Boolean)object ? (byte)1 : (byte)0);
		if (TRACE) trace("kryo", "Wrote boolean: " + object);
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy