@@ -51,7 +51,6 @@ Here is the `HeroStat` class that is the value object. Notice the use of [Lombok
51
51
@Value (staticConstructor = " valueOf" )
52
52
@ToString
53
53
class HeroStat {
54
-
55
54
int strength;
56
55
int intelligence;
57
56
int luck;
@@ -61,16 +60,18 @@ class HeroStat {
61
60
The example creates three different ` HeroStat ` s and compares their equality.
62
61
63
62
``` java
64
- var statA = HeroStat . valueOf(10 , 5 , 0 );
65
- var statB = HeroStat . valueOf(10 , 5 , 0 );
66
- var statC = HeroStat . valueOf(5 , 1 , 8 );
63
+ public static void main(String [] args) {
64
+ var statA = HeroStat . valueOf(10 , 5 , 0 );
65
+ var statB = HeroStat . valueOf(10 , 5 , 0 );
66
+ var statC = HeroStat . valueOf(5 , 1 , 8 );
67
67
68
- LOGGER . info(" statA: {}" , statA);
69
- LOGGER . info(" statB: {}" , statB);
70
- LOGGER . info(" statC: {}" , statC);
68
+ LOGGER . info(" statA: {}" , statA);
69
+ LOGGER . info(" statB: {}" , statB);
70
+ LOGGER . info(" statC: {}" , statC);
71
71
72
- LOGGER . info(" Are statA and statB equal? {}" , statA. equals(statB));
73
- LOGGER . info(" Are statA and statC equal? {}" , statA. equals(statC));
72
+ LOGGER . info(" Are statA and statB equal? {}" , statA. equals(statB));
73
+ LOGGER . info(" Are statA and statC equal? {}" , statA. equals(statC));
74
+ }
74
75
```
75
76
76
77
Here's the console output.
@@ -137,4 +138,4 @@ Trade-offs:
137
138
* [ Effective Java] ( https://amzn.to/4cGk2Jz )
138
139
* [ J2EE Design Patterns] ( https://amzn.to/4dpzgmx )
139
140
* [ Patterns of Enterprise Application Architecture] ( https://amzn.to/3WfKBPR )
140
- * [ ValueObject - Martin Fowler] ( https://martinfowler.com/bliki/ValueObject.html )
141
+ * [ ValueObject ( Martin Fowler) ] ( https://martinfowler.com/bliki/ValueObject.html )
0 commit comments