com.softicar.platform.common.container.iterable.MappingIterable Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of platform-common Show documentation
Show all versions of platform-common Show documentation
The SoftiCAR Platform is a lightweight, Java-based library to create interactive business web applications.
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);
}
}