io.virtdata.libbasics.shared.unary_string.StringFlow Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of virtdata-lib-realer Show documentation
Show all versions of virtdata-lib-realer Show documentation
With inspiration from other libraries
package io.virtdata.libbasics.shared.unary_string;
import io.virtdata.annotations.Categories;
import io.virtdata.annotations.Category;
import io.virtdata.annotations.ThreadSafeMapper;
import java.util.function.Function;
/**
* Combine multiple String functions together into one function.
*/
@Categories(Category.functional)
@ThreadSafeMapper
public class StringFlow implements Function {
private final Function[] funcs;
public StringFlow(Function... funcs) {
this.funcs = funcs;
}
@Override
public String apply(String s) {
String value = s;
for (Function func : funcs) {
value = func.apply(value);
}
return value;
}
}