I have a list inside the list have many objects. every objects has selectedDates as list of String. now i want all the objects of selectedDates in a list. I tried but it is showing the following error. please help me with it. Error:
Type mismatch: cannot convert from List<List<String>> to List<String>
Code:
PlacesListExperienceCartItem expList = cartItemListRepo.save(experienceListCart);
List<String> selectedDateList = expList.getExperienceList()
.stream()
.map(PlacesExperienceCartConfirmRequest::getSelectedDates)
.collect(Collectors.toList());
Bean:
public class PlacesListExperienceCartItem {
@Id
String id;
String customerId;
String placeId;
Double totalPrice;
List<PlacesExperienceCartConfirmRequest> experienceList;
private String bookingId;
private String name;
private String phone;
private String email;
private Location deliveryLocation;
private List<String> selectedDates;
public List<String> getSelectedDates() {
return selectedDates;
}
public void setSelectedDates(List<String> selectedDates) {
this.selectedDates = selectedDates;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getPlaceId() {
return placeId;
}
public void setPlaceId(String placeId) {
this.placeId = placeId;
}
public Double getTotalPrice() {
return totalPrice;
}
public void setTotalPrice(Double totalPrice) {
this.totalPrice = totalPrice;
}
public List<PlacesExperienceCartConfirmRequest> getExperienceList() {
return experienceList;
}
public void setExperienceList(List<PlacesExperienceCartConfirmRequest> experienceList) {
this.experienceList = experienceList;
}
public String getBookingId() {
return bookingId;
}
public void setBookingId(String bookingId) {
this.bookingId = bookingId;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public Location getDeliveryLocation() {
return deliveryLocation;
}
public void setDeliveryLocation(Location deliveryLocation) {
this.deliveryLocation = deliveryLocation;
}
public String getCustomerId() {
return customerId;
}
public void setCustomerId(String customerId) {
this.customerId = customerId;
}
}