Java 如何修复方法引用中的错误返回类型:无法将RecipeIndicatorsDto转换为R?
如何修复下面的错误 方法引用中的返回类型错误:无法将RecipeIndicatorsDto转换为R 谢谢各位Java 如何修复方法引用中的错误返回类型:无法将RecipeIndicatorsDto转换为R?,java,Java,如何修复下面的错误 方法引用中的返回类型错误:无法将RecipeIndicatorsDto转换为R 谢谢各位 public List<RecipeIndicatorsDto> listByUploadTime(LocalDateTime localDateTime) { if(localDateTime!=null) { QRecipeIndicator qRecipeIndicator = recipeIndicatorRepo.getQEntity();
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订单实例来自哪里?你可以用引用相关订单实例。