Skip to content

Commit 66e6c1c

Browse files
author
seungjoo.jeong
committed
fix(revice) 리뷰반영
- 클래스 내 선언순서 조정
1 parent baa9ff9 commit 66e6c1c

File tree

5 files changed

+52
-42
lines changed

5 files changed

+52
-42
lines changed

src/main/java/kitchenpos/product/application/ProductDTO.java

+10
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import static com.google.common.base.Preconditions.checkArgument;
44

5+
import com.google.common.base.MoreObjects;
56
import java.util.UUID;
67
import kitchenpos.product.domain.ProductName;
78
import kitchenpos.product.domain.ProductNew;
@@ -20,4 +21,13 @@ public ProductDTO(final ProductNew entity) {
2021
price = entity.getPrice();
2122
name = entity.getName();
2223
}
24+
25+
@Override
26+
public String toString() {
27+
return MoreObjects.toStringHelper(this)
28+
.add("id", id)
29+
.add("price", price)
30+
.add("name", name)
31+
.toString();
32+
}
2333
}

src/main/java/kitchenpos/product/domain/Name.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,6 @@ public Name(final String value) {
1515
this.value = value;
1616
}
1717

18-
public String getValue() {
19-
return value;
20-
}
21-
2218
@Override
2319
public boolean equals(final Object o) {
2420
if (this == o) {
@@ -35,4 +31,8 @@ public boolean equals(final Object o) {
3531
public int hashCode() {
3632
return Objects.hashCode(value);
3733
}
34+
35+
public String getValue() {
36+
return value;
37+
}
3838
}

src/main/java/kitchenpos/product/domain/ProductName.java

+13-14
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,27 @@ public class ProductName {
1010

1111
private String value;
1212

13+
protected ProductName() {
14+
}
15+
16+
private ProductName(final Name name) {
17+
this.value = name.getValue();
18+
}
19+
1320
public static ProductName of(final Name name) {
1421
checkArgument(name != null, "name must be not null. value: %s", name);
1522

1623
return new ProductName(name);
1724
}
1825

19-
public ProductName() {
20-
}
21-
2226
@Override
2327
public boolean equals(final Object o) {
24-
if (this == o) {
25-
return true;
26-
}
27-
if (o == null || getClass() != o.getClass()) {
28-
return false;
29-
}
28+
if (this == o) {
29+
return true;
30+
}
31+
if (o == null || getClass() != o.getClass()) {
32+
return false;
33+
}
3034
final ProductName that = (ProductName) o;
3135
return Objects.equal(value, that.value);
3236
}
@@ -35,9 +39,4 @@ public boolean equals(final Object o) {
3539
public int hashCode() {
3640
return Objects.hashCode(value);
3741
}
38-
39-
40-
private ProductName(final Name name) {
41-
this.value = name.getValue();
42-
}
4342
}

src/main/java/kitchenpos/product/domain/ProductNew.java

+18-18
Original file line numberDiff line numberDiff line change
@@ -26,27 +26,24 @@ public class ProductNew {
2626
@AttributeOverride(name = "value", column = @Column(name = "price"))
2727
private ProductPrice price;
2828

29-
public static ProductNew newOf(final ProductName name, final ProductPrice price) {
30-
return new ProductNew(UUID.randomUUID(), name, price);
31-
}
3229

33-
public void changePrice(final ProductPrice price) {
34-
this.price = price;
30+
protected ProductNew() {
3531
}
3632

37-
38-
public UUID getId() {
39-
return id;
33+
private ProductNew(final UUID id, final ProductName name, final ProductPrice price) {
34+
this.id = id;
35+
this.name = name;
36+
this.price = price;
4037
}
4138

42-
public ProductName getName() {
43-
return name;
39+
public static ProductNew newOf(final ProductName name, final ProductPrice price) {
40+
return new ProductNew(UUID.randomUUID(), name, price);
4441
}
4542

46-
public ProductPrice getPrice() {
47-
return price;
43+
public void changePrice(final ProductPrice price) {
44+
this.price = price;
4845
}
49-
46+
5047
@Override
5148
public boolean equals(final Object o) {
5249
if (this == o) {
@@ -64,12 +61,15 @@ public int hashCode() {
6461
return Objects.hash(id);
6562
}
6663

67-
private ProductNew(final UUID id, final ProductName name, final ProductPrice price) {
68-
this.id = id;
69-
this.name = name;
70-
this.price = price;
64+
public UUID getId() {
65+
return id;
66+
}
67+
68+
public ProductName getName() {
69+
return name;
7170
}
7271

73-
public ProductNew() {
72+
public ProductPrice getPrice() {
73+
return price;
7474
}
7575
}

src/main/java/kitchenpos/product/domain/ProductPrice.java

+7-6
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,19 @@ public class ProductPrice {
1111

1212
private long value;
1313

14+
protected ProductPrice() {
15+
}
16+
17+
private ProductPrice(final long value) {
18+
this.value = value;
19+
}
20+
1421
public static ProductPrice of(final long value) {
1522
checkArgument(value >= 0, "price must be bigger than 0. value : %s", value);
1623

1724
return new ProductPrice(value);
1825
}
1926

20-
public ProductPrice() {
21-
}
22-
2327
@Override
2428
public boolean equals(final Object o) {
2529
if (this == o) {
@@ -37,7 +41,4 @@ public int hashCode() {
3741
return Objects.hashCode(value);
3842
}
3943

40-
private ProductPrice(final long value) {
41-
this.value = value;
42-
}
4344
}

0 commit comments

Comments
 (0)