use of org.onebusaway.csv_entities.schema.SingleFieldMapping in project onebusaway-gtfs-modules by OneBusAway.
the class PropertyMethodResolverImpl method getPropertyMethod.
@Override
public PropertyMethod getPropertyMethod(Class<?> targetType, String propertyName) {
@SuppressWarnings("rawtypes") PropertyMethod method = _virtualPropertyMethods.get(Tuples.tuple((Class) targetType, propertyName));
if (method != null) {
return method;
}
SingleFieldMapping mapping = _schemaCache.getFieldMappingForCsvFieldName(targetType, propertyName);
if (mapping != null) {
propertyName = mapping.getObjFieldName();
}
return super.getPropertyMethod(targetType, propertyName);
}
use of org.onebusaway.csv_entities.schema.SingleFieldMapping in project onebusaway-gtfs-modules by OneBusAway.
the class TransformFactory method getPropertyValueSettersFromJsonObject.
private Map<String, ValueSetter> getPropertyValueSettersFromJsonObject(Class<?> entityType, JSONObject obj, Set<String> propertiesToExclude) throws JSONException {
Map<String, Object> map = getPropertyValuesFromJsonObject(obj, propertiesToExclude);
Map<String, ValueSetter> setters = new HashMap<String, ValueSetter>();
for (Map.Entry<String, Object> entry : map.entrySet()) {
String propertyName = entry.getKey();
SingleFieldMapping mapping = _schemaCache.getFieldMappingForCsvFieldName(entityType, propertyName);
if (mapping != null) {
propertyName = mapping.getObjFieldName();
}
ValueSetter setter = createSetterForValue(entry.getValue());
setters.put(propertyName, setter);
}
return setters;
}
use of org.onebusaway.csv_entities.schema.SingleFieldMapping in project onebusaway-gtfs-modules by OneBusAway.
the class EntitySchemaCache method addEntitySchema.
public void addEntitySchema(EntitySchema schema) {
_entitySchemasByEntityType.put(schema.getEntityClass(), schema);
if (schema.getFilename() != null) {
_entitySchemasByFileName.put(schema.getFilename(), schema);
}
for (FieldMapping mapping : schema.getFields()) {
if (mapping instanceof SingleFieldMapping) {
SingleFieldMapping single = (SingleFieldMapping) mapping;
putMappingForEntityTypeAndName(_mappingsByTypeAndCsvFieldName, schema.getEntityClass(), single.getCsvFieldName(), single);
putMappingForEntityTypeAndName(_mappingsByTypeAndObjectFieldName, schema.getEntityClass(), single.getObjFieldName(), single);
}
}
}
Aggregations