My AssignedPropertiesDTO class is:
@Data
@Builder
@AllArgsConstructor
public class AssignedPropertiesDTO {
@JsonProperty("hotel_id")
private Long hotelId;
@JsonProperty("oyo_id")
private String oyoId;
@JsonProperty("drn")
private Integer dsrn;
@JsonProperty("is_sold_out")
private Boolean isSoldOut;
@JsonProperty("is_purged")
private Boolean isPurged;
AssignedPropertiesDTO() {
this.isSoldOut = false;
this.isPurged = false;
}
}
I need to set isSoldOut and isPurged to false. That is why i have made default constructor. But i am using Builder() for setting class fields and somewhere just setting properties using getter/setter.
AssignedPropertiesDTO matchingObject = assignedPropertiesDTOS.stream()
.filter(assignedPropertiesDTO -> assignedPropertiesDTO.getHotelId().equals(Long.valueOf(entry.getKey())))
.findFirst()
.orElse(null);
if (matchingObject == null) {
assignedPropertiesDTOS.add(AssignedPropertiesDTO
.builder()
.hotelId(Long.valueOf(entry.getKey()))
.dsrn(count)
.build()
);
} else {
matchingObject.setDsrn(count);
}
My requirement is to set Ispurged/IsSoldOut to either True/False But not NULL.
[
{
"hotel_id": 45693,
"oyo_id": "GOA2161",
"drn": null,
"is_sold_out": null,
"is_purged": null
},
{
"hotel_id": 45693,
"oyo_id": "GOA2161",
"drn": null,
"is_sold_out": true,
"is_purged": false
}
]
Please guide me how can i do this.