Java 8 NoSuchElementException - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 NoSuchElementException class.

This code example shows how to use the following methods:
        return e1 != null;
    } 
 
    public E next() { 
        if (e1 == null) {
            throw new NoSuchElementException();
        } 
        E e = e1;
        e1 = e2;
        e2 = null;
        return e;
    } 
 
    public void remove() { 
    } 
 
    // ------------------------------------------------------------------------- 
    // Utility methods 
    // ------------------------------------------------------------------------- 
 
9
CodeRank
This code example shows how to use the following methods:
    public Object remove() {
        Object x = poll();
        if (x != null)
            return x;
        else 
            throw new NoSuchElementException();
    } 
 
 
    /** 
     * Retrieves, but does not remove, the head of this queue.  This method 
     * differs from {@link #peek peek} only in that it throws an exception if 
     * this queue is empty. 
     * 
     * <p>This implementation returns the result of <tt>peek</tt> 
     * unless the queue is empty. 
     * 
     * @return the head of this queue 
     * @throws NoSuchElementException if this queue is empty 
     */ 
9
CodeRank
This code example shows how to use the following methods:
            return nextEdge != null;
        } 
 
        @Override 
        public R next() { 
            if (nextEdge == null) throw new NoSuchElementException();
            TitanRelation returnEdge = nextEdge;
            getNextEdge(); 
            return (R)returnEdge;
        } 
 
        @Override 
        public void remove() { 
            throw new UnsupportedOperationException();
        } 
    } 
 
} 
8
CodeRank
This code example shows how to use the following methods:
      Image image = createNiceMock(Image.class);
      Set<? extends org.jclouds.ec2.domain.Image> images = ImmutableSet.<org.jclouds.ec2.domain.Image> of(ec2Image);
 
      expect(caller.getAMIApi()).andReturn((Optional) Optional.of(client)).atLeastOnce();
      expect(client.describeImagesInRegion("region", imageIds("ami"))).andReturn(Set.class.cast(images));
      expect(parser.apply(ec2Image)).andThrow(new NoSuchElementException());
 
      replay(caller);
      replay(image);
      replay(parser);
      replay(client);
 
      RegionAndIdToImage function = new RegionAndIdToImage(parser, caller);
 
      assertEquals(function.load(new RegionAndName("region", "ami")), null);
 
      verify(caller);
      verify(image);
      verify(parser);
      verify(client);
7
CodeRank
This code example shows how to use the following methods:
 
	@Override 
	@Test(enabled = false) 
	public void cycle() throws IOException { 
		try { 
			throw new NoSuchElementException(); 
		} catch (Throwable t) { 
 
		} finally { 
		} 
	} 
} 
8
CodeRank
This code example shows how to use the following methods:
        return next != null;
    } 
 
    @Override 
    public Edge next() { 
        if (next == null) throw new NoSuchElementException();
        Edge current = next;
        next = findNext();
        return current;
    } 
 
    /** 
     * Removing edges is not supported! 
     * 
     * @throws UnsupportedOperationException if invoked 
     */ 
    @Override 
    public void remove() { 
        throw new UnsupportedOperationException("Removals are not supported");
    } 
7
CodeRank
This code example shows how to use the following methods:
    } 
 
    @Override 
    public BlockVector next() { 
        if (!hasNext()) { 
            throw new NoSuchElementException();
        } 
 
        BlockVector current = new BlockVector(next2D.getBlockX(), nextY, next2D.getBlockZ());
        if (nextY < maxY) {
            nextY++;
        } else if (flatIterator.hasNext()) {
            next2D = flatIterator.next();
            nextY = minY;
        } else { 
            next2D = null;
        } 
 
        return current;
    } 
8
CodeRank
This code example shows how to use the following methods:
     * specified as one of the constructor file parameters, i.e. is a root file 
     * or directory. 
     */ 
    public boolean isRootFile() { 
        if (current == null) {
            throw new NoSuchElementException();
        } 
        return stack.size() < rootCount;
    } 
 
    /** 
     * Return the next {@link java.io.File} object or {@code null} if no more files are 
     * available. 
     *  
     * @see #getFile() 
     */ 
    public File next() throws IOException {
        if (stack.isEmpty()) {
            current = null;
            return null; 
7
CodeRank
This code example shows how to use the following methods:
        if (more && counter < _bindingList.value.length) {
            org.omg.CosNaming.Binding bndg = _bindingList.value[counter];
            counter++;
            return mapBinding(bndg);
        } else { 
            throw new NoSuchElementException();
        } 
    } 
 
 
    /** 
     * Returns true or false depending on whether there are more bindings. 
     * 
     * @return boolean value 
     */ 
 
    public boolean hasMore() throws NamingException { 
        // If there's more, check whether current bindingList has been exhausted, 
        // and if so, try to get more. 
        // If no more, just say so. 
8
CodeRank
This code example shows how to use the following methods:
	 * 取出String类型的Property,如果都為Null则抛出异常. 
	 */ 
	public String getProperty(String key) {
		String value = getValue(key);
		if (value == null) {
			throw new NoSuchElementException();
		} 
		return value;
	} 
 
	/** 
	 * 取出String类型的Property.如果都為Null則返回Default值. 
	 */ 
	public String getProperty(String key, String defaultValue) {
		String value = getValue(key);
		return value != null ? value : defaultValue;
	} 
 
	/** 
	 * 取出Integer类型的Property.如果都為Null或内容错误则抛出异常. 
7
CodeRank

Related Java 8 NoSuchElementException Questions & Answers:

See Code Examples for Java 8 NoSuchElementException Methods: