org.entur.netex.index.impl.NetexEntityMapByIdImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of netex-parser-java Show documentation
Show all versions of netex-parser-java Show documentation
Library for parsing NeTEx files and looking up entities in an index.
package org.entur.netex.index.impl;
import org.entur.netex.index.api.NetexEntityIndex;
import org.rutebanken.netex.model.EntityStructure;
import java.util.Collection;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
public class NetexEntityMapByIdImpl implements NetexEntityIndex {
private final Map map = new ConcurrentHashMap<>();
@Override
public V get(String id) {
return map.get(id);
}
@Override
public Collection getAll() {
return map.values();
}
@Override
public void put(String id, V entity) {
map.put(id, entity);
}
@Override
public void putAll(Collection entities) {
entities.forEach(this::add);
}
@Override
public void remove(String id) {
map.remove(id);
}
public void add(V entity) {
map.put(entity.getId(), entity);
}
}