com.netflix.astyanax.serializers.SetSerializer Maven / Gradle / Ivy
package com.netflix.astyanax.serializers;
import java.nio.ByteBuffer;
import java.util.Set;
import org.apache.cassandra.db.marshal.AbstractType;
import org.apache.cassandra.db.marshal.SetType;
import com.netflix.astyanax.serializers.AbstractSerializer;
/**
* Serializer implementation for generic sets.
*
* @author vermes
*
* @param
* element type
*/
public class SetSerializer extends AbstractSerializer> {
private final SetType mySet;
/**
* @param elements
*/
public SetSerializer(AbstractType elements) {
mySet = SetType.getInstance(elements);
}
@Override
public Set fromByteBuffer(ByteBuffer arg0) {
return arg0 == null ? null : mySet.compose(arg0);
}
@Override
public ByteBuffer toByteBuffer(Set arg0) {
return arg0 == null ? null : mySet.decompose(arg0);
}
}