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

com.netflix.astyanax.serializers.SetSerializer Maven / Gradle / Ivy

There is a newer version: 3.10.2
Show newest version
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);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy