public void testEmptyGraph() { final TestNode node = new TestNode("A"); final GraphGenerator<TestNode> graphGenerator = new GraphGenerator<TestNode>(new GraphGenerator.SemiGraph<TestNode>() { @Override public Collection<TestNode> getNodes() { return Arrays.asList(new TestNode[]{node}); } @Override public Iterator<TestNode> getIn(TestNode n) { return EmptyIterator.getInstance(); } }); assertFalse(graphGenerator.getOut(node).hasNext()); }
@Nonnull @Override public Iterator<Attribute> iterator() { if (isEmpty()) return EmptyIterator.getInstance(); return new Iterator<Attribute>() { int i; @Override public boolean hasNext() { return i < size(); } @Override public Attribute next() { return get(i++); } @Override public void remove() { throw ImmutableElement.immutableError(ImmutableSameTypeAttributeList.this); } }; }
@NotNull private Iterator<Instruction> indicesToInstructions(int[] next) { if (next == null) return EmptyIterator.getInstance(); List<Instruction> out = new ArrayList<Instruction>(next.length); for (int i : next) { out.add(myInstructions[i]); } return out.iterator(); }
private boolean pushNode(final @NotNull String name, @NotNull Node<T> node) { final HashMap<String, Node<T>> childrenMap = node.myChildren; final boolean hasChildren = childrenMap != null && childrenMap.size() > 0; if (hasChildren || node.mappingExists()) { myCurrentNodePath.push(new PathElement<T>(node, hasChildren? childrenMap.keySet().iterator() : EmptyIterator.<String>getInstance())); if (myCurrentNodePath.size() > 2) { // do not add separator before the Root and its direct child nodes myCurrentName.append(mySeparator); } myCurrentName.append(name); return true; } return false; }
@NotNull @Override public Iterator<E> iterator() { if (mySize == 0) { return EmptyIterator.getInstance(); } if (mySize == 1) { return new SingletonIterator(); } return super.iterator(); }
@Nonnull @Override public Iterator<E> iterator() { if (mySize == 0) { return EmptyIterator.getInstance(); } if (mySize == 1) { return new SingletonIterator(); } return super.iterator(); }
@NotNull private Iterator<Instruction> indicesToInstructions(int[] next) { if(next == null) { return EmptyIterator.getInstance(); } List<Instruction> out = new ArrayList<>(next.length); for(int i : next) { out.add(myInstructions[i]); } return out.iterator(); }
@Override public Iterator<Fragment> iterator() { return EmptyIterator.getInstance(); }
public Iterator<Fragment> iterator() { return EmptyIterator.getInstance(); }
@Nonnull @Override public Iterator<? extends ArchiveEntry> entries() { return EmptyIterator.getInstance(); }