lombok 中註解@Builder
修飾類的時候,相關屬性欄位額外設定的預設值會失效,
如何解決這個問題:
- 在需要使用builder構造模式生產物件的時候,相關屬性上帶上@Builder.defalut 註解修飾就可以
範例
@AllArgsConstructor
@NoArgsConstructor
@Builder
@EqualsAndHashCode(callSuper = true)
@Data
@Accessors(chain = true)
public class JobDto extends DtoBase implements Serializable {
private static final long serialVersionUID = 8596680260100259008L;
private String jobId;
private String jobTypeCode;
private String sysName;
private String appName;
private JobStateEnum jobState;
private String templateId;
@Builder.Default
private Map<String, JobParamDto> jobParams = new HashMap<>();
/**
* preview 過程中傳入依賴用於生成程式碼
*/
@Builder.Default
private Map<String, List<DependencyDto>> dependencies = new HashMap<>(7);
}
}