Activiti7精讲&Java通用型工作流开发实战

128 阅读1分钟

Activiti7精讲&Java通用型工作流开发实战

V:ititit111222333

`public class FunctionInterface {

public static void main(String[] args) {

    //////////////////////////////////////////////////////////////////////////////
    consumerFunction("1", (consumer) -> System.out.println("消费了" + consumer + "元"));

    //////////////////////////////////////////////////////////////////////////////
    List<Integer> integers = supplierFunction(10, () -> (int) (Math.random() * 100));
    integers.forEach(System.out::println);

    //////////////////////////////////////////////////////////////////////////////
    String s = functionFunction("\t\t\t,     我一一iii  ", String::trim);
    System.out.println(s);

    //////////////////////////////////////////////////////////////////////////////
    boolean b = predicateFunction("111111111", "111111111"::equals);
    System.out.println(b);

}

/**
 * 消费型
 */
private static void consumerFunction(String str, Consumer<String> consumer) {
    consumer.accept(str);
}

/**
 * 供给型
 */
private static List<Integer> supplierFunction(int num, Supplier<Integer> supplier) {
    List<Integer> list = Lists.newArrayList();
    for (int i = 0; i < num; i++) {
        list.add(supplier.get());
    }
    return list;
}

/**
 * 函数型
 */
private static String functionFunction(String str, Function<String, String> function) {
    return function.apply(str);
}

/**
 * 函数型
 */
private static boolean predicateFunction(String str, Predicate<String> function) {
    return function.test(str);
}

}`