我不能正确地使用这种 map 方法.我需要指定通用Think<R>
,但在哪里?
public class Think<T> implements Supplier<T> {
private Supplier<T> supplier;
public Think(Supplier<T> expression) {
this.supplier = () -> evaluate(expression);
}
public static <T> Think<T> of(T value) {
return new Think<>(() -> value);
}
private synchronized T evaluate(Supplier<T> expression) {
this.supplier = expression;
return this.supplier.get();
}
@Override
public T get() {
return this.supplier.get();
}
public <R> Think<R> map(Function<? super T, ? extends R> mapper) {
return Think.of(() -> mapper.apply(get()));
}
yield 率
incompatible types: cannot infer type-variable(s) T (argument mismatch; R is not a functional interface)
个