net.intelie.pipes.ListModule Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of pipes-api Show documentation
Show all versions of pipes-api Show documentation
Intelie Pipes' API classes and interfaces
package net.intelie.pipes;
import net.intelie.pipes.util.Iterables;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.StreamSupport;
public class ListModule implements Module {
private static final long serialVersionUID = 1L;
private final Iterable functions;
private final String repr;
public ListModule(Function... functions) {
this(Arrays.asList(functions));
}
public ListModule(Iterable functions) {
this.functions = Collections.unmodifiableList(StreamSupport
.stream(functions.spliterator(), false)
.collect(Collectors.toList()));
this.repr = makeRepr(functions);
}
public static String makeRepr(Iterable functions) {
List repr = makeReprList(functions);
return "functions: " + Iterables.join(", ", repr);
}
public static List makeReprList(Iterable functions) {
List repr = new ArrayList<>();
for (Function function : functions) {
repr.add(function.description());
}
return repr;
}
@Override
public String toString() {
return repr;
}
@Override
public Iterable functions() {
return functions;
}
}