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

com.softicar.platform.common.container.iterable.MappingIterable Maven / Gradle / Ivy

Go to download

The SoftiCAR Platform is a lightweight, Java-based library to create interactive business web applications.

There is a newer version: 50.0.0
Show newest version
package com.softicar.platform.common.container.iterable;

import com.softicar.platform.common.container.iterator.MappingIterator;
import java.util.Iterator;
import java.util.function.Function;

/**
 * An {@link Iterable} that maps the elements from one type to another.
 *
 * @author Oliver Richers
 */
public class MappingIterable implements Iterable {

	private final Iterable sourceIterable;
	private final Function mappingFunction;

	public MappingIterable(Iterable sourceIterable, Function mappingFunction) {

		this.sourceIterable = sourceIterable;
		this.mappingFunction = mappingFunction;
	}

	@Override
	public Iterator iterator() {

		return new MappingIterator<>(sourceIterable.iterator(), mappingFunction);
	}
}