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

com.googlecode.functionalcollections.FunctionalIterable Maven / Gradle / Ivy

package com.googlecode.functionalcollections;

import java.util.Collection;
import java.util.List;
import java.util.NoSuchElementException;

import javax.annotation.Nullable;

import com.google.common.base.Function;
import com.google.common.base.Predicate;
import com.google.common.collect.Iterables;


/**
 * Functional extension of {@link Iterable}, most methods are simple wrapper of {@link Iterables}.
 * 
 * @author James Wang
 * @see Iterable
 * @see Iterables
 * 
 */
public interface FunctionalIterable extends Iterable {
	
	FunctionalIterable each(Block block);

	boolean any(Predicate predicate);
	
	boolean all(Predicate predicate);
	
	/**
	 * @see Iterables#find(Iterable, Predicate)
	 * @see #detect(Predicate)
	 */
	F find(Predicate predicate) throws NoSuchElementException;

	/**
	 * Returns the first element in that satisfies the given predicate, null
	 * if no element satisfies.
	 * @see #find(Predicate)
	 */
	F detect(Predicate predicate);
	
	FunctionalIterable filter(Predicate predicate);

	 FunctionalIterable transform(Function function);

	 M inject(M initial, Injector injector);
	
	int size();
	
	boolean contains(Object element);
	
	boolean removeAll(Collection elementsToRemove);
	
	boolean retainAll(Collection elementsToRetain);
	
	boolean elementsEqual(Iterable target);
	
	String toString();
	
	F getOnlyElement();
	
	F getOnlyElement(@Nullable F defaultValue);
	
	F[] toArray(Class type);
	
	Collection toCollection();
	
	int frequency(Object element);
	
	FunctionalIterable cycle();
	
	FunctionalIterable contat(Iterable target);
	
	FunctionalIterable> partition(int size);
	
	FunctionalIterable> paddedPartition(int size);
	
	F get(int position);
	
	F getLast();
	
	boolean isEmpty();

//	FunctionalIterable flatten();

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy