StreamUtil.java 410 B

12345678910111213141516
  1. package com.persagy.fm.scheduling.utils;
  2. import java.util.function.Consumer;
  3. import java.util.function.Predicate;
  4. public interface StreamUtil {
  5. static <T> void actionWhen(T t, Predicate<T> condition, Consumer<T> consumer) {
  6. if (condition.test(t)) consumer.accept(t);
  7. }
  8. static <T> void actionWhen(T t, Boolean flag, Consumer<T> consumer) {
  9. if (flag) consumer.accept(t);
  10. }
  11. }