Skip to content

Commit f71e186

Browse files
committed
Fixed descriptions in code.
1 parent db2140e commit f71e186

File tree

2 files changed

+17
-11
lines changed

2 files changed

+17
-11
lines changed

value-object/src/main/java/com/iluwatar/value/object/App.java

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,24 @@
11
package 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
*/
619
public 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
}

value-object/src/main/java/com/iluwatar/value/object/HeroStat.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
11
package com.iluwatar.value.object;
22

33
/**
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>
4+
* HeroStat is a value object
115
*
126
* {@link http://docs.oracle.com/javase/8/docs/api/java/lang/doc-files/ValueBased.html}
137
*/

0 commit comments

Comments
 (0)