EdgeStore implements Collection<Edge>, EdgeIterable { @Override public boolean retainAll(Collection<?> c) { checkCollection(c); if (!c.isEmpty()) { ObjectSet<EdgeImpl> set = new ObjectOpenHashSet(c.size()); for (Object o : c) { checkNonNullObject(o); checkEdgeExists((EdgeImpl) o); set.add((EdgeImpl) o); } boolean changed = false; EdgeStoreIterator itr = iterator(); while (itr.hasNext()) { EdgeImpl e = itr.next(); if (!set.contains(e)) { itr.remove(); changed = true; } } return changed; } else { clear(); } return false; } EdgeStore();  EdgeStore(final EdgeTypeStore edgeTypeStore, final GraphLock lock, final GraphViewStore viewStore, final GraphVersion graphVersion); @Override void clear(); @Override int size(); int undirectedSize(); int size(int type); int undirectedSize(int type); @Override boolean isEmpty(); @Override EdgeStoreIterator iterator(); EdgeStoreIterator iteratorUndirected(); SelfLoopIterator iteratorSelfLoop(); EdgeOutIterator edgeOutIterator(final Node node); EdgeInIterator edgeInIterator(final Node node); EdgeInOutIterator edgeIterator(final Node node); Iterator<Edge> edgeUndirectedIterator(final Node node); EdgeTypeOutIterator edgeOutIterator(final Node node, int type); Iterator<Edge> edgeUndirectedIterator(final Node node, int type); EdgeTypeInIterator edgeInIterator(final Node node, int type); EdgeTypeInOutIterator edgeIterator(final Node node, int type); NeighborsIterator neighborOutIterator(final Node node); NeighborsIterator neighborOutIterator(final Node node, int type); NeighborsIterator neighborInIterator(final Node node); NeighborsIterator neighborInIterator(final Node node, int type); NeighborsIterator neighborIterator(Node node); NeighborsIterator neighborIterator(final Node node, int type); Iterator<Edge> edgesUndirectedIterator(final Node node1, final Node node2); Iterator<Edge> edgesUndirectedIterator(final Node node1, final Node node2, int type); EdgeImpl get(int id); EdgeImpl get(final Object id); EdgeImpl get(final Node source, final Node target, boolean undirectedDecorator); Iterator<Edge> getAll(final Node source, final Node target, boolean undirectedDecorator); EdgeImpl get(final Node source, final Node target, final int type, boolean undirectedDecorator); Iterator<Edge> getAll(final Node source, final Node target, final int type, boolean undirectedDecorator); EdgeImpl getMutualEdge(final Edge e); @Override boolean add(final Edge e); @Override boolean remove(final Object o); @Override boolean contains(Object o); boolean containsId(final Object id); boolean contains(NodeImpl source, NodeImpl target, int type); @Override EdgeImpl[] toArray(); @Override T[] toArray(T[] array); @Override Collection<Edge> toCollection(); @Override boolean containsAll(Collection<?> c); @Override boolean addAll(Collection<? extends Edge> c); @Override boolean removeAll(Collection<?> c); @Override boolean retainAll(Collection<?> c); int deepHashCode(); boolean deepEquals(EdgeStore obj); boolean isAdjacent(Node node1, Node node2, int type); boolean isAdjacent(Node node1, Node node2); boolean isIncident(EdgeImpl edge1, EdgeImpl edge2); boolean isIncident(NodeImpl node, EdgeImpl edge); @Override void doBreak();  }
@Test public void testRetainAll() { EdgeStore edgeStore = new EdgeStore(); EdgeImpl[] edges = GraphGenerator.generateEdgeList(3); edgeStore.addAll(Arrays.asList(edges)); EdgeImpl[] r = new EdgeImpl[] { edges[0] }; boolean a = edgeStore.retainAll(Arrays.asList(r)); boolean b = edgeStore.retainAll(Arrays.asList(r)); Assert.assertTrue(a); Assert.assertFalse(b); Assert.assertEquals(edgeStore.size(), 1); Assert.assertTrue(edgeStore.contains(edges[0])); edgeStore.retainAll(new ArrayList()); Assert.assertTrue(edgeStore.isEmpty()); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testRetainAllSelf() { EdgeStore edgeStore = new EdgeStore(); edgeStore.retainAll(edgeStore); }