mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-10-14 04:16:14 +00:00
deps: Refactor dependencies (#3224)
* remove spring dep move junit, logging, mockito under dep mgmt * upgrade anti-corruption-layer deps * async method invocation * balking, bloc * bridge to bytecode * caching * callback - cqrs * component - health check * hexagonal - metadata mapping * rest of the patterns * remove checkstyle, take spotless into use
This commit is contained in:
1 parent
371439aeaa
commit
0ca162a55c
1863 files changed
+14403
-17632
No files matched your search
@@ -34,6 +34,14 @@
|
||||
</parent>
|
||||
<artifactId>abstract-factory</artifactId>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ch.qos.logback</groupId>
|
||||
<artifactId>logback-classic</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-engine</artifactId>
|
||||
|
||||
@@ -74,6 +74,7 @@ public class App implements Runnable {
|
||||
|
||||
/**
|
||||
* Creates kingdom.
|
||||
*
|
||||
* @param kingdomType type of Kingdom
|
||||
*/
|
||||
public void createKingdom(final Kingdom.FactoryMaker.KingdomType kingdomType) {
|
||||
@@ -82,4 +83,4 @@ public class App implements Runnable {
|
||||
kingdom.setCastle(kingdomFactory.createCastle());
|
||||
kingdom.setArmy(kingdomFactory.createArmy());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -24,9 +24,7 @@
|
||||
*/
|
||||
package com.iluwatar.abstractfactory;
|
||||
|
||||
/**
|
||||
* Army interface.
|
||||
*/
|
||||
/** Army interface. */
|
||||
public interface Army {
|
||||
|
||||
String getDescription();
|
||||
|
||||
@@ -24,9 +24,7 @@
|
||||
*/
|
||||
package com.iluwatar.abstractfactory;
|
||||
|
||||
/**
|
||||
* Castle interface.
|
||||
*/
|
||||
/** Castle interface. */
|
||||
public interface Castle {
|
||||
|
||||
String getDescription();
|
||||
|
||||
@@ -24,9 +24,7 @@
|
||||
*/
|
||||
package com.iluwatar.abstractfactory;
|
||||
|
||||
/**
|
||||
* ElfArmy.
|
||||
*/
|
||||
/** ElfArmy. */
|
||||
public class ElfArmy implements Army {
|
||||
|
||||
static final String DESCRIPTION = "This is the elven army!";
|
||||
|
||||
@@ -24,9 +24,7 @@
|
||||
*/
|
||||
package com.iluwatar.abstractfactory;
|
||||
|
||||
/**
|
||||
* ElfCastle.
|
||||
*/
|
||||
/** ElfCastle. */
|
||||
public class ElfCastle implements Castle {
|
||||
|
||||
static final String DESCRIPTION = "This is the elven castle!";
|
||||
|
||||
@@ -24,9 +24,7 @@
|
||||
*/
|
||||
package com.iluwatar.abstractfactory;
|
||||
|
||||
/**
|
||||
* ElfKing.
|
||||
*/
|
||||
/** ElfKing. */
|
||||
public class ElfKing implements King {
|
||||
|
||||
static final String DESCRIPTION = "This is the elven king!";
|
||||
|
||||
@@ -24,9 +24,7 @@
|
||||
*/
|
||||
package com.iluwatar.abstractfactory;
|
||||
|
||||
/**
|
||||
* ElfKingdomFactory concrete factory.
|
||||
*/
|
||||
/** ElfKingdomFactory concrete factory. */
|
||||
public class ElfKingdomFactory implements KingdomFactory {
|
||||
|
||||
@Override
|
||||
@@ -43,5 +41,4 @@ public class ElfKingdomFactory implements KingdomFactory {
|
||||
public Army createArmy() {
|
||||
return new ElfArmy();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -24,9 +24,7 @@
|
||||
*/
|
||||
package com.iluwatar.abstractfactory;
|
||||
|
||||
/**
|
||||
* King interface.
|
||||
*/
|
||||
/** King interface. */
|
||||
public interface King {
|
||||
|
||||
String getDescription();
|
||||
|
||||
@@ -27,9 +27,7 @@ package com.iluwatar.abstractfactory;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* Helper class to manufacture {@link KingdomFactory} beans.
|
||||
*/
|
||||
/** Helper class to manufacture {@link KingdomFactory} beans. */
|
||||
@Getter
|
||||
@Setter
|
||||
public class Kingdom {
|
||||
@@ -38,21 +36,16 @@ public class Kingdom {
|
||||
private Castle castle;
|
||||
private Army army;
|
||||
|
||||
/**
|
||||
* The factory of kingdom factories.
|
||||
*/
|
||||
/** The factory of kingdom factories. */
|
||||
public static class FactoryMaker {
|
||||
|
||||
/**
|
||||
* Enumeration for the different types of Kingdoms.
|
||||
*/
|
||||
/** Enumeration for the different types of Kingdoms. */
|
||||
public enum KingdomType {
|
||||
ELF, ORC
|
||||
ELF,
|
||||
ORC
|
||||
}
|
||||
|
||||
/**
|
||||
* The factory method to create KingdomFactory concrete objects.
|
||||
*/
|
||||
/** The factory method to create KingdomFactory concrete objects. */
|
||||
public static KingdomFactory makeFactory(KingdomType type) {
|
||||
return switch (type) {
|
||||
case ELF -> new ElfKingdomFactory();
|
||||
|
||||
@@ -24,9 +24,7 @@
|
||||
*/
|
||||
package com.iluwatar.abstractfactory;
|
||||
|
||||
/**
|
||||
* KingdomFactory factory interface.
|
||||
*/
|
||||
/** KingdomFactory factory interface. */
|
||||
public interface KingdomFactory {
|
||||
|
||||
Castle createCastle();
|
||||
@@ -34,5 +32,4 @@ public interface KingdomFactory {
|
||||
King createKing();
|
||||
|
||||
Army createArmy();
|
||||
|
||||
}
|
||||
@@ -24,9 +24,7 @@
|
||||
*/
|
||||
package com.iluwatar.abstractfactory;
|
||||
|
||||
/**
|
||||
* OrcArmy.
|
||||
*/
|
||||
/** OrcArmy. */
|
||||
public class OrcArmy implements Army {
|
||||
|
||||
static final String DESCRIPTION = "This is the orc army!";
|
||||
|
||||
@@ -24,9 +24,7 @@
|
||||
*/
|
||||
package com.iluwatar.abstractfactory;
|
||||
|
||||
/**
|
||||
* OrcCastle.
|
||||
*/
|
||||
/** OrcCastle. */
|
||||
public class OrcCastle implements Castle {
|
||||
|
||||
static final String DESCRIPTION = "This is the orc castle!";
|
||||
|
||||
@@ -24,9 +24,7 @@
|
||||
*/
|
||||
package com.iluwatar.abstractfactory;
|
||||
|
||||
/**
|
||||
* OrcKing.
|
||||
*/
|
||||
/** OrcKing. */
|
||||
public class OrcKing implements King {
|
||||
|
||||
static final String DESCRIPTION = "This is the orc king!";
|
||||
|
||||
@@ -24,9 +24,7 @@
|
||||
*/
|
||||
package com.iluwatar.abstractfactory;
|
||||
|
||||
/**
|
||||
* OrcKingdomFactory concrete factory.
|
||||
*/
|
||||
/** OrcKingdomFactory concrete factory. */
|
||||
public class OrcKingdomFactory implements KingdomFactory {
|
||||
|
||||
@Override
|
||||
|
||||
+3
-5
@@ -24,14 +24,12 @@
|
||||
*/
|
||||
package com.iluwatar.abstractfactory;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
/**
|
||||
* Tests for abstract factory.
|
||||
*/
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/** Tests for abstract factory. */
|
||||
class AbstractFactoryTest {
|
||||
|
||||
private final App app = new App();
|
||||
|
||||
@@ -24,18 +24,16 @@
|
||||
*/
|
||||
package com.iluwatar.abstractfactory;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
|
||||
|
||||
/**
|
||||
* Check whether the execution of the main method in {@link App} throws an exception.
|
||||
*/
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/** Check whether the execution of the main method in {@link App} throws an exception. */
|
||||
class AppTest {
|
||||
|
||||
|
||||
@Test
|
||||
void shouldExecuteApplicationWithoutException() {
|
||||
|
||||
assertDoesNotThrow(() -> App.main(new String[]{}));
|
||||
assertDoesNotThrow(() -> App.main(new String[] {}));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user