Search in sources :

Example 1 with DatastaxColumnKey

use of org.simpleflatmapper.datastax.DatastaxColumnKey in project SimpleFlatMapper by arnaudroger.

the class SettableDataSetterFactoryTest method newPM.

@SuppressWarnings("unchecked")
private <T, P> PropertyMapping<?, ?, DatastaxColumnKey, ? extends ColumnDefinition<DatastaxColumnKey, ?>> newPM(Type clazz, DataType datatype, Object... properties) {
    PropertyMeta<T, P> propertyMeta = mock(PropertyMeta.class);
    when(propertyMeta.getPropertyType()).thenReturn(clazz);
    return new PropertyMapping<T, P, DatastaxColumnKey, FieldMapperColumnDefinition<DatastaxColumnKey>>(propertyMeta, new DatastaxColumnKey("col", index++, datatype), FieldMapperColumnDefinition.<DatastaxColumnKey>of(properties));
}
Also used : PropertyMapping(org.simpleflatmapper.map.mapper.PropertyMapping) DatastaxColumnKey(org.simpleflatmapper.datastax.DatastaxColumnKey)

Example 2 with DatastaxColumnKey

use of org.simpleflatmapper.datastax.DatastaxColumnKey in project SimpleFlatMapper by arnaudroger.

the class DataTypeTest method getGetter.

public static <N> Getter<GettableByIndexData, N> getGetter(Class<N> target, DataType dataType) throws InstantiationException, IllegalAccessException, InvocationTargetException, NoSuchMethodException, ClassNotFoundException {
    RowGetterFactory rowGetterFactory = new RowGetterFactory(null);
    DatastaxColumnKey columnKey = new DatastaxColumnKey("col", 1, dataType);
    FieldMapperColumnDefinition<DatastaxColumnKey> columnDefinition = FieldMapperColumnDefinition.identity();
    return rowGetterFactory.newGetter(target, columnKey, columnDefinition);
}
Also used : RowGetterFactory(org.simpleflatmapper.datastax.impl.RowGetterFactory) DatastaxColumnKey(org.simpleflatmapper.datastax.DatastaxColumnKey)

Example 3 with DatastaxColumnKey

use of org.simpleflatmapper.datastax.DatastaxColumnKey in project SimpleFlatMapper by arnaudroger.

the class TupleValueSettableDataSetter method newTupleMapper.

public static <T extends Tuple2<?, ?>> Mapper<T, SettableByIndexData> newTupleMapper(Type target, TupleType tt, MapperConfig<DatastaxColumnKey, FieldMapperColumnDefinition<DatastaxColumnKey>> config, ReflectionService reflectionService) {
    SettableDataMapperBuilder<T> builder = newFieldMapperBuilder(config, reflectionService, target);
    List<DataType> componentTypes = tt.getComponentTypes();
    for (int i = 0; i < componentTypes.size(); i++) {
        builder.addColumn(new DatastaxColumnKey("elt" + i, i, componentTypes.get(i)));
    }
    return builder.mapper();
}
Also used : DatastaxColumnKey(org.simpleflatmapper.datastax.DatastaxColumnKey) DataType(com.datastax.driver.core.DataType)

Example 4 with DatastaxColumnKey

use of org.simpleflatmapper.datastax.DatastaxColumnKey in project SimpleFlatMapper by arnaudroger.

the class UDTObjectSettableDataSetter method newUDTMapper.

public static <T> Mapper<T, SettableByIndexData> newUDTMapper(Type target, UserType tt, MapperConfig<DatastaxColumnKey, FieldMapperColumnDefinition<DatastaxColumnKey>> config, ReflectionService reflectionService) {
    SettableDataMapperBuilder<T> builder = newFieldMapperBuilder(config, reflectionService, target);
    Iterator<UserType.Field> iterator = tt.iterator();
    int i = 0;
    while (iterator.hasNext()) {
        UserType.Field f = iterator.next();
        builder.addColumn(new DatastaxColumnKey(f.getName(), i, f.getType()));
        i++;
    }
    return builder.mapper();
}
Also used : DatastaxColumnKey(org.simpleflatmapper.datastax.DatastaxColumnKey)

Example 5 with DatastaxColumnKey

use of org.simpleflatmapper.datastax.DatastaxColumnKey in project SimpleFlatMapper by arnaudroger.

the class DatastaxUDTGetter method newUDTMapper.

public static <P> Mapper<GettableByIndexData, P> newUDTMapper(Type target, UserType tt, DatastaxMapperFactory factory) {
    ConstantSourceMapperBuilder<GettableByIndexData, P, DatastaxColumnKey> builder = newFieldMapperBuilder(factory, target);
    Iterator<UserType.Field> iterator = tt.iterator();
    int i = 0;
    while (iterator.hasNext()) {
        UserType.Field f = iterator.next();
        FieldMapperColumnDefinition<DatastaxColumnKey> identity = FieldMapperColumnDefinition.identity();
        builder.addMapping(new DatastaxColumnKey(f.getName(), i, f.getType()), identity);
        i++;
    }
    return builder.mapper();
}
Also used : GettableByIndexData(com.datastax.driver.core.GettableByIndexData) DatastaxColumnKey(org.simpleflatmapper.datastax.DatastaxColumnKey) UserType(com.datastax.driver.core.UserType)

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