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:
Anurag Agarwal
2019-12-22 18:11:19 +05:30
committed by Ilkka Seppälä
parent f835d3d516
commit 670c4e43f3
55 changed files with 377 additions and 429 deletions

View File

@ -23,7 +23,6 @@
package com.iluwatar.flyweight;
import java.util.Collections;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -42,7 +41,7 @@ public class AlchemistShop {
* Constructor.
*/
public AlchemistShop() {
PotionFactory factory = new PotionFactory();
var factory = new PotionFactory();
topShelf = List.of(
factory.createPotion(PotionType.INVISIBILITY),
factory.createPotion(PotionType.INVISIBILITY),
@ -68,7 +67,7 @@ public class AlchemistShop {
* @return The top shelf potions
*/
public final List<Potion> getTopShelf() {
return Collections.unmodifiableList(this.topShelf);
return List.copyOf(this.topShelf);
}
/**
@ -77,24 +76,16 @@ public class AlchemistShop {
* @return The bottom shelf potions
*/
public final List<Potion> getBottomShelf() {
return Collections.unmodifiableList(this.bottomShelf);
return List.copyOf(this.bottomShelf);
}
/**
* Enumerate potions.
*/
public void enumerate() {
LOGGER.info("Enumerating top shelf potions\n");
for (Potion p : topShelf) {
p.drink();
}
topShelf.forEach(Potion::drink);
LOGGER.info("Enumerating bottom shelf potions\n");
for (Potion p : bottomShelf) {
p.drink();
}
bottomShelf.forEach(Potion::drink);
}
}

View File

@ -43,7 +43,7 @@ public class App {
* @param args command line args
*/
public static void main(String[] args) {
AlchemistShop alchemistShop = new AlchemistShop();
var alchemistShop = new AlchemistShop();
alchemistShop.enumerate();
}
}

View File

@ -40,7 +40,7 @@ public class PotionFactory {
}
Potion createPotion(PotionType type) {
Potion potion = potions.get(type);
var potion = potions.get(type);
if (potion == null) {
switch (type) {
case HEALING:

View File

@ -23,14 +23,12 @@
package com.iluwatar.flyweight;
import org.junit.jupiter.api.Test;
import java.util.ArrayList;
import java.util.List;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import java.util.ArrayList;
import org.junit.jupiter.api.Test;
/**
* Date: 12/12/15 - 10:54 PM
*
@ -39,18 +37,18 @@ import static org.junit.jupiter.api.Assertions.assertNotNull;
public class AlchemistShopTest {
@Test
public void testShop() throws Exception {
final AlchemistShop shop = new AlchemistShop();
public void testShop() {
final var shop = new AlchemistShop();
final List<Potion> bottomShelf = shop.getBottomShelf();
final var bottomShelf = shop.getBottomShelf();
assertNotNull(bottomShelf);
assertEquals(5, bottomShelf.size());
final List<Potion> topShelf = shop.getTopShelf();
final var topShelf = shop.getTopShelf();
assertNotNull(topShelf);
assertEquals(8, topShelf.size());
final List<Potion> allPotions = new ArrayList<>();
final var allPotions = new ArrayList<Potion>();
allPotions.addAll(topShelf);
allPotions.addAll(bottomShelf);

View File

@ -26,15 +26,12 @@ package com.iluwatar.flyweight;
import org.junit.jupiter.api.Test;
/**
*
* Application test
*
*/
public class AppTest {
@Test
public void test() {
String[] args = {};
App.main(args);
App.main(new String[]{});
}
}