use of org.simpleflatmapper.datastax.DatastaxColumnKey in project SimpleFlatMapper by arnaudroger.
the class DatastaxUDTGetter method newFieldMapperBuilder.
public static <P> ConstantSourceMapperBuilder<GettableByIndexData, P, DatastaxColumnKey> newFieldMapperBuilder(DatastaxMapperFactory factory, Type target) {
MapperConfig<DatastaxColumnKey, FieldMapperColumnDefinition<DatastaxColumnKey>> config = factory.mapperConfig();
MapperSourceImpl<GettableByIndexData, DatastaxColumnKey> mapperSource = new MapperSourceImpl<GettableByIndexData, DatastaxColumnKey>(GettableByIndexData.class, new RowGetterFactory(factory));
ClassMeta<P> classMeta = factory.getClassMeta(target);
return new ConstantSourceMapperBuilder<GettableByIndexData, P, DatastaxColumnKey>(mapperSource, classMeta, config, new DatastaxMappingContextFactoryBuilder(), DatastaxMapperBuilder.KEY_FACTORY);
}
use of org.simpleflatmapper.datastax.DatastaxColumnKey in project SimpleFlatMapper by arnaudroger.
the class DataTypeTest method getSetter.
public static <N> Setter<SettableByIndexData, N> getSetter(Class<N> target, DataType dataType) throws InstantiationException, IllegalAccessException, InvocationTargetException, NoSuchMethodException, ClassNotFoundException {
MapperConfig<DatastaxColumnKey, FieldMapperColumnDefinition<DatastaxColumnKey>> mapperConfig = MapperConfig.<DatastaxColumnKey>fieldMapperConfig();
ReflectionService reflectionService = ReflectionService.newInstance();
SettableDataSetterFactory factory = new SettableDataSetterFactory(mapperConfig, reflectionService);
DatastaxColumnKey columnKey = new DatastaxColumnKey("col", 1, dataType);
return factory.getSetter(newPM(target, dataType, columnKey));
}
use of org.simpleflatmapper.datastax.DatastaxColumnKey in project SimpleFlatMapper by arnaudroger.
the class DatastaxTupleGetter method newTupleMapper.
public static <P extends Tuple2<?, ?>> Mapper<GettableByIndexData, P> newTupleMapper(Type target, TupleType tt, DatastaxMapperFactory factory) {
ConstantSourceMapperBuilder<GettableByIndexData, P, DatastaxColumnKey> builder = DatastaxUDTGetter.newFieldMapperBuilder(factory, target);
List<DataType> componentTypes = tt.getComponentTypes();
for (int i = 0; i < componentTypes.size(); i++) {
FieldMapperColumnDefinition<DatastaxColumnKey> identity = FieldMapperColumnDefinition.identity();
builder.addMapping(new DatastaxColumnKey("elt" + i, i, componentTypes.get(i)), identity);
}
return builder.mapper();
}
Aggregations