11package com .iluwatar .value .object ;
22
33/**
4- * The Discount Coupon only discounts by percentage.
5- *
4+ * HeroStat is a Value Object. following rules are from Stephen Colebourne's term VALJO(not the
5+ * entire rule set) from : http://blog.joda.org/2014/03/valjos-value-java-objects.html<br>
6+ * Value Objects must override equals(), hashCode() to check the equality with values. <br>
7+ * Value Objects should be immutable so declare members final. Obtain instances by static factory
8+ * methods. <br>
9+ * The elements of the state must be other values, including primitive types.<br>
10+ * Provide methods, typically simple getters, to get the elements of the state.<br>
11+ *
12+ * {@link http://docs.oracle.com/javase/8/docs/api/java/lang/doc-files/ValueBased.html}
613 */
714public class HeroStat {
815
916
10- // stats for a hero
17+ // Stats for a hero
1118
1219 private final int strength ;
1320 private final int intelligence ;
@@ -22,6 +29,7 @@ private HeroStat(int strength, int intelligence, int luck) {
2229 this .luck = luck ;
2330 }
2431
32+ // Static factory method to create new instances.
2533 public static HeroStat valueOf (int strength , int intelligence , int luck ) {
2634 return new HeroStat (strength , intelligence , luck );
2735 }
@@ -39,7 +47,7 @@ public int getLuck() {
3947 }
4048
4149 /*
42- * recommended to provide a static factory method capable of creating an instance from the formal
50+ * Recommended to provide a static factory method capable of creating an instance from the formal
4351 * string representation declared like this. public static Juice parse(String string) {}
4452 */
4553
@@ -86,6 +94,6 @@ public boolean equals(Object obj) {
8694 }
8795
8896
89- // the clone() method should not be public
97+ // The clone() method should not be public
9098
9199}
0 commit comments