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

com.netflix.astyanax.serializers.SpecificCompositeSerializer 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.ArrayList;
import java.util.List;

import org.apache.cassandra.db.marshal.AbstractType;
import org.apache.cassandra.db.marshal.CompositeType;

import com.google.common.base.Preconditions;

public class SpecificCompositeSerializer extends CompositeSerializer {
	private final CompositeType type;
	private List comparators;

	public SpecificCompositeSerializer(CompositeType type) {
		Preconditions.checkNotNull(type);
		this.type = type;
		comparators = new ArrayList( type.types.size() );
		for ( AbstractType compType : type.types ) {
			String typeName = compType.toString();
			if ( typeName.startsWith( "org.apache.cassandra.db.marshal." ) ) {
				typeName = typeName.substring( "org.apache.cassandra.db.marshal.".length() );
			}
			comparators.add( typeName );
		}
	}

	@Override
	public ByteBuffer fromString(String string) {
		return type.fromString(string);
	}

	@Override
	public String getString(ByteBuffer byteBuffer) {
		return type.getString(byteBuffer);
	}

	@Override
	public List getComparators() {
		return comparators;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy