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

net.intelie.pipes.ListModule Maven / Gradle / Ivy

There is a newer version: 0.25.5
Show newest version
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);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy