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.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
public class ListModule implements Module {
private static final long serialVersionUID = 1L;
private final List functions;
private final String repr;
public ListModule(Function... functions) {
this(Arrays.asList(functions));
}
public ListModule(List functions) {
this.functions = new ArrayList<>(functions);
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 Collections.unmodifiableList(functions);
}
}