Java 如何修复方法引用中的错误返回类型:无法将RecipeIndicatorsDto转换为R?

Java 如何修复方法引用中的错误返回类型:无法将RecipeIndicatorsDto转换为R?,java,Java,如何修复下面的错误 方法引用中的返回类型错误:无法将RecipeIndicatorsDto转换为R 谢谢各位 public List<RecipeIndicatorsDto> listByUploadTime(LocalDateTime localDateTime) { if(localDateTime!=null) { QRecipeIndicator qRecipeIndicator = recipeIndicatorRepo.getQEntity();

如何修复下面的错误

方法引用中的返回类型错误:无法将RecipeIndicatorsDto转换为R

谢谢各位

public List<RecipeIndicatorsDto> listByUploadTime(LocalDateTime localDateTime) {
    if(localDateTime!=null) {
        QRecipeIndicator qRecipeIndicator = recipeIndicatorRepo.getQEntity();
        QOrder qOrder=orderRepo.getQEntity();
        List<Predicate> predicates = new ArrayList<>();
        predicates.add(qRecipeIndicator.uploadTime.before(localDateTime));
        List<RecipeIndicator> recipeIndicators = recipeIndicatorRepo.find(predicates, new PageRequest(0, 100));
        List<Order> orders=orderRepo.find(null,new PageRequest(0,100));
        return recipeIndicators.stream()
                               .map(DtoFactory::recipeIndicatorsDto)
                               .collect(Collectors.toList());
公共列表listByUploadTime(LocalDateTime LocalDateTime){
if(localDateTime!=null){
QRecipeIndicator QRecipeIndicator=RecipeIndicator或repo.getQEntity();
QOrder QOrder=orderepo.getQEntity();
列表谓词=新的ArrayList();
add(qRecipeIndicator.uploadTime.before(localDateTime));
List recipeIndicators=recipeIndicatorRepo.find(谓词,new PageRequest(01100));
List orders=orderepo.find(null,new PageRequest(0100));
返回recipeIndicators.stream()
.map(数据接口::recipeIndicatorsDto)
.collect(Collectors.toList());
公共静态收件人指示器DTO收件人指示器DTO(收件人指示器收件人指示器,订单){ if(recipeIndicator!=null&&order!=null){ RecipeiveIndicatorSDTO RecipeiveIndicatorSDTO=新RecipeiveIndicatorSDTO(); recipeIndicatorsDto.setVerificationStatus(recipeIndicator.getVerificationStatus());
recipeIndicator.setUploadTime(recipeIndicator.getUploadTime()); recipeIndicatorsDto.setRemark(order.getRemark());
recipeIndicatorsDto.setUseDays(order.getUseDays());

DTOFATORY::recipeIndicatorsDto
是对静态方法的方法引用,该静态方法需要
RecipeIndicator
参数和
order
参数。 由于要将其传递给
流的
映射
,因此只有
RecipeIndicator
实例可用

您可以改用lambda表达式:

.map(recipeIndicator -> DtoFactory.recipeIndicatorsDto(recipeIndicator, qOrder))

我不确定要传递给它的是哪个
Order
实例。我猜它可能是
qOrder

谢谢你,但我想要一个Order实例。这是对上述代码的补充。@awu订单实例来自哪里?你可以用引用相关订单实例。