Skip to content

Commit ac588bb

Browse files
authored
๐Ÿš€ 2๋‹จ๊ณ„ - ์ˆ˜๊ฐ•์‹ ์ฒญ(๋„๋ฉ”์ธ ๋ชจ๋ธ) (#793)
* refactor : ๊ธฐ์กด ์ฝ”๋“œ ๋ฉ”์„œ๋“œ๋ช… ๋ณ€๊ฒฝ ์‚ญ์ œ ๊ฐ€๋Šฅ ์—ฌ๋ถ€ -> ์‚ญ์ œ * refactor : updatedDelete() ๋ฉ”์„œ๋“œ ์‚ญ์ œ ํ›„ ๋ถ€๋ชจ ํด๋ž˜์Šค์—์„œ ๋ฐ”๋กœ ์‚ฌ์šฉ * refactor : questionBody ํด๋ž˜์Šค ์žฌ๊ตฌ์„ฑ ๋ฐ ์ฃผ์ž… ํด๋ž˜์Šค ์ˆ˜์ • * docs : ๊ธฐ๋Šฅ ์š”๊ตฌ์‚ฌํ•ญ, ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์š”๊ตฌ์‚ฌํ•ญ ์ž‘์„ฑ * feat : CoverImage ํด๋ž˜์Šค ์ƒ์„ฑ ๋ฐ ํ…Œ์ŠคํŠธ ์ฝ”๋“œ ์ž‘์„ฑ * refactor : ์ด๋ฏธ์ง€ ์‚ฌ์ด์ฆˆ ๊ด€๋ จ ํด๋ž˜์Šค ๋ถ„๋ฆฌ ๋ฐ ํ…Œ์ŠคํŠธ ์ฝ”๋“œ ์ด๋™ * feat : Payment ํด๋ž˜์Šค ํ…Œ์ŠคํŠธ์ฝ”๋“œ ์ž‘์„ฑ * feat : ๊ฐ•์˜ ํด๋ž˜์Šค ์ƒ์„ฑ ๋ฐ ํ…Œ์ŠคํŠธ ์ฝ”๋“œ ์ž‘์„ฑ, ๋‚ด๋ถ€ ํ•„์š”ํ•œ ๊ฐ’ ํฌ์žฅํ•˜์—ฌ ํด๋ž˜์Šค๋กœ ๋ถ„๋ฆฌ, Enum์œผ๋กœ ๊ฐ•์˜ ํƒ€์ž…, ์ƒํƒœ ๊ด€๋ฆฌ * feat : ์ˆ˜๊ฐ• ์‹ ์ฒญ ๊ด€๋ฆฌ ๊ฐ์ฒด ์ƒ์„ฑ ๋ฐ ํ…Œ์ŠคํŠธ ์ฝ”๋“œ ์ž‘์„ฑ * refactor : tuition ๊ฐ์ฒด ๋ถ„๋ฆฌ ๋ฐ ํ…Œ์ŠคํŠธ ์ฝ”๋“œ ์ˆ˜์ • * refactor : ์ˆ˜๊ฐ•์ธ์› ๊ฐ์ฒด ๋ถ„๋ฆฌ ๋ฐ ํ…Œ์ŠคํŠธ ์ฝ”๋“œ ์ˆ˜์ • * refactor : SessionStatus from ๋ฉ”์„œ๋“œ StreamAPI๋กœ ๋ณ€๊ฒฝ * refactor : SessionType from ๋ฉ”์„œ๋“œ StreamAPI๋กœ ๋ณ€๊ฒฝ * refactor : SessionPolicy, SessionCore ํด๋ž˜์Šค ์ƒ์„ฑ ๋ฐ ํ…Œ์ŠคํŠธ ์ฝ”๋“œ ์ˆ˜์ • * refactor : ์ˆ˜๊ฐ•์‹ ์ฒญ ๋ชฉ๋ก ํด๋ž˜์Šค ์ƒ์„ฑ ํ›„ ํฌ์žฅ * feat : ํ…Œ์ŠคํŠธ ํ•„์š”ํ•œ builder ํด๋ž˜์Šค ์ƒ์„ฑ refactor : builder ์ ์šฉํ•˜์—ฌ ํ…Œ์ŠคํŠธ ์ฝ”๋“œ ์ˆ˜์ •
1 parent ccfcd53 commit ac588bb

35 files changed

+1004
-36
lines changed

โ€ŽREADME.mdโ€Ž

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## ๋‹จ๊ณ„๋ณ„ ๋ฌธ์„œ
44
- [๐Ÿš€ 1๋‹จ๊ณ„ - ๋ ˆ๊ฑฐ์‹œ ์ฝ”๋“œ ๋ฆฌํŒฉํ„ฐ๋ง](./docs/01-refactoring.md)
5+
- [๐Ÿš€ 2๋‹จ๊ณ„ - ์ˆ˜๊ฐ•์‹ ์ฒญ(๋„๋ฉ”์ธ ๋ชจ๋ธ)](./docs/02-lms-domain-model.md)
56

67
## ์ง„ํ–‰ ๋ฐฉ๋ฒ•
78
* ํ•™์Šต ๊ด€๋ฆฌ ์‹œ์Šคํ…œ์˜ ์ˆ˜๊ฐ•์‹ ์ฒญ ์š”๊ตฌ์‚ฌํ•ญ์„ ํŒŒ์•…ํ•œ๋‹ค.
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# ๐Ÿš€ 2๋‹จ๊ณ„ - ์ˆ˜๊ฐ•์‹ ์ฒญ(๋„๋ฉ”์ธ ๋ชจ๋ธ)
2+
***
3+
4+
## ์ฝ”๋“œ ๋ฆฌ๋ทฐ
5+
> PR ๋งํฌ :
6+
7+
## ๋‚˜์˜ ํ•™์Šต ๋ชฉํ‘œ
8+
9+
### 1. ๊ฐ์ฒด ์ค‘์‹ฌ์˜ ์„ค๊ณ„๋ฅผ ํ•ด๋ณด์ž.
10+
- ์š”๊ตฌ์‚ฌํ•ญ์„ ์ •ํ™•ํžˆ ๋ถ„์„ํ•˜๊ณ , TDD ์‚ฌ์ดํด์„ ํ†ตํ•ด ๊ฐ์ฒด์˜ ํ•ต์‹ฌ ๋น„์ฆˆ๋‹ˆ์Šค ๋กœ์ง์„ ์šฐ์„ ์ ์œผ๋กœ ๋งŒ๋“ค์–ด๋ณด์ž.
11+
- ๊ทธ ์ดํ›„ ๊ฐ์ฒด๋ฅผ ์กฐ๋ฆฝํ•˜๋ฉฐ, ๋ฆฌํŒฉํ„ฐ๋ง ํ•ด๋ณด์ž.
12+
13+
### 1. TDD ์‚ฌ์ดํด์„ ์˜์‹ํ•˜๋ฉฐ ๊ธฐ๋Šฅ์„ ๊ตฌํ˜„ํ•œ๋‹ค.
14+
- `์‹คํŒจ โ†’ ์„ฑ๊ณต โ†’ ๋ฆฌํŒฉํ„ฐ๋ง` ๊ณผ์ •์œผ๋กœ ์ž‘์—…ํ•œ๋‹ค.
15+
- ์Šต๊ด€์ฒ˜๋Ÿผ ์ด ๊ณผ์ •์„ ์ง€๋‚˜์น˜๋ฉด, ๋‹ค์‹œ ๋Œ์•„์™€ ์‚ฌ์ดํด์„ ๋ฐ˜๋ณตํ•œ๋‹ค.
16+
- TDD ์‚ฌ์ดํด ์Šต๊ด€์„ ๋งŒ๋“ค์ž.
17+
18+
## ์ˆ˜๊ฐ„ ์‹ ์ฒญ ๊ธฐ๋Šฅ ์š”๊ตฌ์‚ฌํ•ญ
19+
20+
- [x] ๊ณผ์ •(Course)์€ ๊ธฐ์ˆ˜ ๋‹จ์œ„๋กœ ์šด์˜ํ•˜๋ฉฐ, ์—ฌ๋Ÿฌ ๊ฐœ์˜ ๊ฐ•์˜(Session)๋ฅผ ๊ฐ€์งˆ ์ˆ˜ ์žˆ๋‹ค.
21+
- [x] ๊ฐ•์˜๋Š” ์‹œ์ž‘์ผ๊ณผ ์ข…๋ฃŒ์ผ์„ ๊ฐ€์ง„๋‹ค.
22+
- [x] ๊ฐ•์˜๋Š” ๊ฐ•์˜ ์ปค๋ฒ„ ์ด๋ฏธ์ง€ ์ •๋ณด๋ฅผ ๊ฐ€์ง„๋‹ค.
23+
- [x] ์ด๋ฏธ์ง€ ํฌ๊ธฐ๋Š” 1MB ์ดํ•˜์—ฌ์•ผ ํ•œ๋‹ค.
24+
- [x] ์ด๋ฏธ์ง€ ํƒ€์ž…์€ gif, jpg(jpeg ํฌํ•จ), png, svg๋งŒ ํ—ˆ์šฉํ•œ๋‹ค.
25+
- [x] ์ด๋ฏธ์ง€์˜ width๋Š” 300px, height๋Š” 200px ์ด์ƒ์ด์–ด์•ผ ํ•˜๋ฉฐ, width์™€ height์˜ ๋น„์œจ์€ 3:2์—ฌ์•ผ ํ•œ๋‹ค.
26+
- [x] ๊ฐ•์˜๋Š” ๋ฌด๋ฃŒ ๊ฐ•์˜์™€ ์œ ๋ฃŒ ๊ฐ•์˜๋กœ ๋‚˜๋‰œ๋‹ค.
27+
- [x] ๋ฌด๋ฃŒ ๊ฐ•์˜๋Š” ์ตœ๋Œ€ ์ˆ˜๊ฐ• ์ธ์› ์ œํ•œ์ด ์—†๋‹ค.
28+
- [x] ์œ ๋ฃŒ ๊ฐ•์˜๋Š” ๊ฐ•์˜ ์ตœ๋Œ€ ์ˆ˜๊ฐ• ์ธ์›์„ ์ดˆ๊ณผํ•  ์ˆ˜ ์—†๋‹ค.
29+
- [x] ์œ ๋ฃŒ ๊ฐ•์˜๋Š” ์ˆ˜๊ฐ•์ƒ์ด ๊ฒฐ์ œํ•œ ๊ธˆ์•ก๊ณผ ์ˆ˜๊ฐ•๋ฃŒ๊ฐ€ ์ผ์น˜ํ•  ๋•Œ ์ˆ˜๊ฐ• ์‹ ์ฒญ์ด ๊ฐ€๋Šฅํ•˜๋‹ค.
30+
- [x] ๊ฐ•์˜ ์ƒํƒœ๋Š” ์ค€๋น„์ค‘, ๋ชจ์ง‘์ค‘, ์ข…๋ฃŒ 3๊ฐ€์ง€ ์ƒํƒœ๋ฅผ ๊ฐ€์ง„๋‹ค.
31+
- [x] ๊ฐ•์˜ ์ˆ˜๊ฐ•์‹ ์ฒญ์€ ๊ฐ•์˜ ์ƒํƒœ๊ฐ€ ๋ชจ์ง‘์ค‘์ผ ๋•Œ๋งŒ ๊ฐ€๋Šฅํ•˜๋‹ค.
32+
- [x] ์œ ๋ฃŒ ๊ฐ•์˜์˜ ๊ฒฝ์šฐ ๊ฒฐ์ œ๋Š” ์ด๋ฏธ ์™„๋ฃŒํ•œ ๊ฒƒ์œผ๋กœ ๊ฐ€์ •ํ•˜๊ณ  ์ดํ›„ ๊ณผ์ •์„ ๊ตฌํ˜„ํ•œ๋‹ค.
33+
- [x] ๊ฒฐ์ œ๋ฅผ ์™„๋ฃŒํ•œ ๊ฒฐ์ œ ์ •๋ณด๋Š” payments ๋ชจ๋“ˆ์„ ํ†ตํ•ด ๊ด€๋ฆฌ๋˜๋ฉฐ, ๊ฒฐ์ œ ์ •๋ณด๋Š” Payment ๊ฐ์ฒด์— ๋‹ด๊ฒจ ๋ฐ˜ํ•œ๋œ๋‹ค.
34+
35+
## ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์š”๊ตฌ์‚ฌํ•ญ
36+
37+
- DB ํ…Œ์ด๋ธ” ์„ค๊ณ„ ์—†์ด ๋„๋ฉ”์ธ ๋ชจ๋ธ๋ถ€ํ„ฐ ๊ตฌํ˜„ํ•œ๋‹ค.
38+
- ๋„๋ฉ”์ธ ๋ชจ๋ธ์€ TDD๋กœ ๊ตฌํ˜„ํ•œ๋‹ค.
39+
- ๋‹จ, Service ํด๋ž˜์Šค๋Š” ๋‹จ์œ„ ํ…Œ์ŠคํŠธ๊ฐ€ ์—†์–ด๋„ ๋œ๋‹ค.
40+
- ๋‹ค์Œ ๋™์˜์ƒ์„ ์ฐธ๊ณ ํ•ด DB ํ…Œ์ด๋ธ”๋ณด๋‹ค ๋„๋ฉ”์ธ ๋ชจ๋ธ์„ ๋จผ์ € ์„ค๊ณ„ํ•˜๊ณ  ๊ตฌํ˜„ํ•œ๋‹ค.
41+
- https://youtu.be/VjbBGjVRxfk

โ€Žsrc/main/java/nextstep/courses/domain/Course.javaโ€Ž

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
package nextstep.courses.domain;
22

3+
import nextstep.courses.domain.session.Session;
4+
35
import java.time.LocalDateTime;
6+
import java.util.ArrayList;
7+
import java.util.List;
48

59
public class Course {
610
private Long id;
@@ -13,6 +17,8 @@ public class Course {
1317

1418
private LocalDateTime updatedAt;
1519

20+
private List<Session> sessions = new ArrayList<>();
21+
1622
public Course() {
1723
}
1824

@@ -28,6 +34,10 @@ public Course(Long id, String title, Long creatorId, LocalDateTime createdAt, Lo
2834
this.updatedAt = updatedAt;
2935
}
3036

37+
public void addSession(Session session) {
38+
this.sessions.add(session);
39+
}
40+
3141
public String getTitle() {
3242
return title;
3343
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package nextstep.courses.domain.image;
2+
3+
import nextstep.courses.domain.image.constant.ImageType;
4+
5+
public class CoverImage {
6+
7+
public static final double MAX_FILE_SIZE = 1024 * 1024; // 1MB
8+
9+
private final long size;
10+
private final ImageType type;
11+
private final ImageDimentsion dimentsion;
12+
13+
public CoverImage(long size, String type, int width, int height) {
14+
this(size, ImageType.fromName(type.toUpperCase()), width, height);
15+
}
16+
17+
public CoverImage(long size, ImageType type, int width, int height) {
18+
this(size, type, new ImageDimentsion(width, height));
19+
}
20+
21+
public CoverImage(long size, ImageType type, ImageDimentsion dimentsion) {
22+
validateFileSize(size);
23+
this.size = size;
24+
this.type = type;
25+
this.dimentsion = dimentsion;
26+
}
27+
28+
private void validateFileSize(long size) {
29+
if (size > MAX_FILE_SIZE) {
30+
throw new IllegalArgumentException("์ด๋ฏธ์ง€ ์‚ฌ์ด์ฆˆ๋Š” 1MB ์ดํ•˜๋งŒ ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค.");
31+
}
32+
}
33+
34+
public long getSize() {
35+
return size;
36+
}
37+
38+
public ImageType getType() {
39+
return type;
40+
}
41+
42+
43+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package nextstep.courses.domain.image;
2+
3+
public class ImageDimentsion {
4+
5+
public static final int MIN_WIDTH = 300;
6+
public static final int MIN_HEIGHT = 200;
7+
public static final double ASPECT_RATIO = 1.5;
8+
9+
private final int width;
10+
private final int height;
11+
12+
public ImageDimentsion(int width, int height) {
13+
validateSize(width, height);
14+
validateRatio(width, height);
15+
this.width = width;
16+
this.height = height;
17+
}
18+
19+
private void validateRatio(int width, int height) {
20+
double ratio = (double) width / height;
21+
if (ratio != ASPECT_RATIO) {
22+
throw new IllegalArgumentException("3:2 ๋น„์œจ๋กœ ๋‹ค์‹œ ์—…๋กœ๋“œ ํ•ด์ฃผ์„ธ์š”.");
23+
}
24+
}
25+
26+
private void validateSize(int width, int height) {
27+
if (isSize(width, height)) {
28+
throw new IllegalArgumentException("๋„ˆ๋น„๋Š” 300px, ๋†’์ด๋Š” 200px ์ด์ƒ์ด์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.");
29+
}
30+
}
31+
32+
private static boolean isSize(int width, int height) {
33+
return width < MIN_WIDTH || height < MIN_HEIGHT;
34+
}
35+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package nextstep.courses.domain.image.constant;
2+
3+
public enum ImageType {
4+
GIF,
5+
JPG,
6+
JPEG,
7+
PNG,
8+
SVG;
9+
10+
public static ImageType fromName(String name){
11+
for (ImageType type : ImageType.values()) {
12+
if(type.name().equals(name)){
13+
return type;
14+
}
15+
}
16+
throw new IllegalArgumentException("์ด๋ฏธ์ง€ ํƒ€์ž…์„ ๋‹ค์‹œ ํ™•์ธํ•ด์ฃผ์„ธ์š”.");
17+
}
18+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package nextstep.courses.domain.session;
2+
3+
import java.util.Objects;
4+
5+
public class Capacity {
6+
7+
private int value;
8+
9+
public Capacity(int value) {
10+
this.value = value;
11+
}
12+
13+
public int getValue() {
14+
return value;
15+
}
16+
17+
public boolean matchSize(int enrollmentsSize) {
18+
return this.value <= enrollmentsSize;
19+
}
20+
21+
@Override
22+
public boolean equals(Object o) {
23+
if (o == null || getClass() != o.getClass()) return false;
24+
Capacity capacity = (Capacity) o;
25+
return value == capacity.value;
26+
}
27+
28+
@Override
29+
public int hashCode() {
30+
return Objects.hashCode(value);
31+
}
32+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package nextstep.courses.domain.session;
2+
3+
import nextstep.payments.domain.Payment;
4+
import nextstep.users.domain.NsUser;
5+
6+
import java.util.Objects;
7+
8+
public class Enrollment {
9+
10+
private final NsUser user;
11+
private final Long sessionId;
12+
private final Payment payment;
13+
14+
public Enrollment(NsUser user, Long sessionId, Payment payment) {
15+
this.user = user;
16+
this.sessionId = sessionId;
17+
this.payment = payment;
18+
}
19+
20+
public void isPaymentAmount(SessionPolicy sessionPolicy) {
21+
if(sessionPolicy.matchAmount(payment)){
22+
throw new IllegalArgumentException("๊ฐ•์˜ ๊ธˆ์•ก๊ณผ ๊ฒฐ์ œ ๊ธˆ์•ก์ด ์ผ์น˜ํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.");
23+
}
24+
}
25+
26+
@Override
27+
public boolean equals(Object o) {
28+
if (o == null || getClass() != o.getClass()) return false;
29+
Enrollment that = (Enrollment) o;
30+
return Objects.equals(user.getId(), that.user.getId()) && Objects.equals(sessionId, that.sessionId);
31+
}
32+
33+
@Override
34+
public int hashCode() {
35+
return Objects.hash(user, sessionId, payment);
36+
}
37+
38+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package nextstep.courses.domain.session;
2+
3+
import java.util.ArrayList;
4+
import java.util.List;
5+
6+
public class Enrollments {
7+
8+
private final List<Enrollment> enrollments = new ArrayList<>();
9+
10+
public void add(Enrollment enrollment) {
11+
validateNotDuplicate(enrollment);
12+
this.enrollments.add(enrollment);
13+
}
14+
15+
public int size() {
16+
return this.enrollments.size();
17+
}
18+
19+
private void validateNotDuplicate(Enrollment enrollment) {
20+
if (this.enrollments.contains(enrollment)) {
21+
throw new IllegalArgumentException("์ด๋ฏธ ์‹ ์ฒญํ•œ ๊ฐ•์˜์ž…๋‹ˆ๋‹ค.");
22+
}
23+
}
24+
25+
@Override
26+
public String toString() {
27+
return "Enrollments{" +
28+
"enrollments=" + enrollments +
29+
'}';
30+
}
31+
}
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
package nextstep.courses.domain.session;
2+
3+
import nextstep.courses.domain.image.CoverImage;
4+
import nextstep.courses.domain.session.constant.SessionStatus;
5+
import nextstep.courses.domain.session.constant.SessionType;
6+
7+
import java.time.LocalDateTime;
8+
import java.util.Objects;
9+
10+
public class Session extends SessionCore {
11+
12+
private final Long id;
13+
private final CoverImage coverImage;
14+
private final Enrollments enrollments;
15+
16+
public Session(Long id, LocalDateTime startDate, LocalDateTime endDate, String sessionType, String sessionStatus, CoverImage coverImage) {
17+
this(id, startDate, endDate, sessionType, Integer.MAX_VALUE, 0L, sessionStatus, coverImage);
18+
}
19+
20+
public Session(Long id, LocalDateTime startDate, LocalDateTime endDate, String sessionType, int maxCapacity, Long tuition, String sessionStatus, CoverImage coverImage) {
21+
this(id, startDate, endDate, SessionType.from(sessionType.toUpperCase()), maxCapacity, tuition, SessionStatus.from(sessionStatus.toUpperCase()), coverImage);
22+
}
23+
24+
public Session(Long id, LocalDateTime startDate, LocalDateTime endDate, SessionType sessionType, int maxCapacity, Long tuition, SessionStatus sessionStatus, CoverImage coverImage) {
25+
this(id, new SessionRange(startDate, endDate), sessionType, new Capacity(maxCapacity), new Tuition(tuition), sessionStatus, coverImage);
26+
}
27+
28+
public Session(Long id, SessionRange sessionRange, SessionType sessionType, Capacity maxCapacity, Tuition tuition, SessionStatus sessionStatus, CoverImage coverImage) {
29+
this(id, sessionRange, new SessionPolicy(maxCapacity, tuition, sessionType), sessionStatus, coverImage);
30+
}
31+
32+
public Session(Long id, SessionRange sessionRange, SessionPolicy sessionPolicy, SessionStatus sessionStatus, CoverImage coverImage) {
33+
super(sessionRange, sessionPolicy, sessionStatus);
34+
this.id = id;
35+
this.coverImage = coverImage;
36+
this.enrollments = new Enrollments();
37+
}
38+
39+
public Session(Long id, SessionRange sessionRange, SessionPolicy sessionPolicy, SessionStatus sessionStatus, CoverImage coverImage, Enrollments enrollments) {
40+
super(sessionRange, sessionPolicy, sessionStatus);
41+
this.id = id;
42+
this.coverImage = coverImage;
43+
this.enrollments = enrollments;
44+
}
45+
46+
public void addEnrollment(Enrollment enrollment) {
47+
validatePaymentAmount(enrollment);
48+
validateNotFull(this.enrollments);
49+
validateSessionStatus();
50+
this.enrollments.add(enrollment);
51+
}
52+
53+
@Override
54+
public boolean equals(Object o) {
55+
if (o == null || getClass() != o.getClass()) return false;
56+
Session session = (Session) o;
57+
return Objects.equals(id, session.id) && Objects.equals(coverImage, session.coverImage) && Objects.equals(enrollments, session.enrollments);
58+
}
59+
60+
@Override
61+
public int hashCode() {
62+
return Objects.hash(id, coverImage, enrollments);
63+
}
64+
65+
@Override
66+
public String toString() {
67+
return "Session{" +
68+
"id=" + id +
69+
", coverImage=" + coverImage +
70+
", enrollments=" + enrollments +
71+
'}';
72+
}
73+
}

0 commit comments

Comments
ย (0)