鉴于下面的代码片段,我将如何使用 Vavr 不可变列表或流?我不能作为局部变量,因为无法将其标记为最终变量。我不想晋升List<CurvePoint> points
为班员。
import io.vavr.collection.List;
private RemoteFileTemplate template;
public <T> List<T> loadObjects(Class<T> type, InputStream stream) {...}
public List<CurvePoint> getCurvePoints(String path, FTPFile file) {
final List<CurvePoint> points = List.empty();
template.get(path + "/" + file.getName(), s -> {
// The final local variable points cannot be assigned. It must be blank and not using a compound assignment
points = points.appendAll(loadObjects(CurvePoint.class, s));
});
return points;
}
public class RemoteFileTemplate<F> implements RemoteFileOperations<F>, InitializingBean, BeanFactoryAware {
public boolean get(final String remotePath, final InputStreamCallback callback) {...}