org.simpleflatmapper.datastax.impl.setter.ConverterToTupleValueMapper Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sfm-datastax Show documentation
Show all versions of sfm-datastax Show documentation
Cassandra Datastax SFM supports.
package org.simpleflatmapper.datastax.impl.setter;
import com.datastax.driver.core.TupleType;
import com.datastax.driver.core.TupleValue;
import org.simpleflatmapper.converter.Context;
import org.simpleflatmapper.map.FieldMapper;
import org.simpleflatmapper.converter.ContextualConverter;
public class ConverterToTupleValueMapper implements ContextualConverter {
private final FieldMapper mapper;
private final TupleType tupleType;
public ConverterToTupleValueMapper(FieldMapper mapper, TupleType tupleType) {
this.mapper = mapper;
this.tupleType = tupleType;
}
@Override
public TupleValue convert(I in, Context context) throws Exception {
if (in == null) return null;
TupleValue tv = tupleType.newValue();
mapper.mapTo(in, tv, null);
return tv;
}
}