Use local variable type inference (#995)

* "visitor" pattern: Use local variable type inference

Update "visitor" pattern with local variable type inference.

* "value-object" pattern: Use local variable type inference

Update "value-object" pattern with local variable type inference.

* "unit-of-work" pattern: Use local variable type inference

Update "value-object" pattern with local variable type inference.

* "typeobjectpattern" pattern: Use local variable type inference

Update "value-object" pattern with local variable type inference.
This commit is contained in:
Zack Beach
2019-10-21 01:09:29 -04:00
committed by Ilkka Seppälä
parent 5fc03ee9f8
commit c81c3ff1c7
17 changed files with 110 additions and 110 deletions

View File

@ -48,9 +48,9 @@ public class App {
* This practice creates three HeroStats(Value object) and checks equality between those.
*/
public static void main(String[] args) {
HeroStat statA = HeroStat.valueOf(10, 5, 0);
HeroStat statB = HeroStat.valueOf(10, 5, 0);
HeroStat statC = HeroStat.valueOf(5, 1, 8);
var statA = HeroStat.valueOf(10, 5, 0);
var statB = HeroStat.valueOf(10, 5, 0);
var statC = HeroStat.valueOf(5, 1, 8);
LOGGER.info(statA.toString());

View File

@ -76,8 +76,8 @@ public class HeroStat {
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
final var prime = 31;
var result = 1;
result = prime * result + intelligence;
result = prime * result + luck;
result = prime * result + strength;
@ -95,7 +95,7 @@ public class HeroStat {
if (getClass() != obj.getClass()) {
return false;
}
HeroStat other = (HeroStat) obj;
var other = (HeroStat) obj;
if (intelligence != other.intelligence) {
return false;
}

View File

@ -45,8 +45,8 @@ public class HeroStatTest {
*/
@Test
public void testEquals() {
HeroStat heroStatA = HeroStat.valueOf(3, 9, 2);
HeroStat heroStatB = HeroStat.valueOf(3, 9, 2);
var heroStatA = HeroStat.valueOf(3, 9, 2);
var heroStatB = HeroStat.valueOf(3, 9, 2);
new EqualsTester().addEqualityGroup(heroStatA, heroStatB).testEquals();
}
@ -56,9 +56,9 @@ public class HeroStatTest {
*/
@Test
public void testToString() {
HeroStat heroStatA = HeroStat.valueOf(3, 9, 2);
HeroStat heroStatB = HeroStat.valueOf(3, 9, 2);
HeroStat heroStatC = HeroStat.valueOf(3, 9, 8);
var heroStatA = HeroStat.valueOf(3, 9, 2);
var heroStatB = HeroStat.valueOf(3, 9, 2);
var heroStatC = HeroStat.valueOf(3, 9, 8);
assertThat(heroStatA.toString(), is(heroStatB.toString()));
assertThat(heroStatA.toString(), is(not(heroStatC.toString())));