private @NotNull <T> Consumer<T> onValidThread(@NotNull Consumer<? super T> consumer) {
    return value -> onValidThread(() -> consumer.accept(value));
  }
private @NotNull <T> Consumer<T> onValidThread(@NotNull Consumer<? super T> consumer)