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.Iterator;
import java.util.List;
import java.util.NoSuchElementException;
import java.util.Set;

import javax.annotation.Nullable;

import com.google.common.base.Function;
import com.google.common.base.Joiner;
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);
	
	/**
	 * 
	 * Alias method of {@link #filter(Predicate)}.
	 * 
	 */
	FunctionalIterable select(Predicate predicate);
	
	FunctionalIterable filter(Predicate predicate);

	/**
	 * Alias method of {@link #transform(Function)}.
	 */
	 FunctionalIterable map(Function function);
	
	 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);
	
	boolean elementsEqual(Iterable target, EqualDelegate equalDelegate);
	
	String toString();
	
	F getOnlyElement();
	
	F getOnlyElement(@Nullable F defaultValue);
	
	F[] toArray(Class type);
	
	Collection toCollection();
	
	List toList();
	
	Set toSet();
	
	int frequency(Object element);
	
	FunctionalIterable uniq();
	
	FunctionalIterable cycle();
	
	FunctionalIterable reverse();
	
	FunctionalIterable concat(Iterable target);
	
	FunctionalIterable concat(F... target);
	
	FunctionalIterable> partition(int size);
	
	FunctionalIterable> paddedPartition(int size);
	
	F get(int position);
	
	F getLast();
	
	boolean isEmpty();

	Iterator messagedIterator(String messageOnLast);
	
	/**
	 * @see Joiner
	 * @see #join(JoinSpecification)
	 */
	String join(String separator);
	
	/**
	 * @see Joiner
	 */
	String join(Joiner joiner);


//	FunctionalIterable flatten();

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy