-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: refactor portfolio stock domain
- Loading branch information
Showing
3 changed files
with
37 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
domain/src/main/java/nexters/payout/domain/portfolio/domain/PortfolioStocks.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package nexters.payout.domain.portfolio.domain; | ||
|
||
import jakarta.persistence.CollectionTable; | ||
import jakarta.persistence.ElementCollection; | ||
import jakarta.persistence.Embeddable; | ||
import jakarta.persistence.JoinColumn; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
@NoArgsConstructor | ||
@Embeddable | ||
public class PortfolioStocks { | ||
|
||
@ElementCollection | ||
@CollectionTable(name = "portfolio_stock", joinColumns = @JoinColumn(name = "portfolio_id")) | ||
private List<PortfolioStock> portfolioStocks = new ArrayList<>(); | ||
|
||
public PortfolioStocks(List<PortfolioStock> stocks) { | ||
if (stocks.isEmpty()) { | ||
throw new IllegalArgumentException("portfolioStocks must not be empty"); | ||
} | ||
portfolioStocks = stocks; | ||
} | ||
|
||
public List<PortfolioStock> getPortfolioStocks() { | ||
return Collections.unmodifiableList(portfolioStocks); | ||
} | ||
} |