All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jnario.lib.JnarioIteratorExtensions Maven / Gradle / Ivy

The newest version!
/*******************************************************************************
 * Copyright (c) 2012 BMW Car IT and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *******************************************************************************/
package org.jnario.lib;

import static com.google.common.collect.Iterators.filter;

import java.util.Iterator;

import com.google.common.collect.Iterators;

public class JnarioIteratorExtensions {

	/**
     * Returns the element at the specified position in the arguments.
     *
     * @param index index of the element to return
     * @return the element at the specified position in this argument list
     * @throws IndexOutOfBoundsException if the index is out of range
     *         (index < 0 || index >= size())
     */
	public static  T  get(Iterator iterator, int index){
		return Iterators.get(iterator, index);
	}
	
	/**
	 * @return the first argument
	 */
	public static  T first(Iterator iterator){
		return get(iterator, 0);
	}
	
	/**
	 * @return the second argument
	 */
	public static  T  second(Iterator iterator){
		return  get(iterator, 1);
	}
	
	/**
	 * @return the third argument
	 */
	public static  T  third(Iterator iterator){
		return  get(iterator, 2);
	}
	
	/**
	 * @return the forth argument
	 */
	public static  T  forth(Iterator iterator){
		return  get(iterator, 3);
	}
	
	/**
	 * @return the fifth argument
	 */
	public static  T  fifth(Iterator iterator){
		return get(iterator, 4);
	}
	
	/**
	 * @return the first argument with the specified type
	 */
	public static  T first(Iterator iterator, Class type){
		return first(filter(iterator, type));
	}
	
	/**
	 * @return the second argument with the specified type
	 */
	public static  T  second(Iterator iterator, Class type){
		return  second(filter(iterator, type));
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy