com.github.dakusui.printables.Printables Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of actionunit Show documentation
Show all versions of actionunit Show documentation
A library to build 'action' structure for testing
package com.github.dakusui.printables;
import java.util.Map;
import java.util.Objects;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Predicate;
import static com.github.dakusui.actionunit.utils.InternalUtils.summary;
public enum Printables {
;
public static Predicate isEmptyString() {
return printablePredicate(String::isEmpty).describe("isEmptyString");
}
public static PrintablePredicate.Builder printablePredicate(Predicate predicate) {
return new PrintablePredicate.Builder<>(predicate);
}
public static PrintableConsumer.Builder printableConsumer(Consumer consumer) {
return new PrintableConsumer.Builder<>(consumer);
}
public static PrintableFunction.Builder printableFunction(Function function) {
return new PrintableFunction.Builder<>(function);
}
public static Predicate isKeyOf(Map values) {
return printablePredicate((Predicate) values::containsKey)
.describe(() -> String.format("isKeyOf[%s]", summary(values.toString())));
}
public static Predicate isEqualTo(T value) {
return printablePredicate((Predicate) v -> Objects.equals(v, value))
.describe(() -> String.format("is[%s]", value));
}
}