final String propertyPath,
final PojoMetadata metadata) {
int index = propertyPath.indexOf('.');
if (index <= 0) {
// Simple path - fast way
final Getter getter = metadata.getPropertyGetterIfExists(propertyPath);
// behavior change: do not throw if POJO contains less properties
if (getter == null) return null;
final Converter converter = quirks.converterOf(getter.getType());
// getter without converter
if (converter == null) return getter;
return new Getter() {
public Object getProperty(Object obj) {
try {
return converter.convert(getter.getProperty(obj));
} catch (ConverterException e) {
throw new Sql2oException("Error trying to convert column " + propertyPath + " to type " + getter.getType(), e);
}
}
public Class getType() {
return getter.getType();
}
};
}
// dot path - long way
// i'm too lazy now to rewrite this case so I just call old unoptimized code...
// TODO: rewrite, get rid of POJO class
return new Getter() {
public Object getProperty(Object obj) {
Pojo pojo = new Pojo(metadata, metadata.isCaseSensitive(), obj);
return pojo.getProperty(propertyPath, quirks);
}