remove lombok, related to #1503
This commit is contained in:
parent
bd48d6ce10
commit
2e36a11e24
@ -31,11 +31,6 @@
|
|||||||
<artifactId>junit-jupiter-engine</artifactId>
|
<artifactId>junit-jupiter-engine</artifactId>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.projectlombok</groupId>
|
|
||||||
<artifactId>lombok</artifactId>
|
|
||||||
<version>1.18.12</version>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
|
@ -23,8 +23,10 @@
|
|||||||
|
|
||||||
package com.iluwatar.abstractfactory;
|
package com.iluwatar.abstractfactory;
|
||||||
|
|
||||||
import lombok.Getter;
|
import org.slf4j.Logger;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Abstract Factory pattern provides a way to encapsulate a group of individual factories that
|
* The Abstract Factory pattern provides a way to encapsulate a group of individual factories that
|
||||||
@ -40,12 +42,16 @@ import lombok.extern.slf4j.Slf4j;
|
|||||||
* and its implementations ( {@link ElfKingdomFactory}, {@link OrcKingdomFactory}). The example uses
|
* and its implementations ( {@link ElfKingdomFactory}, {@link OrcKingdomFactory}). The example uses
|
||||||
* both concrete implementations to create a king, a castle and an army.
|
* both concrete implementations to create a king, a castle and an army.
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
|
||||||
public class App implements Runnable {
|
public class App implements Runnable {
|
||||||
|
|
||||||
@Getter
|
private static Logger log = LoggerFactory.getLogger(App.class);
|
||||||
|
|
||||||
private final Kingdom kingdom = new Kingdom();
|
private final Kingdom kingdom = new Kingdom();
|
||||||
|
|
||||||
|
public Kingdom getKingdom() {
|
||||||
|
return kingdom;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Program entry point.
|
* Program entry point.
|
||||||
*
|
*
|
||||||
|
@ -1,14 +1,35 @@
|
|||||||
package com.iluwatar.abstractfactory;
|
package com.iluwatar.abstractfactory;
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public class Kingdom {
|
public class Kingdom {
|
||||||
|
|
||||||
private King king;
|
private King king;
|
||||||
private Castle castle;
|
private Castle castle;
|
||||||
private Army army;
|
private Army army;
|
||||||
|
|
||||||
|
public King getKing() {
|
||||||
|
return king;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Castle getCastle() {
|
||||||
|
return castle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Army getArmy() {
|
||||||
|
return army;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setKing(King king) {
|
||||||
|
this.king = king;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCastle(Castle castle) {
|
||||||
|
this.castle = castle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setArmy(Army army) {
|
||||||
|
this.army = army;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The factory of kingdom factories.
|
* The factory of kingdom factories.
|
||||||
*/
|
*/
|
||||||
|
@ -23,7 +23,6 @@
|
|||||||
|
|
||||||
package com.iluwatar.abstractfactory;
|
package com.iluwatar.abstractfactory;
|
||||||
|
|
||||||
import lombok.val;
|
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
@ -48,14 +47,14 @@ public class AbstractFactoryTest {
|
|||||||
@Test
|
@Test
|
||||||
public void king() {
|
public void king() {
|
||||||
app.createKingdom(elfFactory);
|
app.createKingdom(elfFactory);
|
||||||
val kingdom = app.getKingdom();
|
final var kingdom = app.getKingdom();
|
||||||
|
|
||||||
val elfKing = kingdom.getKing();
|
final var elfKing = kingdom.getKing();
|
||||||
assertTrue(elfKing instanceof ElfKing);
|
assertTrue(elfKing instanceof ElfKing);
|
||||||
assertEquals(ElfKing.DESCRIPTION, elfKing.getDescription());
|
assertEquals(ElfKing.DESCRIPTION, elfKing.getDescription());
|
||||||
|
|
||||||
app.createKingdom(orcFactory);
|
app.createKingdom(orcFactory);
|
||||||
val orcKing = kingdom.getKing();
|
final var orcKing = kingdom.getKing();
|
||||||
assertTrue(orcKing instanceof OrcKing);
|
assertTrue(orcKing instanceof OrcKing);
|
||||||
assertEquals(OrcKing.DESCRIPTION, orcKing.getDescription());
|
assertEquals(OrcKing.DESCRIPTION, orcKing.getDescription());
|
||||||
}
|
}
|
||||||
@ -63,14 +62,14 @@ public class AbstractFactoryTest {
|
|||||||
@Test
|
@Test
|
||||||
public void castle() {
|
public void castle() {
|
||||||
app.createKingdom(elfFactory);
|
app.createKingdom(elfFactory);
|
||||||
val kingdom = app.getKingdom();
|
final var kingdom = app.getKingdom();
|
||||||
|
|
||||||
val elfCastle = kingdom.getCastle();
|
final var elfCastle = kingdom.getCastle();
|
||||||
assertTrue(elfCastle instanceof ElfCastle);
|
assertTrue(elfCastle instanceof ElfCastle);
|
||||||
assertEquals(ElfCastle.DESCRIPTION, elfCastle.getDescription());
|
assertEquals(ElfCastle.DESCRIPTION, elfCastle.getDescription());
|
||||||
|
|
||||||
app.createKingdom(orcFactory);
|
app.createKingdom(orcFactory);
|
||||||
val orcCastle = kingdom.getCastle();
|
final var orcCastle = kingdom.getCastle();
|
||||||
assertTrue(orcCastle instanceof OrcCastle);
|
assertTrue(orcCastle instanceof OrcCastle);
|
||||||
assertEquals(OrcCastle.DESCRIPTION, orcCastle.getDescription());
|
assertEquals(OrcCastle.DESCRIPTION, orcCastle.getDescription());
|
||||||
}
|
}
|
||||||
@ -78,14 +77,14 @@ public class AbstractFactoryTest {
|
|||||||
@Test
|
@Test
|
||||||
public void army() {
|
public void army() {
|
||||||
app.createKingdom(elfFactory);
|
app.createKingdom(elfFactory);
|
||||||
val kingdom = app.getKingdom();
|
final var kingdom = app.getKingdom();
|
||||||
|
|
||||||
val elfArmy = kingdom.getArmy();
|
final var elfArmy = kingdom.getArmy();
|
||||||
assertTrue(elfArmy instanceof ElfArmy);
|
assertTrue(elfArmy instanceof ElfArmy);
|
||||||
assertEquals(ElfArmy.DESCRIPTION, elfArmy.getDescription());
|
assertEquals(ElfArmy.DESCRIPTION, elfArmy.getDescription());
|
||||||
|
|
||||||
app.createKingdom(orcFactory);
|
app.createKingdom(orcFactory);
|
||||||
val orcArmy = kingdom.getArmy();
|
final var orcArmy = kingdom.getArmy();
|
||||||
assertTrue(orcArmy instanceof OrcArmy);
|
assertTrue(orcArmy instanceof OrcArmy);
|
||||||
assertEquals(OrcArmy.DESCRIPTION, orcArmy.getDescription());
|
assertEquals(OrcArmy.DESCRIPTION, orcArmy.getDescription());
|
||||||
}
|
}
|
||||||
@ -93,11 +92,11 @@ public class AbstractFactoryTest {
|
|||||||
@Test
|
@Test
|
||||||
public void createElfKingdom() {
|
public void createElfKingdom() {
|
||||||
app.createKingdom(elfFactory);
|
app.createKingdom(elfFactory);
|
||||||
val kingdom = app.getKingdom();
|
final var kingdom = app.getKingdom();
|
||||||
|
|
||||||
val king = kingdom.getKing();
|
final var king = kingdom.getKing();
|
||||||
val castle = kingdom.getCastle();
|
final var castle = kingdom.getCastle();
|
||||||
val army = kingdom.getArmy();
|
final var army = kingdom.getArmy();
|
||||||
assertTrue(king instanceof ElfKing);
|
assertTrue(king instanceof ElfKing);
|
||||||
assertEquals(ElfKing.DESCRIPTION, king.getDescription());
|
assertEquals(ElfKing.DESCRIPTION, king.getDescription());
|
||||||
assertTrue(castle instanceof ElfCastle);
|
assertTrue(castle instanceof ElfCastle);
|
||||||
@ -109,11 +108,11 @@ public class AbstractFactoryTest {
|
|||||||
@Test
|
@Test
|
||||||
public void createOrcKingdom() {
|
public void createOrcKingdom() {
|
||||||
app.createKingdom(orcFactory);
|
app.createKingdom(orcFactory);
|
||||||
val kingdom = app.getKingdom();
|
final var kingdom = app.getKingdom();
|
||||||
|
|
||||||
val king = kingdom.getKing();
|
final var king = kingdom.getKing();
|
||||||
val castle = kingdom.getCastle();
|
final var castle = kingdom.getCastle();
|
||||||
val army = kingdom.getArmy();
|
final var army = kingdom.getArmy();
|
||||||
assertTrue(king instanceof OrcKing);
|
assertTrue(king instanceof OrcKing);
|
||||||
assertEquals(OrcKing.DESCRIPTION, king.getDescription());
|
assertEquals(OrcKing.DESCRIPTION, king.getDescription());
|
||||||
assertTrue(castle instanceof OrcCastle);
|
assertTrue(castle instanceof OrcCastle);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user