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

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

There is a newer version: 3.10.2
Show newest version
package com.netflix.astyanax.serializers;

import java.nio.ByteBuffer;
import org.apache.cassandra.db.marshal.AbstractType;
import org.apache.cassandra.db.marshal.ReversedType;
import com.google.common.base.Preconditions;

@SuppressWarnings("rawtypes")
public class SpecificReversedSerializer extends ReversedSerializer {

	private String reversedTypeName;
	private final ComparatorType reversedComparatorType;
	
	public SpecificReversedSerializer(ReversedType type) {
		Preconditions.checkNotNull(type);
		AbstractType compType = type.baseType;
		reversedTypeName = compType.toString();
		if ( reversedTypeName.startsWith( "org.apache.cassandra.db.marshal." ) ) {
			reversedTypeName = reversedTypeName.substring( "org.apache.cassandra.db.marshal.".length() );
		}		
		this.reversedComparatorType = ComparatorType.getByClassName(reversedTypeName);
	}

	@Override
	public ByteBuffer fromString(String string) {
		return this.reversedComparatorType.getSerializer().fromString(string);
	}

	@Override
	public String getString(ByteBuffer byteBuffer) {
		return this.reversedComparatorType.getSerializer().getString(byteBuffer);
	}	
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy