11package com .iluwatar .value .object ;
22
33/**
4- * App Class.
4+ * A Value Object are objects which follow value semantics rather than reference semantics. This
5+ * means value objects' equality are not based on identity. Two value objects are equal when they
6+ * have the same value, not necessarily being the same object..
7+ *
8+ * Value Objects must override equals(), hashCode() to check the equality with values.
9+ * Value Objects should be immutable so declare members final.
10+ * Obtain instances by static factory methods.
11+ * The elements of the state must be other values, including primitive types.
12+ * Provide methods, typically simple getters, to get the elements of the state.
13+ * A Value Object must check equality with equals() not ==
14+ *
15+ * For more specific and strict rules to implement value objects check the rules from Stephen
16+ * Colebourne's term VALJO : http://blog.joda.org/2014/03/valjos-value-java-objects.html
17+ *
518 */
619public class App {
720 /**
8- * main method.
9- * A Value Object must check equality with equals() not == <br>
21+ *
1022 * This practice creates three HeroStats(Value object) and checks equality between those.
1123 */
1224 public static void main (String [] args ) {
@@ -15,7 +27,7 @@ public static void main(String[] args) {
1527 HeroStat statC = HeroStat .valueOf (5 , 1 , 8 );
1628
1729 System .out .println (statA .toString ());
18-
30+
1931 System .out .println ("Is statA and statB equal : " + statA .equals (statB ));
2032 System .out .println ("Is statA and statC equal : " + statA .equals (statC ));
2133 }
0 commit comments