Search in sources :

Example 1 with ObjectPropertyMeta

use of org.simpleflatmapper.reflect.meta.ObjectPropertyMeta in project SimpleFlatMapper by arnaudroger.

the class AbstractConstantTargetMapperBuilder method addColumn.

@SuppressWarnings("unchecked")
public B addColumn(K key, FieldMapperColumnDefinition<K> columnDefinition) {
    final FieldMapperColumnDefinition<K> composedDefinition = columnDefinition.compose(mapperConfig.columnDefinitions().getColumnDefinition(key));
    final K mappedColumnKey = composedDefinition.rename(key);
    if (composedDefinition.has(ConstantValueProperty.class)) {
        ConstantValueProperty staticValueProperty = composedDefinition.lookFor(ConstantValueProperty.class);
        PropertyMeta<T, Object> meta = new ObjectPropertyMeta<T, Object>(key.getName(), classMeta.getType(), reflectionService, staticValueProperty.getType(), ScoredGetter.of(new ConstantGetter<T, Object>(staticValueProperty.getValue()), 1), null, null);
        propertyMappingsBuilder.addProperty(key, columnDefinition, meta);
    } else {
        propertyMappingsBuilder.addProperty(mappedColumnKey, composedDefinition);
    }
    return (B) this;
}
Also used : ConstantGetter(org.simpleflatmapper.reflect.getter.ConstantGetter) ConstantValueProperty(org.simpleflatmapper.map.property.ConstantValueProperty) ObjectPropertyMeta(org.simpleflatmapper.reflect.meta.ObjectPropertyMeta)

Example 2 with ObjectPropertyMeta

use of org.simpleflatmapper.reflect.meta.ObjectPropertyMeta in project SimpleFlatMapper by arnaudroger.

the class SqlParameterSourceBuilder method add.

public SqlParameterSourceBuilder<T> add(JdbcColumnKey key, FieldMapperColumnDefinition<JdbcColumnKey> columnDefinition) {
    final FieldMapperColumnDefinition<JdbcColumnKey> composedDefinition = columnDefinition.compose(mapperConfig.columnDefinitions().getColumnDefinition(key));
    final JdbcColumnKey mappedColumnKey = composedDefinition.rename(key);
    if (composedDefinition.has(ConstantValueProperty.class)) {
        ConstantValueProperty staticValueProperty = composedDefinition.lookFor(ConstantValueProperty.class);
        PropertyMeta<T, Object> meta = new ObjectPropertyMeta<T, Object>(key.getName(), builder.getClassMeta().getType(), reflectionService, staticValueProperty.getType(), ScoredGetter.of(new ConstantGetter<T, Object>(staticValueProperty.getValue()), 1), null, null);
        builder.addProperty(key, columnDefinition, meta);
    } else {
        builder.addProperty(mappedColumnKey, composedDefinition);
    }
    return this;
}
Also used : JdbcColumnKey(org.simpleflatmapper.jdbc.JdbcColumnKey) ConstantGetter(org.simpleflatmapper.reflect.getter.ConstantGetter) ConstantValueProperty(org.simpleflatmapper.map.property.ConstantValueProperty) ObjectPropertyMeta(org.simpleflatmapper.reflect.meta.ObjectPropertyMeta)

Aggregations

ConstantValueProperty (org.simpleflatmapper.map.property.ConstantValueProperty)2 ConstantGetter (org.simpleflatmapper.reflect.getter.ConstantGetter)2 ObjectPropertyMeta (org.simpleflatmapper.reflect.meta.ObjectPropertyMeta)2 JdbcColumnKey (org.simpleflatmapper.jdbc.JdbcColumnKey)1