format code
This commit is contained in:
parent
f71e186959
commit
83533543e6
@ -14,11 +14,9 @@ package com.iluwatar.value.object;
|
|||||||
*
|
*
|
||||||
* For more specific and strict rules to implement value objects check the rules from Stephen
|
* For more specific and strict rules to implement value objects check the rules from Stephen
|
||||||
* Colebourne's term VALJO : http://blog.joda.org/2014/03/valjos-value-java-objects.html
|
* Colebourne's term VALJO : http://blog.joda.org/2014/03/valjos-value-java-objects.html
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class App {
|
public class App {
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* This practice creates three HeroStats(Value object) and checks equality between those.
|
* This practice creates three HeroStats(Value object) and checks equality between those.
|
||||||
*/
|
*/
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
@ -7,14 +7,12 @@ package com.iluwatar.value.object;
|
|||||||
*/
|
*/
|
||||||
public class HeroStat {
|
public class HeroStat {
|
||||||
|
|
||||||
|
|
||||||
// Stats for a hero
|
// Stats for a hero
|
||||||
|
|
||||||
private final int strength;
|
private final int strength;
|
||||||
private final int intelligence;
|
private final int intelligence;
|
||||||
private final int luck;
|
private final int luck;
|
||||||
|
|
||||||
|
|
||||||
// All constructors must be private.
|
// All constructors must be private.
|
||||||
private HeroStat(int strength, int intelligence, int luck) {
|
private HeroStat(int strength, int intelligence, int luck) {
|
||||||
super();
|
super();
|
||||||
@ -87,7 +85,6 @@ public class HeroStat {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// The clone() method should not be public. Just don't override it.
|
// The clone() method should not be public. Just don't override it.
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ import org.junit.Test;
|
|||||||
public class HeroStatTest {
|
public class HeroStatTest {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tester for equals() and hashCode() methods of a class. Using guava's EqualsTester
|
* Tester for equals() and hashCode() methods of a class. Using guava's EqualsTester.
|
||||||
*
|
*
|
||||||
* @see http://static.javadoc.io/com.google.guava/guava-testlib/19.0/com/google/common/testing/
|
* @see http://static.javadoc.io/com.google.guava/guava-testlib/19.0/com/google/common/testing/
|
||||||
* EqualsTester.html
|
* EqualsTester.html
|
||||||
@ -33,15 +33,12 @@ public class HeroStatTest {
|
|||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testToString() {
|
public void testToString() {
|
||||||
|
|
||||||
HeroStat heroStatA = HeroStat.valueOf(3, 9, 2);
|
HeroStat heroStatA = HeroStat.valueOf(3, 9, 2);
|
||||||
HeroStat heroStatB = HeroStat.valueOf(3, 9, 2);
|
HeroStat heroStatB = HeroStat.valueOf(3, 9, 2);
|
||||||
HeroStat heroStatC = HeroStat.valueOf(3, 9, 8);
|
HeroStat heroStatC = HeroStat.valueOf(3, 9, 8);
|
||||||
|
|
||||||
assertThat(heroStatA.toString(), is(heroStatB.toString()));
|
assertThat(heroStatA.toString(), is(heroStatB.toString()));
|
||||||
assertThat(heroStatA.toString(), is(not(heroStatC.toString())));
|
assertThat(heroStatA.toString(), is(not(heroStatC.toString())));
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user