ArrayUtils used instead of checking for null and empty
@@ -17,6 +17,7 @@ import greencity.enums.TagType;
import greencity.exception.exceptions.BadRequestException;
import greencity.repository.EventRepo;
import lombok.RequiredArgsConstructor;
+import org.apache.commons.lang3.ArrayUtils;
import org.modelmapper.ModelMapper;
import org.modelmapper.TypeToken;
import org.springframework.data.domain.Page;
@@ -192,7 +193,7 @@ public class EventServiceImpl implements EventService {
}
private void updateImages(Event toUpdate, UpdateEventDto updateEventDto, MultipartFile[] images) {
- if ((images == null || images.length == 0) && updateEventDto.getImagesToDelete() == null) {
+ if (ArrayUtils.isEmpty(images) && updateEventDto.getImagesToDelete() == null) {
changeOldImagesWithoutRemovingAndAdding(toUpdate, updateEventDto);
} else if (images == null || images.length == 0) {
deleteOldImages(toUpdate, updateEventDto);
