@Test(expectedExceptions = IllegalArgumentException.class) public void testDictionaryDuplicate() { NodeStore nodeStore = new NodeStore(); NodeImpl node = new NodeImpl("1"); nodeStore.add(node); NodeImpl node2 = new NodeImpl("1"); nodeStore.add(node2); }
@Override public boolean add(final Node n) { checkNonNullNodeObject(n); NodeImpl node = (NodeImpl) n; if (node.storeId == NodeStore.NULL_ID) { checkIdDoesntExist(n.getId()); incrementVersion(); if (garbageSize > 0) { for (int i = 0; i < blocksCount; i++) { NodeBlock nodeBlock = blocks[i]; if (nodeBlock.hasGarbage()) { nodeBlock.set(node); garbageSize--; dictionary.put(node.getId(), node.storeId); break; } } } else { ensureCapacity(1); currentBlock.add(node); dictionary.put(node.getId(), node.storeId); } if (viewStore != null) { viewStore.addNode(node); } node.indexAttributes(); size++; return true; } else if (isValidIndex(node.storeId) && get(node.storeId) == node) { return false; } else { throw new IllegalArgumentException("The node already belongs to another store"); } }
NodeStore implements Collection<Node>, NodeIterable { @Override public boolean add(final Node n) { checkNonNullNodeObject(n); NodeImpl node = (NodeImpl) n; if (node.storeId == NodeStore.NULL_ID) { checkIdDoesntExist(n.getId()); incrementVersion(); if (garbageSize > 0) { for (int i = 0; i < blocksCount; i++) { NodeBlock nodeBlock = blocks[i]; if (nodeBlock.hasGarbage()) { nodeBlock.set(node); garbageSize--; dictionary.put(node.getId(), node.storeId); break; } } } else { ensureCapacity(1); currentBlock.add(node); dictionary.put(node.getId(), node.storeId); } if (viewStore != null) { viewStore.addNode(node); } node.indexAttributes(); size++; return true; } else if (isValidIndex(node.storeId) && get(node.storeId) == node) { return false; } else { throw new IllegalArgumentException("The node already belongs to another store"); } } }
NodeStore implements Collection<Node>, NodeIterable { @Override public boolean add(final Node n) { checkNonNullNodeObject(n); NodeImpl node = (NodeImpl) n; if (node.storeId == NodeStore.NULL_ID) { checkIdDoesntExist(n.getId()); incrementVersion(); if (garbageSize > 0) { for (int i = 0; i < blocksCount; i++) { NodeBlock nodeBlock = blocks[i]; if (nodeBlock.hasGarbage()) { nodeBlock.set(node); garbageSize--; dictionary.put(node.getId(), node.storeId); break; } } } else { ensureCapacity(1); currentBlock.add(node); dictionary.put(node.getId(), node.storeId); } if (viewStore != null) { viewStore.addNode(node); } node.indexAttributes(); size++; return true; } else if (isValidIndex(node.storeId) && get(node.storeId) == node) { return false; } else { throw new IllegalArgumentException("The node already belongs to another store"); } } NodeStore();  NodeStore(final EdgeStore edgeStore, final GraphLock lock, final GraphViewStore viewStore, final GraphVersion graphVersion); }
NodeStore implements Collection<Node>, NodeIterable { @Override public boolean add(final Node n) { checkNonNullNodeObject(n); NodeImpl node = (NodeImpl) n; if (node.storeId == NodeStore.NULL_ID) { checkIdDoesntExist(n.getId()); incrementVersion(); if (garbageSize > 0) { for (int i = 0; i < blocksCount; i++) { NodeBlock nodeBlock = blocks[i]; if (nodeBlock.hasGarbage()) { nodeBlock.set(node); garbageSize--; dictionary.put(node.getId(), node.storeId); break; } } } else { ensureCapacity(1); currentBlock.add(node); dictionary.put(node.getId(), node.storeId); } if (viewStore != null) { viewStore.addNode(node); } node.indexAttributes(); size++; return true; } else if (isValidIndex(node.storeId) && get(node.storeId) == node) { return false; } else { throw new IllegalArgumentException("The node already belongs to another store"); } } NodeStore();  NodeStore(final EdgeStore edgeStore, final GraphLock lock, final GraphViewStore viewStore, final GraphVersion graphVersion); NodeImpl get(final int id); NodeImpl get(final Object id); @Override void clear(); @Override int size(); @Override boolean isEmpty(); @Override NodeStoreIterator iterator(); @Override NodeImpl[] toArray(); @Override T[] toArray(T[] array); @Override Collection<Node> toCollection(); @Override boolean add(final Node n); @Override boolean remove(final Object o); @Override boolean contains(final Object o); boolean containsId(final Object id); @Override boolean containsAll(final Collection<?> c); @Override boolean addAll(final Collection<? extends Node> c); @Override boolean removeAll(final Collection<?> c); @Override boolean retainAll(final Collection<?> c); int deepHashCode(); boolean deepEquals(NodeStore obj); @Override void doBreak(); }
NodeStore implements Collection<Node>, NodeIterable { @Override public boolean add(final Node n) { checkNonNullNodeObject(n); NodeImpl node = (NodeImpl) n; if (node.storeId == NodeStore.NULL_ID) { checkIdDoesntExist(n.getId()); incrementVersion(); if (garbageSize > 0) { for (int i = 0; i < blocksCount; i++) { NodeBlock nodeBlock = blocks[i]; if (nodeBlock.hasGarbage()) { nodeBlock.set(node); garbageSize--; dictionary.put(node.getId(), node.storeId); break; } } } else { ensureCapacity(1); currentBlock.add(node); dictionary.put(node.getId(), node.storeId); } if (viewStore != null) { viewStore.addNode(node); } node.indexAttributes(); size++; return true; } else if (isValidIndex(node.storeId) && get(node.storeId) == node) { return false; } else { throw new IllegalArgumentException("The node already belongs to another store"); } } NodeStore();  NodeStore(final EdgeStore edgeStore, final GraphLock lock, final GraphViewStore viewStore, final GraphVersion graphVersion); NodeImpl get(final int id); NodeImpl get(final Object id); @Override void clear(); @Override int size(); @Override boolean isEmpty(); @Override NodeStoreIterator iterator(); @Override NodeImpl[] toArray(); @Override T[] toArray(T[] array); @Override Collection<Node> toCollection(); @Override boolean add(final Node n); @Override boolean remove(final Object o); @Override boolean contains(final Object o); boolean containsId(final Object id); @Override boolean containsAll(final Collection<?> c); @Override boolean addAll(final Collection<? extends Node> c); @Override boolean removeAll(final Collection<?> c); @Override boolean retainAll(final Collection<?> c); int deepHashCode(); boolean deepEquals(NodeStore obj); @Override void doBreak();  }