use of org.simpleflatmapper.map.property.SetterProperty in project SimpleFlatMapper by arnaudroger.
the class FieldMapperToAppendableFactory method getSetter.
@SuppressWarnings("unchecked")
private <S, P> Setter<Appendable, ? super P> getSetter(PropertyMapping<S, P, CsvColumnKey, FieldMapperColumnDefinition<CsvColumnKey>> pm, CellWriter cellWriter) {
final SetterProperty setterProperty = pm.getColumnDefinition().lookFor(SetterProperty.class);
if (setterProperty != null) {
return new CellWriterSetterWrapper<P>(cellWriter, (Setter<Appendable, P>) setterProperty.getSetter());
}
Setter<Appendable, ? super P> setter = setterFromFactory(pm);
if (setter != null) {
return new CellWriterSetterWrapper<P>(cellWriter, setter);
}
return null;
}
use of org.simpleflatmapper.map.property.SetterProperty in project SimpleFlatMapper by arnaudroger.
the class CtfmSetterNotFoundTest method csvMapperOverrideGetter.
@Test
public void csvMapperOverrideGetter() throws IOException {
StringBuilder sb = new StringBuilder();
CsvWriter.from(Foo2.class).column("bar", new SetterProperty(new Setter<Appendable, Bar2Prop>() {
@Override
public void set(Appendable target, Bar2Prop value) throws Exception {
target.append(value.getVal()).append(":").append(String.valueOf(value.getI()));
}
})).to(sb).append(new Foo2(new Bar2Prop("val", 3)));
assertEquals("bar\r\nval:3\r\n", sb.toString());
}
use of org.simpleflatmapper.map.property.SetterProperty in project SimpleFlatMapper by arnaudroger.
the class PreparedStatementFieldMapperFactoryTest method testCustomSetter.
@Test
public void testCustomSetter() throws Exception {
Object o = new Object();
newFieldMapperAndMapToPS(new ConstantGetter<Object, Object>(o), Object.class, new SetterProperty(new Setter<PreparedStatement, Object>() {
@Override
public void set(PreparedStatement target, Object value) throws Exception {
ps.setString(35, "aa");
}
}));
verify(ps).setString(35, "aa");
}
use of org.simpleflatmapper.map.property.SetterProperty in project SimpleFlatMapper by arnaudroger.
the class Issue365Test method mapperConfig.
private MapperConfig<SampleFieldKey, FieldMapperColumnDefinition<SampleFieldKey>> mapperConfig() {
FieldMapperColumnDefinitionProviderImpl<SampleFieldKey> provider = new FieldMapperColumnDefinitionProviderImpl<SampleFieldKey>();
provider.addColumnDefinition("benchmark", FieldMapperColumnDefinition.<SampleFieldKey>identity().add(new SetterProperty(SETTER)).add(new GetterProperty(GETTER)));
return MapperConfig.<SampleFieldKey>fieldMapperConfig().columnDefinitions(provider);
}
Aggregations