private final Map<String,BundleEntry> bundlesByName =
new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
public TypesRegistry(Collection<? extends TClass> tClasses) {
for (TClass tClass : tClasses) {
TName tName = tClass.name();
TBundleID bundleID = tName.bundleId();
BundleEntry entry = bundlesByUUID.get(bundleID.uuid());
if (entry == null) {
entry = new BundleEntry(bundleID);
bundlesByUUID.put(bundleID.uuid(), entry);
BundleEntry oentry = bundlesByName.put(bundleID.name(), entry);
if (oentry != null) {
// Tests may fail, but can work if only one used.
logger.warn("There is more than one bundle named {}: {} and {}",
new Object[] {
bundleID.name(), bundleID.uuid(),
oentry.bundleID.uuid()
});
}
}
TClass prev = entry.typeClassByName.put(tName.unqualifiedName(), tClass);
if (prev != null) {
throw new IllegalStateException("Duplicate classes: " + prev +
" and " + tClass);
}
}