【发布时间】:2021-04-12 17:00:43
【问题描述】:
@JsonInclude(JsonInclude.Include.NON_NULL)
public class Flight implements Serializable {
private TrackInformation trackInformation;
private MiscData miscData;
private CargoItems cargoItems;
}
Controller class
@RequestMapping(value = "/getFlightByKey", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
public Flight getFlightByKey(@RequestBody @Valid final FlightInfoRequestDTO request)throws NoDataFoundException {
return flightInfoAppService.getFlightByKey(request.getKey());
}
公共类 TrackInformation 扩展 AbstractRecord {
private static final long serialVersionUID = -5226745652646434627L;
private String sourceFacility;
private ComputerID computerID;
private String sourceTimeStamp;
private Double latitude;
private Double longitude;
private ReportedAltitude reportedAltitude;
private Integer speed;
}
公共抽象类 AbstractRecord 实现 Serializable {
}
现在返回的飞行对象具有嵌套对象的空字段。如何忽略嵌套对象中的空字段。
在 TrackInformation 中覆盖了 hashCode 和 equals。
【问题讨论】:
-
你能显示嵌套类
TrackInformation吗?