Search in sources :

Example 1 with RowGetterFactory

use of org.simpleflatmapper.datastax.impl.RowGetterFactory in project SimpleFlatMapper by arnaudroger.

the class RowGetterFactoryTest method testIntGetterOnNullValue.

@Test
public void testIntGetterOnNullValue() throws Exception {
    when(row.isNull(1)).thenReturn(true);
    assertEquals(null, new RowGetterFactory(null).newGetter(Integer.class, columnKey).get(row));
}
Also used : RowGetterFactory(org.simpleflatmapper.datastax.impl.RowGetterFactory) Test(org.junit.Test)

Example 2 with RowGetterFactory

use of org.simpleflatmapper.datastax.impl.RowGetterFactory in project SimpleFlatMapper by arnaudroger.

the class RowGetterFactoryTest method testFloatGetterOnNullValue.

@Test
public void testFloatGetterOnNullValue() throws Exception {
    when(row.isNull(1)).thenReturn(true);
    assertEquals(null, new RowGetterFactory(null).newGetter(Float.class, columnKey).get(row));
}
Also used : RowGetterFactory(org.simpleflatmapper.datastax.impl.RowGetterFactory) Test(org.junit.Test)

Example 3 with RowGetterFactory

use of org.simpleflatmapper.datastax.impl.RowGetterFactory 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 4 with RowGetterFactory

use of org.simpleflatmapper.datastax.impl.RowGetterFactory 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 5 with RowGetterFactory

use of org.simpleflatmapper.datastax.impl.RowGetterFactory in project SimpleFlatMapper by arnaudroger.

the class RowGetterFactoryTest method testByteGetterOnNullValue.

@Test
public void testByteGetterOnNullValue() throws Exception {
    when(row.isNull(1)).thenReturn(true);
    assertEquals(null, new RowGetterFactory(null).newGetter(Byte.class, columnKey.datatype(DataType.bigint())).get(row));
}
Also used : RowGetterFactory(org.simpleflatmapper.datastax.impl.RowGetterFactory) Test(org.junit.Test)

Aggregations

RowGetterFactory (org.simpleflatmapper.datastax.impl.RowGetterFactory)9 Test (org.junit.Test)7 DatastaxColumnKey (org.simpleflatmapper.datastax.DatastaxColumnKey)2 GettableByIndexData (com.datastax.driver.core.GettableByIndexData)1 DatastaxMappingContextFactoryBuilder (org.simpleflatmapper.datastax.impl.DatastaxMappingContextFactoryBuilder)1 ConstantSourceMapperBuilder (org.simpleflatmapper.map.mapper.ConstantSourceMapperBuilder)1 MapperSourceImpl (org.simpleflatmapper.map.mapper.MapperSourceImpl)1 FieldMapperColumnDefinition (org.simpleflatmapper.map.property.FieldMapperColumnDefinition)1