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:
committed by
Ilkka Seppälä
parent
5fc03ee9f8
commit
c81c3ff1c7
@ -41,7 +41,7 @@ public class App {
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
|
||||
Commander commander =
|
||||
var commander =
|
||||
new Commander(new Sergeant(new Soldier(), new Soldier(), new Soldier()), new Sergeant(
|
||||
new Soldier(), new Soldier(), new Soldier()));
|
||||
commander.accept(new SoldierVisitor());
|
||||
|
@ -39,7 +39,7 @@ public abstract class Unit {
|
||||
* Accept visitor
|
||||
*/
|
||||
public void accept(UnitVisitor visitor) {
|
||||
for (Unit child : children) {
|
||||
for (var child : children) {
|
||||
child.accept(visitor);
|
||||
}
|
||||
}
|
||||
|
@ -56,15 +56,15 @@ public abstract class UnitTest<U extends Unit> {
|
||||
|
||||
@Test
|
||||
public void testAccept() {
|
||||
final Unit[] children = new Unit[5];
|
||||
final var children = new Unit[5];
|
||||
Arrays.setAll(children, (i) -> mock(Unit.class));
|
||||
|
||||
final U unit = this.factory.apply(children);
|
||||
final UnitVisitor visitor = mock(UnitVisitor.class);
|
||||
final var unit = this.factory.apply(children);
|
||||
final var visitor = mock(UnitVisitor.class);
|
||||
unit.accept(visitor);
|
||||
verifyVisit(unit, visitor);
|
||||
|
||||
for (final Unit child : children) {
|
||||
for (final var child : children) {
|
||||
verify(child).accept(eq(visitor));
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user