Java 11 migrate 7 remaining f (#1115)
* Moves facade to Java 11 * Moves factory-kit to Java 11 * Moves factory-method to Java 11 * Moves feature-toggle to Java 11 * Moves fluentinterface to Java 11 * Moves flux to Java 11 * Moves flyweight to Java 11 * Moves front-controller to Java 11 * Uses stream properly * Resolves issues with ci
This commit is contained in:
committed by
Ilkka Seppälä
parent
f835d3d516
commit
670c4e43f3
@@ -48,13 +48,13 @@ public class App {
|
||||
* @param args command line args
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
WeaponFactory factory = WeaponFactory.factory(builder -> {
|
||||
var factory = WeaponFactory.factory(builder -> {
|
||||
builder.add(WeaponType.SWORD, Sword::new);
|
||||
builder.add(WeaponType.AXE, Axe::new);
|
||||
builder.add(WeaponType.SPEAR, Spear::new);
|
||||
builder.add(WeaponType.BOW, Bow::new);
|
||||
});
|
||||
Weapon axe = factory.create(WeaponType.AXE);
|
||||
var axe = factory.create(WeaponType.AXE);
|
||||
LOGGER.info(axe.toString());
|
||||
}
|
||||
}
|
||||
|
@@ -24,7 +24,6 @@
|
||||
package com.iluwatar.factorykit;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
@@ -52,7 +51,7 @@ public interface WeaponFactory {
|
||||
* @return factory with specified {@link Builder}s
|
||||
*/
|
||||
static WeaponFactory factory(Consumer<Builder> consumer) {
|
||||
Map<WeaponType, Supplier<Weapon>> map = new HashMap<>();
|
||||
var map = new HashMap<WeaponType, Supplier<Weapon>>();
|
||||
consumer.accept(map::put);
|
||||
return name -> map.get(name).get();
|
||||
}
|
||||
|
@@ -33,8 +33,7 @@ public class AppTest {
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
String[] args = {};
|
||||
App.main(args);
|
||||
App.main(new String[]{});
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -23,6 +23,8 @@
|
||||
|
||||
package com.iluwatar.factorykit.factorykit;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import com.iluwatar.factorykit.Axe;
|
||||
import com.iluwatar.factorykit.Spear;
|
||||
import com.iluwatar.factorykit.Sword;
|
||||
@@ -32,10 +34,8 @@ import com.iluwatar.factorykit.WeaponType;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
/**
|
||||
* Test Factory Kit Pattern
|
||||
/**
|
||||
* Test Factory Kit Pattern
|
||||
*/
|
||||
public class FactoryKitTest {
|
||||
|
||||
@@ -51,30 +51,33 @@ public class FactoryKitTest {
|
||||
}
|
||||
|
||||
/**
|
||||
* Testing {@link WeaponFactory} to produce a SPEAR asserting that the Weapon is an instance of {@link Spear}
|
||||
* Testing {@link WeaponFactory} to produce a SPEAR asserting that the Weapon is an instance of
|
||||
* {@link Spear}
|
||||
*/
|
||||
@Test
|
||||
public void testSpearWeapon() {
|
||||
Weapon weapon = factory.create(WeaponType.SPEAR);
|
||||
var weapon = factory.create(WeaponType.SPEAR);
|
||||
verifyWeapon(weapon, Spear.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Testing {@link WeaponFactory} to produce a AXE asserting that the Weapon is an instance of {@link Axe}
|
||||
* Testing {@link WeaponFactory} to produce a AXE asserting that the Weapon is an instance of
|
||||
* {@link Axe}
|
||||
*/
|
||||
@Test
|
||||
public void testAxeWeapon() {
|
||||
Weapon weapon = factory.create(WeaponType.AXE);
|
||||
var weapon = factory.create(WeaponType.AXE);
|
||||
verifyWeapon(weapon, Axe.class);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Testing {@link WeaponFactory} to produce a SWORD asserting that the Weapon is an instance of {@link Sword}
|
||||
* Testing {@link WeaponFactory} to produce a SWORD asserting that the Weapon is an instance of
|
||||
* {@link Sword}
|
||||
*/
|
||||
@Test
|
||||
public void testWeapon() {
|
||||
Weapon weapon = factory.create(WeaponType.SWORD);
|
||||
var weapon = factory.create(WeaponType.SWORD);
|
||||
verifyWeapon(weapon, Sword.class);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user