use of org.neo4j.token.api.NonUniqueTokenException in project neo4j by neo4j.
the class TokenRegistry method insertAllChecked.
private Registries insertAllChecked(List<NamedToken> tokens, Registries registries) {
MutableObjectIntMap<String> uniquePublicNames = new ObjectIntHashMap<>();
MutableObjectIntMap<String> uniqueInternalNames = new ObjectIntHashMap<>();
MutableIntSet uniqueIds = new IntHashSet();
for (NamedToken token : tokens) {
if (token.isInternal()) {
checkNameUniqueness(uniqueInternalNames, token, registries);
checkNameUniqueness(registries.internalNameToId, token, registries);
uniqueInternalNames.put(token.name(), token.id());
} else {
checkNameUniqueness(uniquePublicNames, token, registries);
checkNameUniqueness(registries.publicNameToId, token, registries);
uniquePublicNames.put(token.name(), token.id());
}
if (!uniqueIds.add(token.id()) || registries.idToToken.containsKey(token.id())) {
NamedToken existingToken = registries.idToToken.get(token.id());
throw new NonUniqueTokenException(tokenType, token, existingToken);
}
insertUnchecked(token, registries);
}
return registries;
}
Aggregations