Search in sources :

Example 6 with DatastaxColumnKey

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);
}
Also used : FieldMapperColumnDefinition(org.simpleflatmapper.map.property.FieldMapperColumnDefinition) GettableByIndexData(com.datastax.driver.core.GettableByIndexData) DatastaxMappingContextFactoryBuilder(org.simpleflatmapper.datastax.impl.DatastaxMappingContextFactoryBuilder) MapperSourceImpl(org.simpleflatmapper.map.mapper.MapperSourceImpl) RowGetterFactory(org.simpleflatmapper.datastax.impl.RowGetterFactory) DatastaxColumnKey(org.simpleflatmapper.datastax.DatastaxColumnKey) ConstantSourceMapperBuilder(org.simpleflatmapper.map.mapper.ConstantSourceMapperBuilder)

Example 7 with DatastaxColumnKey

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));
}
Also used : FieldMapperColumnDefinition(org.simpleflatmapper.map.property.FieldMapperColumnDefinition) DatastaxColumnKey(org.simpleflatmapper.datastax.DatastaxColumnKey) SettableDataSetterFactory(org.simpleflatmapper.datastax.impl.SettableDataSetterFactory) ReflectionService(org.simpleflatmapper.reflect.ReflectionService)

Example 8 with DatastaxColumnKey

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();
}
Also used : GettableByIndexData(com.datastax.driver.core.GettableByIndexData) DatastaxColumnKey(org.simpleflatmapper.datastax.DatastaxColumnKey) DataType(com.datastax.driver.core.DataType)

Aggregations

DatastaxColumnKey (org.simpleflatmapper.datastax.DatastaxColumnKey)8 GettableByIndexData (com.datastax.driver.core.GettableByIndexData)3 DataType (com.datastax.driver.core.DataType)2 RowGetterFactory (org.simpleflatmapper.datastax.impl.RowGetterFactory)2 FieldMapperColumnDefinition (org.simpleflatmapper.map.property.FieldMapperColumnDefinition)2 UserType (com.datastax.driver.core.UserType)1 DatastaxMappingContextFactoryBuilder (org.simpleflatmapper.datastax.impl.DatastaxMappingContextFactoryBuilder)1 SettableDataSetterFactory (org.simpleflatmapper.datastax.impl.SettableDataSetterFactory)1 ConstantSourceMapperBuilder (org.simpleflatmapper.map.mapper.ConstantSourceMapperBuilder)1 MapperSourceImpl (org.simpleflatmapper.map.mapper.MapperSourceImpl)1 PropertyMapping (org.simpleflatmapper.map.mapper.PropertyMapping)1 ReflectionService (org.simpleflatmapper.reflect.ReflectionService)1