com.conveyal.gtfs.util.Renamer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of gtfs-lib Show documentation
Show all versions of gtfs-lib Show documentation
A library to load and index GTFS feeds of arbitrary size using disk-backed storage
package com.conveyal.gtfs.util;
import java.util.*;
/**
* Creates new unique names to give things new IDs.
*/
public class Renamer {
private Map newNameForOldName = new HashMap<>();
private Map oldNameForNewName = new HashMap<>();
public String getNewName(String oldName) {
String newName = newNameForOldName.get(oldName);
if (newName == null) {
while (newName == null || oldNameForNewName.containsKey(newName)) {
newName = UUID.randomUUID().toString().substring(0, 6);
}
newNameForOldName.put(oldName, newName);
oldNameForNewName.put(newName, oldName);
System.out.println(oldName + " <--> " + newName);
}
return newName;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy