I have the following
public class OfferService {
@Autowired
private OfferRepository offerRepository;
@Autowired
private ModelMapper modelMapper;
public OfferDto getById(Long id){
Offer offer = offerRepository.findById(id)
.orElseThrow(()-> new OfferException());
if(offer.getFim().isAfter(LocalDate.now()))
{
return modelMapper.map(offer, OfferDto.class);
}
return null;
}
}
So I would like to know how to create a class/interface, so I would replace that if-condition with something else. In fact, I would like to create a class that I could put all my if-statements and conditions.
Aucun commentaire:
Enregistrer un commentaire