💠 정적 팩토리 메서드 패턴 (Static Factory Method)

정적 팩토리 메서드(Static Factory Method)

@Getter
@Setter
@AllArgsConstructor
public class ProposalDto {
  private Long id;

  private String buyerLoginId;
  private String sellerLoginId;

  private ProposalStatus proposalStatus;

  private String itemTitle;

  public static ProposalDto fromEntity(ProposalEntity entity) {
    return new ProposalDto(
      entity.getId(),
      entity.getBuyer().getLoginId(),
      entity.getSeller().getLoginId(),
      entity.getProposalStatus(),
      entity.getItem().getTitle()
    );
  }
}