Search in sources :

Example 6 with NonUniqueTokenException

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;
}
Also used : MutableIntSet(org.eclipse.collections.api.set.primitive.MutableIntSet) ObjectIntHashMap(org.eclipse.collections.impl.map.mutable.primitive.ObjectIntHashMap) NonUniqueTokenException(org.neo4j.token.api.NonUniqueTokenException) IntHashSet(org.eclipse.collections.impl.set.mutable.primitive.IntHashSet) NamedToken(org.neo4j.token.api.NamedToken)

Aggregations

NamedToken (org.neo4j.token.api.NamedToken)6 NonUniqueTokenException (org.neo4j.token.api.NonUniqueTokenException)6 Test (org.junit.jupiter.api.Test)2 MutableIntSet (org.eclipse.collections.api.set.primitive.MutableIntSet)1 ObjectIntHashMap (org.eclipse.collections.impl.map.mutable.primitive.ObjectIntHashMap)1 IntHashSet (org.eclipse.collections.impl.set.mutable.primitive.IntHashSet)1 UnspecifiedKernelException (org.neo4j.exceptions.UnspecifiedKernelException)1