com.github.skjolber.dc.gtfs.OneToManyProcessor Maven / Gradle / Ivy
package com.github.skjolber.dc.gtfs;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* Helper-class for storing a single reference key. Not thread safe.
*
* @param entity type
*/
public class OneToManyProcessor {
protected Map> entityById = new HashMap<>(4 * 4096);
public OneToManyProcessor() {
}
public Map> getById() {
return entityById;
}
public void add(String id, T trip) {
List byId = entityById.get(id);
if(byId == null) {
byId = new ArrayList<>(8);
entityById.put(id, byId);
}
byId.add(trip);
}
}