diff --git a/patterns/design-patterns-2/README.md b/patterns/design-patterns-2/README.md deleted file mode 100644 index 8e4ef657e1..0000000000 --- a/patterns/design-patterns-2/README.md +++ /dev/null @@ -1,5 +0,0 @@ -### Relevant Articles - -- [The Mediator Pattern in Java](https://www.baeldung.com/java-mediator-pattern) -- [Introduction to the Null Object Pattern](https://www.baeldung.com/java-null-object-pattern) -- [Avoid Check for Null Statement in Java](https://www.baeldung.com/java-avoid-null-check) diff --git a/patterns/design-patterns-architectural/README.md b/patterns/design-patterns-architectural/README.md new file mode 100644 index 0000000000..fbe4221752 --- /dev/null +++ b/patterns/design-patterns-architectural/README.md @@ -0,0 +1,3 @@ +### Relevant Articles: +- [Service Locator Pattern](https://www.baeldung.com/java-service-locator-pattern) +- [The DAO Pattern in Java](https://www.baeldung.com/java-dao-pattern) diff --git a/patterns/design-patterns/pom.xml b/patterns/design-patterns-architectural/pom.xml similarity index 78% rename from patterns/design-patterns/pom.xml rename to patterns/design-patterns-architectural/pom.xml index e6bff64f9e..cf99919e7c 100644 --- a/patterns/design-patterns/pom.xml +++ b/patterns/design-patterns-architectural/pom.xml @@ -2,9 +2,9 @@ 4.0.0 - design-patterns + design-patterns-architectural 1.0 - design-patterns + design-patterns-architectural jar @@ -21,7 +21,8 @@ ${assertj-core.version} test - + + javax javaee-api ${javaee.version} @@ -37,24 +38,15 @@ ${mysql-connector.version} jar - - log4j - log4j - ${log4j.version} - - - com.googlecode.grep4j - grep4j - ${grep4j.version} - UTF-8 1.8 1.8 - 1.8.7 + 3.9.1 + 8.0 5.2.16.Final 6.0.6 diff --git a/patterns/design-patterns/src/main/java/com/baeldung/daopattern/application/UserApplication.java b/patterns/design-patterns-architectural/src/main/java/com/baeldung/daopattern/application/UserApplication.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/daopattern/application/UserApplication.java rename to patterns/design-patterns-architectural/src/main/java/com/baeldung/daopattern/application/UserApplication.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/daopattern/config/JpaEntityManagerFactory.java b/patterns/design-patterns-architectural/src/main/java/com/baeldung/daopattern/config/JpaEntityManagerFactory.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/daopattern/config/JpaEntityManagerFactory.java rename to patterns/design-patterns-architectural/src/main/java/com/baeldung/daopattern/config/JpaEntityManagerFactory.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/daopattern/config/PersistenceUnitInfoImpl.java b/patterns/design-patterns-architectural/src/main/java/com/baeldung/daopattern/config/PersistenceUnitInfoImpl.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/daopattern/config/PersistenceUnitInfoImpl.java rename to patterns/design-patterns-architectural/src/main/java/com/baeldung/daopattern/config/PersistenceUnitInfoImpl.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/daopattern/daos/Dao.java b/patterns/design-patterns-architectural/src/main/java/com/baeldung/daopattern/daos/Dao.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/daopattern/daos/Dao.java rename to patterns/design-patterns-architectural/src/main/java/com/baeldung/daopattern/daos/Dao.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/daopattern/daos/JpaUserDao.java b/patterns/design-patterns-architectural/src/main/java/com/baeldung/daopattern/daos/JpaUserDao.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/daopattern/daos/JpaUserDao.java rename to patterns/design-patterns-architectural/src/main/java/com/baeldung/daopattern/daos/JpaUserDao.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/daopattern/daos/UserDao.java b/patterns/design-patterns-architectural/src/main/java/com/baeldung/daopattern/daos/UserDao.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/daopattern/daos/UserDao.java rename to patterns/design-patterns-architectural/src/main/java/com/baeldung/daopattern/daos/UserDao.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/daopattern/entities/User.java b/patterns/design-patterns-architectural/src/main/java/com/baeldung/daopattern/entities/User.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/daopattern/entities/User.java rename to patterns/design-patterns-architectural/src/main/java/com/baeldung/daopattern/entities/User.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/service/locator/Cache.java b/patterns/design-patterns-architectural/src/main/java/com/baeldung/service/locator/Cache.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/service/locator/Cache.java rename to patterns/design-patterns-architectural/src/main/java/com/baeldung/service/locator/Cache.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/service/locator/EmailService.java b/patterns/design-patterns-architectural/src/main/java/com/baeldung/service/locator/EmailService.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/service/locator/EmailService.java rename to patterns/design-patterns-architectural/src/main/java/com/baeldung/service/locator/EmailService.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/service/locator/InitialContext.java b/patterns/design-patterns-architectural/src/main/java/com/baeldung/service/locator/InitialContext.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/service/locator/InitialContext.java rename to patterns/design-patterns-architectural/src/main/java/com/baeldung/service/locator/InitialContext.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/service/locator/Main.java b/patterns/design-patterns-architectural/src/main/java/com/baeldung/service/locator/Main.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/service/locator/Main.java rename to patterns/design-patterns-architectural/src/main/java/com/baeldung/service/locator/Main.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/service/locator/MessagingService.java b/patterns/design-patterns-architectural/src/main/java/com/baeldung/service/locator/MessagingService.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/service/locator/MessagingService.java rename to patterns/design-patterns-architectural/src/main/java/com/baeldung/service/locator/MessagingService.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/service/locator/SMSService.java b/patterns/design-patterns-architectural/src/main/java/com/baeldung/service/locator/SMSService.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/service/locator/SMSService.java rename to patterns/design-patterns-architectural/src/main/java/com/baeldung/service/locator/SMSService.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/service/locator/ServiceLocator.java b/patterns/design-patterns-architectural/src/main/java/com/baeldung/service/locator/ServiceLocator.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/service/locator/ServiceLocator.java rename to patterns/design-patterns-architectural/src/main/java/com/baeldung/service/locator/ServiceLocator.java diff --git a/patterns/design-patterns/src/main/resources/META-INF/persistence.xml b/patterns/design-patterns-architectural/src/main/resources/META-INF/persistence.xml similarity index 100% rename from patterns/design-patterns/src/main/resources/META-INF/persistence.xml rename to patterns/design-patterns-architectural/src/main/resources/META-INF/persistence.xml diff --git a/patterns/design-patterns/src/test/java/com/baeldung/daopattern/test/UserDaoUnitTest.java b/patterns/design-patterns-architectural/src/test/java/com/baeldung/daopattern/test/UserDaoUnitTest.java similarity index 100% rename from patterns/design-patterns/src/test/java/com/baeldung/daopattern/test/UserDaoUnitTest.java rename to patterns/design-patterns-architectural/src/test/java/com/baeldung/daopattern/test/UserDaoUnitTest.java diff --git a/patterns/design-patterns-behavioral-2/README.md b/patterns/design-patterns-behavioral-2/README.md new file mode 100644 index 0000000000..9618a9c458 --- /dev/null +++ b/patterns/design-patterns-behavioral-2/README.md @@ -0,0 +1,2 @@ +### Relevant Articles: +- [Memento Design Pattern in Java](https://www.baeldung.com/java-memento-design-pattern) diff --git a/patterns/design-patterns-behavioral-2/pom.xml b/patterns/design-patterns-behavioral-2/pom.xml new file mode 100644 index 0000000000..7e73c0ad19 --- /dev/null +++ b/patterns/design-patterns-behavioral-2/pom.xml @@ -0,0 +1,33 @@ + + + 4.0.0 + design-patterns-behavioral-2 + 1.0 + design-patterns-behavioral-2 + jar + + + com.baeldung + patterns + 1.0.0-SNAPSHOT + .. + + + + + org.assertj + assertj-core + ${assertj.version} + test + + + + + UTF-8 + 1.8 + 1.8 + + 3.12.2 + + diff --git a/patterns/design-patterns-2/src/main/java/com/baeldung/memento/TextEditor.java b/patterns/design-patterns-behavioral-2/src/main/java/com/baeldung/memento/TextEditor.java similarity index 100% rename from patterns/design-patterns-2/src/main/java/com/baeldung/memento/TextEditor.java rename to patterns/design-patterns-behavioral-2/src/main/java/com/baeldung/memento/TextEditor.java diff --git a/patterns/design-patterns-2/src/main/java/com/baeldung/memento/TextWindow.java b/patterns/design-patterns-behavioral-2/src/main/java/com/baeldung/memento/TextWindow.java similarity index 100% rename from patterns/design-patterns-2/src/main/java/com/baeldung/memento/TextWindow.java rename to patterns/design-patterns-behavioral-2/src/main/java/com/baeldung/memento/TextWindow.java diff --git a/patterns/design-patterns-2/src/main/java/com/baeldung/memento/TextWindowState.java b/patterns/design-patterns-behavioral-2/src/main/java/com/baeldung/memento/TextWindowState.java similarity index 100% rename from patterns/design-patterns-2/src/main/java/com/baeldung/memento/TextWindowState.java rename to patterns/design-patterns-behavioral-2/src/main/java/com/baeldung/memento/TextWindowState.java diff --git a/patterns/design-patterns-2/src/test/java/com/baeldung/memento/TextEditorUnitTest.java b/patterns/design-patterns-behavioral-2/src/test/java/com/baeldung/memento/TextEditorUnitTest.java similarity index 100% rename from patterns/design-patterns-2/src/test/java/com/baeldung/memento/TextEditorUnitTest.java rename to patterns/design-patterns-behavioral-2/src/test/java/com/baeldung/memento/TextEditorUnitTest.java diff --git a/patterns/design-patterns-behavioral/README.md b/patterns/design-patterns-behavioral/README.md new file mode 100644 index 0000000000..42514e0ad8 --- /dev/null +++ b/patterns/design-patterns-behavioral/README.md @@ -0,0 +1,11 @@ +### Relevant Articles: +- [The Observer Pattern in Java](https://www.baeldung.com/java-observer-pattern) +- [Visitor Design Pattern in Java](https://www.baeldung.com/java-visitor-pattern) +- [Interpreter Design Pattern in Java](https://www.baeldung.com/java-interpreter-pattern) +- [State Design Pattern in Java](https://www.baeldung.com/java-state-design-pattern) +- [Implementing the Template Method Pattern in Java](https://www.baeldung.com/java-template-method-pattern) +- [Chain of Responsibility Design Pattern in Java](https://www.baeldung.com/chain-of-responsibility-pattern) +- [The Command Pattern in Java](https://www.baeldung.com/java-command-pattern) +- [The Mediator Pattern in Java](https://www.baeldung.com/java-mediator-pattern) +- [Introduction to the Null Object Pattern](https://www.baeldung.com/java-null-object-pattern) +- [Avoid Check for Null Statement in Java](https://www.baeldung.com/java-avoid-null-check) diff --git a/patterns/design-patterns-2/pom.xml b/patterns/design-patterns-behavioral/pom.xml similarity index 69% rename from patterns/design-patterns-2/pom.xml rename to patterns/design-patterns-behavioral/pom.xml index f99bb4dc9c..d6603f94ec 100644 --- a/patterns/design-patterns-2/pom.xml +++ b/patterns/design-patterns-behavioral/pom.xml @@ -2,9 +2,9 @@ 4.0.0 - design-patterns-2 + design-patterns-behavioral 1.0 - design-patterns-2 + design-patterns-behavioral jar @@ -31,32 +31,21 @@ commons-lang3 ${commons-lang3.version} + org.assertj assertj-core - ${assertj.version} + ${assertj-core.version} test - - - org.inferred - freebuilder - ${freebuilder.version} - true - - - com.google.code.findbugs - jsr305 - ${javax.annotations.version} - + UTF-8 1.8 1.8 + 16.0.2 - 3.12.2 - 2.4.1 - 3.0.2 + 3.9.1 diff --git a/patterns/design-patterns/src/main/java/com/baeldung/chainofresponsibility/AuthenticationProcessor.java b/patterns/design-patterns-behavioral/src/main/java/com/baeldung/chainofresponsibility/AuthenticationProcessor.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/chainofresponsibility/AuthenticationProcessor.java rename to patterns/design-patterns-behavioral/src/main/java/com/baeldung/chainofresponsibility/AuthenticationProcessor.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/chainofresponsibility/AuthenticationProvider.java b/patterns/design-patterns-behavioral/src/main/java/com/baeldung/chainofresponsibility/AuthenticationProvider.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/chainofresponsibility/AuthenticationProvider.java rename to patterns/design-patterns-behavioral/src/main/java/com/baeldung/chainofresponsibility/AuthenticationProvider.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/chainofresponsibility/OAuthAuthenticationProcessor.java b/patterns/design-patterns-behavioral/src/main/java/com/baeldung/chainofresponsibility/OAuthAuthenticationProcessor.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/chainofresponsibility/OAuthAuthenticationProcessor.java rename to patterns/design-patterns-behavioral/src/main/java/com/baeldung/chainofresponsibility/OAuthAuthenticationProcessor.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/chainofresponsibility/OAuthTokenProvider.java b/patterns/design-patterns-behavioral/src/main/java/com/baeldung/chainofresponsibility/OAuthTokenProvider.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/chainofresponsibility/OAuthTokenProvider.java rename to patterns/design-patterns-behavioral/src/main/java/com/baeldung/chainofresponsibility/OAuthTokenProvider.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/chainofresponsibility/SamlAuthenticationProvider.java b/patterns/design-patterns-behavioral/src/main/java/com/baeldung/chainofresponsibility/SamlAuthenticationProvider.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/chainofresponsibility/SamlAuthenticationProvider.java rename to patterns/design-patterns-behavioral/src/main/java/com/baeldung/chainofresponsibility/SamlAuthenticationProvider.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/chainofresponsibility/UsernamePasswordAuthenticationProcessor.java b/patterns/design-patterns-behavioral/src/main/java/com/baeldung/chainofresponsibility/UsernamePasswordAuthenticationProcessor.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/chainofresponsibility/UsernamePasswordAuthenticationProcessor.java rename to patterns/design-patterns-behavioral/src/main/java/com/baeldung/chainofresponsibility/UsernamePasswordAuthenticationProcessor.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/chainofresponsibility/UsernamePasswordProvider.java b/patterns/design-patterns-behavioral/src/main/java/com/baeldung/chainofresponsibility/UsernamePasswordProvider.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/chainofresponsibility/UsernamePasswordProvider.java rename to patterns/design-patterns-behavioral/src/main/java/com/baeldung/chainofresponsibility/UsernamePasswordProvider.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/command/client/TextFileApplication.java b/patterns/design-patterns-behavioral/src/main/java/com/baeldung/command/client/TextFileApplication.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/command/client/TextFileApplication.java rename to patterns/design-patterns-behavioral/src/main/java/com/baeldung/command/client/TextFileApplication.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/command/command/OpenTextFileOperation.java b/patterns/design-patterns-behavioral/src/main/java/com/baeldung/command/command/OpenTextFileOperation.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/command/command/OpenTextFileOperation.java rename to patterns/design-patterns-behavioral/src/main/java/com/baeldung/command/command/OpenTextFileOperation.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/command/command/SaveTextFileOperation.java b/patterns/design-patterns-behavioral/src/main/java/com/baeldung/command/command/SaveTextFileOperation.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/command/command/SaveTextFileOperation.java rename to patterns/design-patterns-behavioral/src/main/java/com/baeldung/command/command/SaveTextFileOperation.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/command/command/TextFileOperation.java b/patterns/design-patterns-behavioral/src/main/java/com/baeldung/command/command/TextFileOperation.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/command/command/TextFileOperation.java rename to patterns/design-patterns-behavioral/src/main/java/com/baeldung/command/command/TextFileOperation.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/command/invoker/TextFileOperationExecutor.java b/patterns/design-patterns-behavioral/src/main/java/com/baeldung/command/invoker/TextFileOperationExecutor.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/command/invoker/TextFileOperationExecutor.java rename to patterns/design-patterns-behavioral/src/main/java/com/baeldung/command/invoker/TextFileOperationExecutor.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/command/receiver/TextFile.java b/patterns/design-patterns-behavioral/src/main/java/com/baeldung/command/receiver/TextFile.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/command/receiver/TextFile.java rename to patterns/design-patterns-behavioral/src/main/java/com/baeldung/command/receiver/TextFile.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/interpreter/Context.java b/patterns/design-patterns-behavioral/src/main/java/com/baeldung/interpreter/Context.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/interpreter/Context.java rename to patterns/design-patterns-behavioral/src/main/java/com/baeldung/interpreter/Context.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/interpreter/Expression.java b/patterns/design-patterns-behavioral/src/main/java/com/baeldung/interpreter/Expression.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/interpreter/Expression.java rename to patterns/design-patterns-behavioral/src/main/java/com/baeldung/interpreter/Expression.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/interpreter/From.java b/patterns/design-patterns-behavioral/src/main/java/com/baeldung/interpreter/From.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/interpreter/From.java rename to patterns/design-patterns-behavioral/src/main/java/com/baeldung/interpreter/From.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/interpreter/InterpreterDemo.java b/patterns/design-patterns-behavioral/src/main/java/com/baeldung/interpreter/InterpreterDemo.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/interpreter/InterpreterDemo.java rename to patterns/design-patterns-behavioral/src/main/java/com/baeldung/interpreter/InterpreterDemo.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/interpreter/Row.java b/patterns/design-patterns-behavioral/src/main/java/com/baeldung/interpreter/Row.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/interpreter/Row.java rename to patterns/design-patterns-behavioral/src/main/java/com/baeldung/interpreter/Row.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/interpreter/Select.java b/patterns/design-patterns-behavioral/src/main/java/com/baeldung/interpreter/Select.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/interpreter/Select.java rename to patterns/design-patterns-behavioral/src/main/java/com/baeldung/interpreter/Select.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/interpreter/Where.java b/patterns/design-patterns-behavioral/src/main/java/com/baeldung/interpreter/Where.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/interpreter/Where.java rename to patterns/design-patterns-behavioral/src/main/java/com/baeldung/interpreter/Where.java diff --git a/patterns/design-patterns-2/src/main/java/com/baeldung/mediator/Button.java b/patterns/design-patterns-behavioral/src/main/java/com/baeldung/mediator/Button.java similarity index 100% rename from patterns/design-patterns-2/src/main/java/com/baeldung/mediator/Button.java rename to patterns/design-patterns-behavioral/src/main/java/com/baeldung/mediator/Button.java diff --git a/patterns/design-patterns-2/src/main/java/com/baeldung/mediator/Fan.java b/patterns/design-patterns-behavioral/src/main/java/com/baeldung/mediator/Fan.java similarity index 100% rename from patterns/design-patterns-2/src/main/java/com/baeldung/mediator/Fan.java rename to patterns/design-patterns-behavioral/src/main/java/com/baeldung/mediator/Fan.java diff --git a/patterns/design-patterns-2/src/main/java/com/baeldung/mediator/Mediator.java b/patterns/design-patterns-behavioral/src/main/java/com/baeldung/mediator/Mediator.java similarity index 100% rename from patterns/design-patterns-2/src/main/java/com/baeldung/mediator/Mediator.java rename to patterns/design-patterns-behavioral/src/main/java/com/baeldung/mediator/Mediator.java diff --git a/patterns/design-patterns-2/src/main/java/com/baeldung/mediator/PowerSupplier.java b/patterns/design-patterns-behavioral/src/main/java/com/baeldung/mediator/PowerSupplier.java similarity index 100% rename from patterns/design-patterns-2/src/main/java/com/baeldung/mediator/PowerSupplier.java rename to patterns/design-patterns-behavioral/src/main/java/com/baeldung/mediator/PowerSupplier.java diff --git a/patterns/design-patterns-2/src/main/java/com/baeldung/nullobject/JmsRouter.java b/patterns/design-patterns-behavioral/src/main/java/com/baeldung/nullobject/JmsRouter.java similarity index 100% rename from patterns/design-patterns-2/src/main/java/com/baeldung/nullobject/JmsRouter.java rename to patterns/design-patterns-behavioral/src/main/java/com/baeldung/nullobject/JmsRouter.java diff --git a/patterns/design-patterns-2/src/main/java/com/baeldung/nullobject/Message.java b/patterns/design-patterns-behavioral/src/main/java/com/baeldung/nullobject/Message.java similarity index 100% rename from patterns/design-patterns-2/src/main/java/com/baeldung/nullobject/Message.java rename to patterns/design-patterns-behavioral/src/main/java/com/baeldung/nullobject/Message.java diff --git a/patterns/design-patterns-2/src/main/java/com/baeldung/nullobject/NullRouter.java b/patterns/design-patterns-behavioral/src/main/java/com/baeldung/nullobject/NullRouter.java similarity index 100% rename from patterns/design-patterns-2/src/main/java/com/baeldung/nullobject/NullRouter.java rename to patterns/design-patterns-behavioral/src/main/java/com/baeldung/nullobject/NullRouter.java diff --git a/patterns/design-patterns-2/src/main/java/com/baeldung/nullobject/Router.java b/patterns/design-patterns-behavioral/src/main/java/com/baeldung/nullobject/Router.java similarity index 100% rename from patterns/design-patterns-2/src/main/java/com/baeldung/nullobject/Router.java rename to patterns/design-patterns-behavioral/src/main/java/com/baeldung/nullobject/Router.java diff --git a/patterns/design-patterns-2/src/main/java/com/baeldung/nullobject/RouterFactory.java b/patterns/design-patterns-behavioral/src/main/java/com/baeldung/nullobject/RouterFactory.java similarity index 100% rename from patterns/design-patterns-2/src/main/java/com/baeldung/nullobject/RouterFactory.java rename to patterns/design-patterns-behavioral/src/main/java/com/baeldung/nullobject/RouterFactory.java diff --git a/patterns/design-patterns-2/src/main/java/com/baeldung/nullobject/RoutingHandler.java b/patterns/design-patterns-behavioral/src/main/java/com/baeldung/nullobject/RoutingHandler.java similarity index 100% rename from patterns/design-patterns-2/src/main/java/com/baeldung/nullobject/RoutingHandler.java rename to patterns/design-patterns-behavioral/src/main/java/com/baeldung/nullobject/RoutingHandler.java diff --git a/patterns/design-patterns-2/src/main/java/com/baeldung/nullobject/SmsRouter.java b/patterns/design-patterns-behavioral/src/main/java/com/baeldung/nullobject/SmsRouter.java similarity index 100% rename from patterns/design-patterns-2/src/main/java/com/baeldung/nullobject/SmsRouter.java rename to patterns/design-patterns-behavioral/src/main/java/com/baeldung/nullobject/SmsRouter.java diff --git a/patterns/design-patterns-2/src/main/java/com/baeldung/nulls/APIContracts.java b/patterns/design-patterns-behavioral/src/main/java/com/baeldung/nulls/APIContracts.java similarity index 100% rename from patterns/design-patterns-2/src/main/java/com/baeldung/nulls/APIContracts.java rename to patterns/design-patterns-behavioral/src/main/java/com/baeldung/nulls/APIContracts.java diff --git a/patterns/design-patterns-2/src/main/java/com/baeldung/nulls/Assertions.java b/patterns/design-patterns-behavioral/src/main/java/com/baeldung/nulls/Assertions.java similarity index 100% rename from patterns/design-patterns-2/src/main/java/com/baeldung/nulls/Assertions.java rename to patterns/design-patterns-behavioral/src/main/java/com/baeldung/nulls/Assertions.java diff --git a/patterns/design-patterns-2/src/main/java/com/baeldung/nulls/EmptyCollections.java b/patterns/design-patterns-behavioral/src/main/java/com/baeldung/nulls/EmptyCollections.java similarity index 100% rename from patterns/design-patterns-2/src/main/java/com/baeldung/nulls/EmptyCollections.java rename to patterns/design-patterns-behavioral/src/main/java/com/baeldung/nulls/EmptyCollections.java diff --git a/patterns/design-patterns-2/src/main/java/com/baeldung/nulls/FindBugsAnnotations.java b/patterns/design-patterns-behavioral/src/main/java/com/baeldung/nulls/FindBugsAnnotations.java similarity index 100% rename from patterns/design-patterns-2/src/main/java/com/baeldung/nulls/FindBugsAnnotations.java rename to patterns/design-patterns-behavioral/src/main/java/com/baeldung/nulls/FindBugsAnnotations.java diff --git a/patterns/design-patterns-2/src/main/java/com/baeldung/nulls/Preconditions.java b/patterns/design-patterns-behavioral/src/main/java/com/baeldung/nulls/Preconditions.java similarity index 100% rename from patterns/design-patterns-2/src/main/java/com/baeldung/nulls/Preconditions.java rename to patterns/design-patterns-behavioral/src/main/java/com/baeldung/nulls/Preconditions.java diff --git a/patterns/design-patterns-2/src/main/java/com/baeldung/nulls/PrimitivesAndWrapper.java b/patterns/design-patterns-behavioral/src/main/java/com/baeldung/nulls/PrimitivesAndWrapper.java similarity index 100% rename from patterns/design-patterns-2/src/main/java/com/baeldung/nulls/PrimitivesAndWrapper.java rename to patterns/design-patterns-behavioral/src/main/java/com/baeldung/nulls/PrimitivesAndWrapper.java diff --git a/patterns/design-patterns-2/src/main/java/com/baeldung/nulls/UsingLombok.java b/patterns/design-patterns-behavioral/src/main/java/com/baeldung/nulls/UsingLombok.java similarity index 100% rename from patterns/design-patterns-2/src/main/java/com/baeldung/nulls/UsingLombok.java rename to patterns/design-patterns-behavioral/src/main/java/com/baeldung/nulls/UsingLombok.java diff --git a/patterns/design-patterns-2/src/main/java/com/baeldung/nulls/UsingObjects.java b/patterns/design-patterns-behavioral/src/main/java/com/baeldung/nulls/UsingObjects.java similarity index 100% rename from patterns/design-patterns-2/src/main/java/com/baeldung/nulls/UsingObjects.java rename to patterns/design-patterns-behavioral/src/main/java/com/baeldung/nulls/UsingObjects.java diff --git a/patterns/design-patterns-2/src/main/java/com/baeldung/nulls/UsingOptional.java b/patterns/design-patterns-behavioral/src/main/java/com/baeldung/nulls/UsingOptional.java similarity index 100% rename from patterns/design-patterns-2/src/main/java/com/baeldung/nulls/UsingOptional.java rename to patterns/design-patterns-behavioral/src/main/java/com/baeldung/nulls/UsingOptional.java diff --git a/patterns/design-patterns-2/src/main/java/com/baeldung/nulls/UsingStringUtils.java b/patterns/design-patterns-behavioral/src/main/java/com/baeldung/nulls/UsingStringUtils.java similarity index 100% rename from patterns/design-patterns-2/src/main/java/com/baeldung/nulls/UsingStringUtils.java rename to patterns/design-patterns-behavioral/src/main/java/com/baeldung/nulls/UsingStringUtils.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/observer/Channel.java b/patterns/design-patterns-behavioral/src/main/java/com/baeldung/observer/Channel.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/observer/Channel.java rename to patterns/design-patterns-behavioral/src/main/java/com/baeldung/observer/Channel.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/observer/NewsAgency.java b/patterns/design-patterns-behavioral/src/main/java/com/baeldung/observer/NewsAgency.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/observer/NewsAgency.java rename to patterns/design-patterns-behavioral/src/main/java/com/baeldung/observer/NewsAgency.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/observer/NewsChannel.java b/patterns/design-patterns-behavioral/src/main/java/com/baeldung/observer/NewsChannel.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/observer/NewsChannel.java rename to patterns/design-patterns-behavioral/src/main/java/com/baeldung/observer/NewsChannel.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/observer/ONewsAgency.java b/patterns/design-patterns-behavioral/src/main/java/com/baeldung/observer/ONewsAgency.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/observer/ONewsAgency.java rename to patterns/design-patterns-behavioral/src/main/java/com/baeldung/observer/ONewsAgency.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/observer/ONewsChannel.java b/patterns/design-patterns-behavioral/src/main/java/com/baeldung/observer/ONewsChannel.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/observer/ONewsChannel.java rename to patterns/design-patterns-behavioral/src/main/java/com/baeldung/observer/ONewsChannel.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/observer/PCLNewsAgency.java b/patterns/design-patterns-behavioral/src/main/java/com/baeldung/observer/PCLNewsAgency.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/observer/PCLNewsAgency.java rename to patterns/design-patterns-behavioral/src/main/java/com/baeldung/observer/PCLNewsAgency.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/observer/PCLNewsChannel.java b/patterns/design-patterns-behavioral/src/main/java/com/baeldung/observer/PCLNewsChannel.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/observer/PCLNewsChannel.java rename to patterns/design-patterns-behavioral/src/main/java/com/baeldung/observer/PCLNewsChannel.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/state/DeliveredState.java b/patterns/design-patterns-behavioral/src/main/java/com/baeldung/state/DeliveredState.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/state/DeliveredState.java rename to patterns/design-patterns-behavioral/src/main/java/com/baeldung/state/DeliveredState.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/state/OrderedState.java b/patterns/design-patterns-behavioral/src/main/java/com/baeldung/state/OrderedState.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/state/OrderedState.java rename to patterns/design-patterns-behavioral/src/main/java/com/baeldung/state/OrderedState.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/state/Package.java b/patterns/design-patterns-behavioral/src/main/java/com/baeldung/state/Package.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/state/Package.java rename to patterns/design-patterns-behavioral/src/main/java/com/baeldung/state/Package.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/state/PackageState.java b/patterns/design-patterns-behavioral/src/main/java/com/baeldung/state/PackageState.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/state/PackageState.java rename to patterns/design-patterns-behavioral/src/main/java/com/baeldung/state/PackageState.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/state/ReceivedState.java b/patterns/design-patterns-behavioral/src/main/java/com/baeldung/state/ReceivedState.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/state/ReceivedState.java rename to patterns/design-patterns-behavioral/src/main/java/com/baeldung/state/ReceivedState.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/state/StateDemo.java b/patterns/design-patterns-behavioral/src/main/java/com/baeldung/state/StateDemo.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/state/StateDemo.java rename to patterns/design-patterns-behavioral/src/main/java/com/baeldung/state/StateDemo.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/templatemethod/application/Application.java b/patterns/design-patterns-behavioral/src/main/java/com/baeldung/templatemethod/application/Application.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/templatemethod/application/Application.java rename to patterns/design-patterns-behavioral/src/main/java/com/baeldung/templatemethod/application/Application.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/templatemethod/model/Computer.java b/patterns/design-patterns-behavioral/src/main/java/com/baeldung/templatemethod/model/Computer.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/templatemethod/model/Computer.java rename to patterns/design-patterns-behavioral/src/main/java/com/baeldung/templatemethod/model/Computer.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/templatemethod/model/ComputerBuilder.java b/patterns/design-patterns-behavioral/src/main/java/com/baeldung/templatemethod/model/ComputerBuilder.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/templatemethod/model/ComputerBuilder.java rename to patterns/design-patterns-behavioral/src/main/java/com/baeldung/templatemethod/model/ComputerBuilder.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/templatemethod/model/HighEndComputer.java b/patterns/design-patterns-behavioral/src/main/java/com/baeldung/templatemethod/model/HighEndComputer.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/templatemethod/model/HighEndComputer.java rename to patterns/design-patterns-behavioral/src/main/java/com/baeldung/templatemethod/model/HighEndComputer.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/templatemethod/model/HighEndComputerBuilder.java b/patterns/design-patterns-behavioral/src/main/java/com/baeldung/templatemethod/model/HighEndComputerBuilder.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/templatemethod/model/HighEndComputerBuilder.java rename to patterns/design-patterns-behavioral/src/main/java/com/baeldung/templatemethod/model/HighEndComputerBuilder.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/templatemethod/model/StandardComputer.java b/patterns/design-patterns-behavioral/src/main/java/com/baeldung/templatemethod/model/StandardComputer.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/templatemethod/model/StandardComputer.java rename to patterns/design-patterns-behavioral/src/main/java/com/baeldung/templatemethod/model/StandardComputer.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/templatemethod/model/StandardComputerBuilder.java b/patterns/design-patterns-behavioral/src/main/java/com/baeldung/templatemethod/model/StandardComputerBuilder.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/templatemethod/model/StandardComputerBuilder.java rename to patterns/design-patterns-behavioral/src/main/java/com/baeldung/templatemethod/model/StandardComputerBuilder.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/visitor/Document.java b/patterns/design-patterns-behavioral/src/main/java/com/baeldung/visitor/Document.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/visitor/Document.java rename to patterns/design-patterns-behavioral/src/main/java/com/baeldung/visitor/Document.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/visitor/Element.java b/patterns/design-patterns-behavioral/src/main/java/com/baeldung/visitor/Element.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/visitor/Element.java rename to patterns/design-patterns-behavioral/src/main/java/com/baeldung/visitor/Element.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/visitor/ElementVisitor.java b/patterns/design-patterns-behavioral/src/main/java/com/baeldung/visitor/ElementVisitor.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/visitor/ElementVisitor.java rename to patterns/design-patterns-behavioral/src/main/java/com/baeldung/visitor/ElementVisitor.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/visitor/JsonElement.java b/patterns/design-patterns-behavioral/src/main/java/com/baeldung/visitor/JsonElement.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/visitor/JsonElement.java rename to patterns/design-patterns-behavioral/src/main/java/com/baeldung/visitor/JsonElement.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/visitor/Visitor.java b/patterns/design-patterns-behavioral/src/main/java/com/baeldung/visitor/Visitor.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/visitor/Visitor.java rename to patterns/design-patterns-behavioral/src/main/java/com/baeldung/visitor/Visitor.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/visitor/VisitorDemo.java b/patterns/design-patterns-behavioral/src/main/java/com/baeldung/visitor/VisitorDemo.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/visitor/VisitorDemo.java rename to patterns/design-patterns-behavioral/src/main/java/com/baeldung/visitor/VisitorDemo.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/visitor/XmlElement.java b/patterns/design-patterns-behavioral/src/main/java/com/baeldung/visitor/XmlElement.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/visitor/XmlElement.java rename to patterns/design-patterns-behavioral/src/main/java/com/baeldung/visitor/XmlElement.java diff --git a/patterns/design-patterns/src/test/java/com/baeldung/chainofresponsibility/ChainOfResponsibilityIntegrationTest.java b/patterns/design-patterns-behavioral/src/test/java/com/baeldung/chainofresponsibility/ChainOfResponsibilityIntegrationTest.java similarity index 100% rename from patterns/design-patterns/src/test/java/com/baeldung/chainofresponsibility/ChainOfResponsibilityIntegrationTest.java rename to patterns/design-patterns-behavioral/src/test/java/com/baeldung/chainofresponsibility/ChainOfResponsibilityIntegrationTest.java diff --git a/patterns/design-patterns/src/test/java/com/baeldung/command/test/OpenTextFileOperationUnitTest.java b/patterns/design-patterns-behavioral/src/test/java/com/baeldung/command/test/OpenTextFileOperationUnitTest.java similarity index 100% rename from patterns/design-patterns/src/test/java/com/baeldung/command/test/OpenTextFileOperationUnitTest.java rename to patterns/design-patterns-behavioral/src/test/java/com/baeldung/command/test/OpenTextFileOperationUnitTest.java diff --git a/patterns/design-patterns/src/test/java/com/baeldung/command/test/SaveTextFileOperationUnitTest.java b/patterns/design-patterns-behavioral/src/test/java/com/baeldung/command/test/SaveTextFileOperationUnitTest.java similarity index 100% rename from patterns/design-patterns/src/test/java/com/baeldung/command/test/SaveTextFileOperationUnitTest.java rename to patterns/design-patterns-behavioral/src/test/java/com/baeldung/command/test/SaveTextFileOperationUnitTest.java diff --git a/patterns/design-patterns/src/test/java/com/baeldung/command/test/TextFileOperationExecutorUnitTest.java b/patterns/design-patterns-behavioral/src/test/java/com/baeldung/command/test/TextFileOperationExecutorUnitTest.java similarity index 100% rename from patterns/design-patterns/src/test/java/com/baeldung/command/test/TextFileOperationExecutorUnitTest.java rename to patterns/design-patterns-behavioral/src/test/java/com/baeldung/command/test/TextFileOperationExecutorUnitTest.java diff --git a/patterns/design-patterns/src/test/java/com/baeldung/command/test/TextFileUnitTest.java b/patterns/design-patterns-behavioral/src/test/java/com/baeldung/command/test/TextFileUnitTest.java similarity index 100% rename from patterns/design-patterns/src/test/java/com/baeldung/command/test/TextFileUnitTest.java rename to patterns/design-patterns-behavioral/src/test/java/com/baeldung/command/test/TextFileUnitTest.java diff --git a/patterns/design-patterns-2/src/test/java/com/baeldung/mediator/MediatorIntegrationTest.java b/patterns/design-patterns-behavioral/src/test/java/com/baeldung/mediator/MediatorIntegrationTest.java similarity index 100% rename from patterns/design-patterns-2/src/test/java/com/baeldung/mediator/MediatorIntegrationTest.java rename to patterns/design-patterns-behavioral/src/test/java/com/baeldung/mediator/MediatorIntegrationTest.java diff --git a/patterns/design-patterns-2/src/test/java/com/baeldung/nulls/PrimitivesAndWrapperUnitTest.java b/patterns/design-patterns-behavioral/src/test/java/com/baeldung/nulls/PrimitivesAndWrapperUnitTest.java similarity index 100% rename from patterns/design-patterns-2/src/test/java/com/baeldung/nulls/PrimitivesAndWrapperUnitTest.java rename to patterns/design-patterns-behavioral/src/test/java/com/baeldung/nulls/PrimitivesAndWrapperUnitTest.java diff --git a/patterns/design-patterns-2/src/test/java/com/baeldung/nulls/UsingLombokUnitTest.java b/patterns/design-patterns-behavioral/src/test/java/com/baeldung/nulls/UsingLombokUnitTest.java similarity index 100% rename from patterns/design-patterns-2/src/test/java/com/baeldung/nulls/UsingLombokUnitTest.java rename to patterns/design-patterns-behavioral/src/test/java/com/baeldung/nulls/UsingLombokUnitTest.java diff --git a/patterns/design-patterns-2/src/test/java/com/baeldung/nulls/UsingObjectsUnitTest.java b/patterns/design-patterns-behavioral/src/test/java/com/baeldung/nulls/UsingObjectsUnitTest.java similarity index 100% rename from patterns/design-patterns-2/src/test/java/com/baeldung/nulls/UsingObjectsUnitTest.java rename to patterns/design-patterns-behavioral/src/test/java/com/baeldung/nulls/UsingObjectsUnitTest.java diff --git a/patterns/design-patterns-2/src/test/java/com/baeldung/nulls/UsingOptionalUnitTest.java b/patterns/design-patterns-behavioral/src/test/java/com/baeldung/nulls/UsingOptionalUnitTest.java similarity index 100% rename from patterns/design-patterns-2/src/test/java/com/baeldung/nulls/UsingOptionalUnitTest.java rename to patterns/design-patterns-behavioral/src/test/java/com/baeldung/nulls/UsingOptionalUnitTest.java diff --git a/patterns/design-patterns-2/src/test/java/com/baeldung/nulls/UsingStringUtilsUnitTest.java b/patterns/design-patterns-behavioral/src/test/java/com/baeldung/nulls/UsingStringUtilsUnitTest.java similarity index 100% rename from patterns/design-patterns-2/src/test/java/com/baeldung/nulls/UsingStringUtilsUnitTest.java rename to patterns/design-patterns-behavioral/src/test/java/com/baeldung/nulls/UsingStringUtilsUnitTest.java diff --git a/patterns/design-patterns/src/test/java/com/baeldung/observer/ObserverIntegrationTest.java b/patterns/design-patterns-behavioral/src/test/java/com/baeldung/observer/ObserverIntegrationTest.java similarity index 100% rename from patterns/design-patterns/src/test/java/com/baeldung/observer/ObserverIntegrationTest.java rename to patterns/design-patterns-behavioral/src/test/java/com/baeldung/observer/ObserverIntegrationTest.java diff --git a/patterns/design-patterns/src/test/java/com/baeldung/state/StatePatternUnitTest.java b/patterns/design-patterns-behavioral/src/test/java/com/baeldung/state/StatePatternUnitTest.java similarity index 100% rename from patterns/design-patterns/src/test/java/com/baeldung/state/StatePatternUnitTest.java rename to patterns/design-patterns-behavioral/src/test/java/com/baeldung/state/StatePatternUnitTest.java diff --git a/patterns/design-patterns/src/test/java/com/baeldung/templatemethod/test/TemplateMethodPatternIntegrationTest.java b/patterns/design-patterns-behavioral/src/test/java/com/baeldung/templatemethod/test/TemplateMethodPatternIntegrationTest.java similarity index 100% rename from patterns/design-patterns/src/test/java/com/baeldung/templatemethod/test/TemplateMethodPatternIntegrationTest.java rename to patterns/design-patterns-behavioral/src/test/java/com/baeldung/templatemethod/test/TemplateMethodPatternIntegrationTest.java diff --git a/patterns/design-patterns-creational/README.md b/patterns/design-patterns-creational/README.md new file mode 100644 index 0000000000..0c00dc7b3a --- /dev/null +++ b/patterns/design-patterns-creational/README.md @@ -0,0 +1,8 @@ +### Relevant Articles: +- [Singletons in Java](https://www.baeldung.com/java-singleton) +- [Introduction to Creational Design Patterns](https://www.baeldung.com/creational-design-patterns) +- [Abstract Factory Pattern in Java](https://www.baeldung.com/java-abstract-factory-pattern) +- [Flyweight Pattern in Java](https://www.baeldung.com/java-flyweight) +- [Double-Checked Locking with Singleton](https://www.baeldung.com/java-singleton-double-checked-locking) +- [Java Constructors vs Static Factory Methods](https://www.baeldung.com/java-constructors-vs-static-factory-methods) +- [Automatic Generation of the Builder Pattern with FreeBuilder](https://www.baeldung.com/java-builder-pattern-freebuilder) diff --git a/patterns/design-patterns-creational/pom.xml b/patterns/design-patterns-creational/pom.xml new file mode 100644 index 0000000000..351f69f749 --- /dev/null +++ b/patterns/design-patterns-creational/pom.xml @@ -0,0 +1,47 @@ + + + 4.0.0 + design-patterns-creational + 1.0 + design-patterns-creational + jar + + + com.baeldung + patterns + 1.0.0-SNAPSHOT + .. + + + + + org.inferred + freebuilder + ${freebuilder.version} + true + + + com.google.code.findbugs + jsr305 + ${javax.annotations.version} + + + + org.assertj + assertj-core + ${assertj-core.version} + test + + + + + UTF-8 + 1.8 + 1.8 + + 2.4.1 + 3.0.2 + 3.9.1 + + diff --git a/patterns/design-patterns/src/main/java/com/baeldung/constructorsstaticfactorymethods/application/Application.java b/patterns/design-patterns-creational/src/main/java/com/baeldung/constructorsstaticfactorymethods/application/Application.java similarity index 97% rename from patterns/design-patterns/src/main/java/com/baeldung/constructorsstaticfactorymethods/application/Application.java rename to patterns/design-patterns-creational/src/main/java/com/baeldung/constructorsstaticfactorymethods/application/Application.java index d19772072f..8730542dcb 100644 --- a/patterns/design-patterns/src/main/java/com/baeldung/constructorsstaticfactorymethods/application/Application.java +++ b/patterns/design-patterns-creational/src/main/java/com/baeldung/constructorsstaticfactorymethods/application/Application.java @@ -1,12 +1,12 @@ -package com.baeldung.constructorsstaticfactorymethods.application; - -import com.baeldung.constructorsstaticfactorymethods.entities.User; - -public class Application { - - public static void main(String[] args) { - User user1 = User.createWithDefaultCountry("John", "john@domain.com"); - User user2 = User.createWithLoggedInstantiationTime("John", "john@domain.com", "Argentina"); - User user3 = User.getSingletonInstance("John", "john@domain.com", "Argentina"); - } +package com.baeldung.constructorsstaticfactorymethods.application; + +import com.baeldung.constructorsstaticfactorymethods.entities.User; + +public class Application { + + public static void main(String[] args) { + User user1 = User.createWithDefaultCountry("John", "john@domain.com"); + User user2 = User.createWithLoggedInstantiationTime("John", "john@domain.com", "Argentina"); + User user3 = User.getSingletonInstance("John", "john@domain.com", "Argentina"); + } } \ No newline at end of file diff --git a/patterns/design-patterns/src/main/java/com/baeldung/constructorsstaticfactorymethods/entities/User.java b/patterns/design-patterns-creational/src/main/java/com/baeldung/constructorsstaticfactorymethods/entities/User.java similarity index 96% rename from patterns/design-patterns/src/main/java/com/baeldung/constructorsstaticfactorymethods/entities/User.java rename to patterns/design-patterns-creational/src/main/java/com/baeldung/constructorsstaticfactorymethods/entities/User.java index 4036b622c6..f05a3baaa3 100644 --- a/patterns/design-patterns/src/main/java/com/baeldung/constructorsstaticfactorymethods/entities/User.java +++ b/patterns/design-patterns-creational/src/main/java/com/baeldung/constructorsstaticfactorymethods/entities/User.java @@ -1,63 +1,63 @@ -package com.baeldung.constructorsstaticfactorymethods.entities; - -import java.time.LocalTime; -import java.util.logging.ConsoleHandler; -import java.util.logging.Level; -import java.util.logging.Logger; -import java.util.logging.SimpleFormatter; - -public class User { - - private static volatile User instance = null; - private static final Logger LOGGER = Logger.getLogger(User.class.getName()); - private final String name; - private final String email; - private final String country; - - public static User createWithDefaultCountry(String name, String email) { - return new User(name, email, "Argentina"); - } - - public static User createWithLoggedInstantiationTime(String name, String email, String country) { - setLoggerProperties(); - LOGGER.log(Level.INFO, "Creating User instance at : {0}", LocalTime.now()); - return new User(name, email, country); - } - - public static User getSingletonInstance(String name, String email, String country) { - if (instance == null) { - synchronized (User.class) { - if (instance == null) { - instance = new User(name, email, country); - } - } - } - return instance; - - } - - private User(String name, String email, String country) { - this.name = name; - this.email = email; - this.country = country; - } - - public String getName() { - return name; - } - - public String getEmail() { - return email; - } - - public String getCountry() { - return country; - } - - private static void setLoggerProperties() { - ConsoleHandler handler = new ConsoleHandler(); - handler.setLevel(Level.INFO); - handler.setFormatter(new SimpleFormatter()); - LOGGER.addHandler(handler); - } -} +package com.baeldung.constructorsstaticfactorymethods.entities; + +import java.time.LocalTime; +import java.util.logging.ConsoleHandler; +import java.util.logging.Level; +import java.util.logging.Logger; +import java.util.logging.SimpleFormatter; + +public class User { + + private static volatile User instance = null; + private static final Logger LOGGER = Logger.getLogger(User.class.getName()); + private final String name; + private final String email; + private final String country; + + public static User createWithDefaultCountry(String name, String email) { + return new User(name, email, "Argentina"); + } + + public static User createWithLoggedInstantiationTime(String name, String email, String country) { + setLoggerProperties(); + LOGGER.log(Level.INFO, "Creating User instance at : {0}", LocalTime.now()); + return new User(name, email, country); + } + + public static User getSingletonInstance(String name, String email, String country) { + if (instance == null) { + synchronized (User.class) { + if (instance == null) { + instance = new User(name, email, country); + } + } + } + return instance; + + } + + private User(String name, String email, String country) { + this.name = name; + this.email = email; + this.country = country; + } + + public String getName() { + return name; + } + + public String getEmail() { + return email; + } + + public String getCountry() { + return country; + } + + private static void setLoggerProperties() { + ConsoleHandler handler = new ConsoleHandler(); + handler.setLevel(Level.INFO); + handler.setFormatter(new SimpleFormatter()); + LOGGER.addHandler(handler); + } +} diff --git a/patterns/design-patterns/src/main/java/com/baeldung/creational/abstractfactory/AbstractFactory.java b/patterns/design-patterns-creational/src/main/java/com/baeldung/creational/abstractfactory/AbstractFactory.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/creational/abstractfactory/AbstractFactory.java rename to patterns/design-patterns-creational/src/main/java/com/baeldung/creational/abstractfactory/AbstractFactory.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/creational/abstractfactory/AbstractPatternDriver.java b/patterns/design-patterns-creational/src/main/java/com/baeldung/creational/abstractfactory/AbstractPatternDriver.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/creational/abstractfactory/AbstractPatternDriver.java rename to patterns/design-patterns-creational/src/main/java/com/baeldung/creational/abstractfactory/AbstractPatternDriver.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/creational/abstractfactory/Animal.java b/patterns/design-patterns-creational/src/main/java/com/baeldung/creational/abstractfactory/Animal.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/creational/abstractfactory/Animal.java rename to patterns/design-patterns-creational/src/main/java/com/baeldung/creational/abstractfactory/Animal.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/creational/abstractfactory/AnimalFactory.java b/patterns/design-patterns-creational/src/main/java/com/baeldung/creational/abstractfactory/AnimalFactory.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/creational/abstractfactory/AnimalFactory.java rename to patterns/design-patterns-creational/src/main/java/com/baeldung/creational/abstractfactory/AnimalFactory.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/creational/abstractfactory/Brown.java b/patterns/design-patterns-creational/src/main/java/com/baeldung/creational/abstractfactory/Brown.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/creational/abstractfactory/Brown.java rename to patterns/design-patterns-creational/src/main/java/com/baeldung/creational/abstractfactory/Brown.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/creational/abstractfactory/Color.java b/patterns/design-patterns-creational/src/main/java/com/baeldung/creational/abstractfactory/Color.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/creational/abstractfactory/Color.java rename to patterns/design-patterns-creational/src/main/java/com/baeldung/creational/abstractfactory/Color.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/creational/abstractfactory/ColorFactory.java b/patterns/design-patterns-creational/src/main/java/com/baeldung/creational/abstractfactory/ColorFactory.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/creational/abstractfactory/ColorFactory.java rename to patterns/design-patterns-creational/src/main/java/com/baeldung/creational/abstractfactory/ColorFactory.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/creational/abstractfactory/Dog.java b/patterns/design-patterns-creational/src/main/java/com/baeldung/creational/abstractfactory/Dog.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/creational/abstractfactory/Dog.java rename to patterns/design-patterns-creational/src/main/java/com/baeldung/creational/abstractfactory/Dog.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/creational/abstractfactory/Duck.java b/patterns/design-patterns-creational/src/main/java/com/baeldung/creational/abstractfactory/Duck.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/creational/abstractfactory/Duck.java rename to patterns/design-patterns-creational/src/main/java/com/baeldung/creational/abstractfactory/Duck.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/creational/abstractfactory/FactoryProvider.java b/patterns/design-patterns-creational/src/main/java/com/baeldung/creational/abstractfactory/FactoryProvider.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/creational/abstractfactory/FactoryProvider.java rename to patterns/design-patterns-creational/src/main/java/com/baeldung/creational/abstractfactory/FactoryProvider.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/creational/abstractfactory/White.java b/patterns/design-patterns-creational/src/main/java/com/baeldung/creational/abstractfactory/White.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/creational/abstractfactory/White.java rename to patterns/design-patterns-creational/src/main/java/com/baeldung/creational/abstractfactory/White.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/creational/builder/BankAccount.java b/patterns/design-patterns-creational/src/main/java/com/baeldung/creational/builder/BankAccount.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/creational/builder/BankAccount.java rename to patterns/design-patterns-creational/src/main/java/com/baeldung/creational/builder/BankAccount.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/creational/builder/BuilderPatternDriver.java b/patterns/design-patterns-creational/src/main/java/com/baeldung/creational/builder/BuilderPatternDriver.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/creational/builder/BuilderPatternDriver.java rename to patterns/design-patterns-creational/src/main/java/com/baeldung/creational/builder/BuilderPatternDriver.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/creational/factory/FactoryDriver.java b/patterns/design-patterns-creational/src/main/java/com/baeldung/creational/factory/FactoryDriver.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/creational/factory/FactoryDriver.java rename to patterns/design-patterns-creational/src/main/java/com/baeldung/creational/factory/FactoryDriver.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/creational/factory/Heptagon.java b/patterns/design-patterns-creational/src/main/java/com/baeldung/creational/factory/Heptagon.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/creational/factory/Heptagon.java rename to patterns/design-patterns-creational/src/main/java/com/baeldung/creational/factory/Heptagon.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/creational/factory/Octagon.java b/patterns/design-patterns-creational/src/main/java/com/baeldung/creational/factory/Octagon.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/creational/factory/Octagon.java rename to patterns/design-patterns-creational/src/main/java/com/baeldung/creational/factory/Octagon.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/creational/factory/Pentagon.java b/patterns/design-patterns-creational/src/main/java/com/baeldung/creational/factory/Pentagon.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/creational/factory/Pentagon.java rename to patterns/design-patterns-creational/src/main/java/com/baeldung/creational/factory/Pentagon.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/creational/factory/Polygon.java b/patterns/design-patterns-creational/src/main/java/com/baeldung/creational/factory/Polygon.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/creational/factory/Polygon.java rename to patterns/design-patterns-creational/src/main/java/com/baeldung/creational/factory/Polygon.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/creational/factory/PolygonFactory.java b/patterns/design-patterns-creational/src/main/java/com/baeldung/creational/factory/PolygonFactory.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/creational/factory/PolygonFactory.java rename to patterns/design-patterns-creational/src/main/java/com/baeldung/creational/factory/PolygonFactory.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/creational/factory/Square.java b/patterns/design-patterns-creational/src/main/java/com/baeldung/creational/factory/Square.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/creational/factory/Square.java rename to patterns/design-patterns-creational/src/main/java/com/baeldung/creational/factory/Square.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/creational/factory/Triangle.java b/patterns/design-patterns-creational/src/main/java/com/baeldung/creational/factory/Triangle.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/creational/factory/Triangle.java rename to patterns/design-patterns-creational/src/main/java/com/baeldung/creational/factory/Triangle.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/creational/singleton/Singleton.java b/patterns/design-patterns-creational/src/main/java/com/baeldung/creational/singleton/Singleton.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/creational/singleton/Singleton.java rename to patterns/design-patterns-creational/src/main/java/com/baeldung/creational/singleton/Singleton.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/creational/singleton/SingletonDriver.java b/patterns/design-patterns-creational/src/main/java/com/baeldung/creational/singleton/SingletonDriver.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/creational/singleton/SingletonDriver.java rename to patterns/design-patterns-creational/src/main/java/com/baeldung/creational/singleton/SingletonDriver.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/flyweight/Car.java b/patterns/design-patterns-creational/src/main/java/com/baeldung/flyweight/Car.java similarity index 95% rename from patterns/design-patterns/src/main/java/com/baeldung/flyweight/Car.java rename to patterns/design-patterns-creational/src/main/java/com/baeldung/flyweight/Car.java index a0b1a7cdf5..80ef992abb 100644 --- a/patterns/design-patterns/src/main/java/com/baeldung/flyweight/Car.java +++ b/patterns/design-patterns-creational/src/main/java/com/baeldung/flyweight/Car.java @@ -2,8 +2,6 @@ package com.baeldung.flyweight; import java.awt.Color; -import javax.annotation.concurrent.Immutable; - import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -12,7 +10,6 @@ import org.slf4j.LoggerFactory; * * @author Donato Rimenti */ -@Immutable public class Car implements Vehicle { /** diff --git a/patterns/design-patterns/src/main/java/com/baeldung/flyweight/Engine.java b/patterns/design-patterns-creational/src/main/java/com/baeldung/flyweight/Engine.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/flyweight/Engine.java rename to patterns/design-patterns-creational/src/main/java/com/baeldung/flyweight/Engine.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/flyweight/Vehicle.java b/patterns/design-patterns-creational/src/main/java/com/baeldung/flyweight/Vehicle.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/flyweight/Vehicle.java rename to patterns/design-patterns-creational/src/main/java/com/baeldung/flyweight/Vehicle.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/flyweight/VehicleFactory.java b/patterns/design-patterns-creational/src/main/java/com/baeldung/flyweight/VehicleFactory.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/flyweight/VehicleFactory.java rename to patterns/design-patterns-creational/src/main/java/com/baeldung/flyweight/VehicleFactory.java diff --git a/patterns/design-patterns-2/src/main/java/com/baeldung/freebuilder/Address.java b/patterns/design-patterns-creational/src/main/java/com/baeldung/freebuilder/Address.java similarity index 100% rename from patterns/design-patterns-2/src/main/java/com/baeldung/freebuilder/Address.java rename to patterns/design-patterns-creational/src/main/java/com/baeldung/freebuilder/Address.java diff --git a/patterns/design-patterns-2/src/main/java/com/baeldung/freebuilder/Employee.java b/patterns/design-patterns-creational/src/main/java/com/baeldung/freebuilder/Employee.java similarity index 100% rename from patterns/design-patterns-2/src/main/java/com/baeldung/freebuilder/Employee.java rename to patterns/design-patterns-creational/src/main/java/com/baeldung/freebuilder/Employee.java diff --git a/patterns/design-patterns-2/src/main/java/com/baeldung/freebuilder/builder/Employee.java b/patterns/design-patterns-creational/src/main/java/com/baeldung/freebuilder/builder/Employee.java similarity index 100% rename from patterns/design-patterns-2/src/main/java/com/baeldung/freebuilder/builder/Employee.java rename to patterns/design-patterns-creational/src/main/java/com/baeldung/freebuilder/builder/Employee.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/singleton/ClassSingleton.java b/patterns/design-patterns-creational/src/main/java/com/baeldung/singleton/ClassSingleton.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/singleton/ClassSingleton.java rename to patterns/design-patterns-creational/src/main/java/com/baeldung/singleton/ClassSingleton.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/singleton/EnumSingleton.java b/patterns/design-patterns-creational/src/main/java/com/baeldung/singleton/EnumSingleton.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/singleton/EnumSingleton.java rename to patterns/design-patterns-creational/src/main/java/com/baeldung/singleton/EnumSingleton.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/singleton/Sandbox.java b/patterns/design-patterns-creational/src/main/java/com/baeldung/singleton/Sandbox.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/singleton/Sandbox.java rename to patterns/design-patterns-creational/src/main/java/com/baeldung/singleton/Sandbox.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/singleton/synchronization/DclSingleton.java b/patterns/design-patterns-creational/src/main/java/com/baeldung/singleton/synchronization/DclSingleton.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/singleton/synchronization/DclSingleton.java rename to patterns/design-patterns-creational/src/main/java/com/baeldung/singleton/synchronization/DclSingleton.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/singleton/synchronization/DraconianSingleton.java b/patterns/design-patterns-creational/src/main/java/com/baeldung/singleton/synchronization/DraconianSingleton.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/singleton/synchronization/DraconianSingleton.java rename to patterns/design-patterns-creational/src/main/java/com/baeldung/singleton/synchronization/DraconianSingleton.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/singleton/synchronization/EarlyInitSingleton.java b/patterns/design-patterns-creational/src/main/java/com/baeldung/singleton/synchronization/EarlyInitSingleton.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/singleton/synchronization/EarlyInitSingleton.java rename to patterns/design-patterns-creational/src/main/java/com/baeldung/singleton/synchronization/EarlyInitSingleton.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/singleton/synchronization/EnumSingleton.java b/patterns/design-patterns-creational/src/main/java/com/baeldung/singleton/synchronization/EnumSingleton.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/singleton/synchronization/EnumSingleton.java rename to patterns/design-patterns-creational/src/main/java/com/baeldung/singleton/synchronization/EnumSingleton.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/singleton/synchronization/InitOnDemandSingleton.java b/patterns/design-patterns-creational/src/main/java/com/baeldung/singleton/synchronization/InitOnDemandSingleton.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/singleton/synchronization/InitOnDemandSingleton.java rename to patterns/design-patterns-creational/src/main/java/com/baeldung/singleton/synchronization/InitOnDemandSingleton.java diff --git a/patterns/design-patterns/src/test/java/com/baeldung/constructorsstaticfactorymethods/UserUnitTest.java b/patterns/design-patterns-creational/src/test/java/com/baeldung/constructorsstaticfactorymethods/UserUnitTest.java similarity index 97% rename from patterns/design-patterns/src/test/java/com/baeldung/constructorsstaticfactorymethods/UserUnitTest.java rename to patterns/design-patterns-creational/src/test/java/com/baeldung/constructorsstaticfactorymethods/UserUnitTest.java index 0c0266a111..ee8698b18d 100644 --- a/patterns/design-patterns/src/test/java/com/baeldung/constructorsstaticfactorymethods/UserUnitTest.java +++ b/patterns/design-patterns-creational/src/test/java/com/baeldung/constructorsstaticfactorymethods/UserUnitTest.java @@ -1,43 +1,43 @@ -package com.baeldung.constructorsstaticfactorymethods; - -import com.baeldung.constructorsstaticfactorymethods.entities.User; -import static org.assertj.core.api.Assertions.assertThat; -import org.junit.Test; - -public class UserUnitTest { - - @Test - public void givenUserClass_whenCalledcreateWithDefaultCountry_thenCorrect() { - assertThat(User.createWithDefaultCountry("John", "john@domain.com")).isInstanceOf(User.class); - } - - @Test - public void givenUserIntanceCreatedWithcreateWithDefaultCountry_whenCalledgetName_thenCorrect() { - User user = User.createWithDefaultCountry("John", "john@domain.com"); - assertThat(user.getName()).isEqualTo("John"); - } - - @Test - public void givenUserIntanceCreatedWithcreateWithDefaultCountry_whenCalledgetEmail_thenCorrect() { - User user = User.createWithDefaultCountry("John", "john@domain.com"); - assertThat(user.getEmail()).isEqualTo("john@domain.com"); - } - - @Test - public void givenUserIntanceCreatedWithcreateWithDefaultCountry_whenCalledgetCountry_thenCorrect() { - User user = User.createWithDefaultCountry("John", "john@domain.com"); - assertThat(user.getCountry()).isEqualTo("Argentina"); - } - - @Test - public void givenUserInstanceCreatedWithcreateWithInstantiationTime_whenCalledcreateWithInstantiationTime_thenCorrect() { - assertThat(User.createWithLoggedInstantiationTime("John", "john@domain.com", "Argentina")).isInstanceOf(User.class); - } - - @Test - public void givenUserInstanceCreatedWithgetSingletonIntance_whenCalledgetSingletonInstance_thenCorrect() { - User user1 = User.getSingletonInstance("John", "john@domain.com", "Argentina"); - User user2 = User.getSingletonInstance("John", "john@domain.com", "Argentina"); - assertThat(user1).isEqualTo(user2); - } +package com.baeldung.constructorsstaticfactorymethods; + +import com.baeldung.constructorsstaticfactorymethods.entities.User; +import static org.assertj.core.api.Assertions.assertThat; +import org.junit.Test; + +public class UserUnitTest { + + @Test + public void givenUserClass_whenCalledcreateWithDefaultCountry_thenCorrect() { + assertThat(User.createWithDefaultCountry("John", "john@domain.com")).isInstanceOf(User.class); + } + + @Test + public void givenUserIntanceCreatedWithcreateWithDefaultCountry_whenCalledgetName_thenCorrect() { + User user = User.createWithDefaultCountry("John", "john@domain.com"); + assertThat(user.getName()).isEqualTo("John"); + } + + @Test + public void givenUserIntanceCreatedWithcreateWithDefaultCountry_whenCalledgetEmail_thenCorrect() { + User user = User.createWithDefaultCountry("John", "john@domain.com"); + assertThat(user.getEmail()).isEqualTo("john@domain.com"); + } + + @Test + public void givenUserIntanceCreatedWithcreateWithDefaultCountry_whenCalledgetCountry_thenCorrect() { + User user = User.createWithDefaultCountry("John", "john@domain.com"); + assertThat(user.getCountry()).isEqualTo("Argentina"); + } + + @Test + public void givenUserInstanceCreatedWithcreateWithInstantiationTime_whenCalledcreateWithInstantiationTime_thenCorrect() { + assertThat(User.createWithLoggedInstantiationTime("John", "john@domain.com", "Argentina")).isInstanceOf(User.class); + } + + @Test + public void givenUserInstanceCreatedWithgetSingletonIntance_whenCalledgetSingletonInstance_thenCorrect() { + User user1 = User.getSingletonInstance("John", "john@domain.com", "Argentina"); + User user2 = User.getSingletonInstance("John", "john@domain.com", "Argentina"); + assertThat(user1).isEqualTo(user2); + } } \ No newline at end of file diff --git a/patterns/design-patterns/src/test/java/com/baeldung/creational/abstractfactory/AbstractPatternIntegrationTest.java b/patterns/design-patterns-creational/src/test/java/com/baeldung/creational/abstractfactory/AbstractPatternIntegrationTest.java similarity index 100% rename from patterns/design-patterns/src/test/java/com/baeldung/creational/abstractfactory/AbstractPatternIntegrationTest.java rename to patterns/design-patterns-creational/src/test/java/com/baeldung/creational/abstractfactory/AbstractPatternIntegrationTest.java diff --git a/patterns/design-patterns/src/test/java/com/baeldung/creational/builder/BuilderPatternIntegrationTest.java b/patterns/design-patterns-creational/src/test/java/com/baeldung/creational/builder/BuilderPatternIntegrationTest.java similarity index 100% rename from patterns/design-patterns/src/test/java/com/baeldung/creational/builder/BuilderPatternIntegrationTest.java rename to patterns/design-patterns-creational/src/test/java/com/baeldung/creational/builder/BuilderPatternIntegrationTest.java diff --git a/patterns/design-patterns/src/test/java/com/baeldung/creational/factory/FactoryIntegrationTest.java b/patterns/design-patterns-creational/src/test/java/com/baeldung/creational/factory/FactoryIntegrationTest.java similarity index 100% rename from patterns/design-patterns/src/test/java/com/baeldung/creational/factory/FactoryIntegrationTest.java rename to patterns/design-patterns-creational/src/test/java/com/baeldung/creational/factory/FactoryIntegrationTest.java diff --git a/patterns/design-patterns/src/test/java/com/baeldung/creational/singleton/SingletonIntegrationTest.java b/patterns/design-patterns-creational/src/test/java/com/baeldung/creational/singleton/SingletonIntegrationTest.java similarity index 100% rename from patterns/design-patterns/src/test/java/com/baeldung/creational/singleton/SingletonIntegrationTest.java rename to patterns/design-patterns-creational/src/test/java/com/baeldung/creational/singleton/SingletonIntegrationTest.java diff --git a/patterns/design-patterns/src/test/java/com/baeldung/flyweight/FlyweightUnitTest.java b/patterns/design-patterns-creational/src/test/java/com/baeldung/flyweight/FlyweightUnitTest.java similarity index 100% rename from patterns/design-patterns/src/test/java/com/baeldung/flyweight/FlyweightUnitTest.java rename to patterns/design-patterns-creational/src/test/java/com/baeldung/flyweight/FlyweightUnitTest.java diff --git a/patterns/design-patterns-2/src/test/java/com/baeldung/freebuilder/EmployeeBuilderUnitTest.java b/patterns/design-patterns-creational/src/test/java/com/baeldung/freebuilder/EmployeeBuilderUnitTest.java similarity index 100% rename from patterns/design-patterns-2/src/test/java/com/baeldung/freebuilder/EmployeeBuilderUnitTest.java rename to patterns/design-patterns-creational/src/test/java/com/baeldung/freebuilder/EmployeeBuilderUnitTest.java diff --git a/patterns/design-patterns-2/src/test/java/com/baeldung/freebuilder/builder/EmployeeBuilderUnitTest.java b/patterns/design-patterns-creational/src/test/java/com/baeldung/freebuilder/builder/EmployeeBuilderUnitTest.java similarity index 100% rename from patterns/design-patterns-2/src/test/java/com/baeldung/freebuilder/builder/EmployeeBuilderUnitTest.java rename to patterns/design-patterns-creational/src/test/java/com/baeldung/freebuilder/builder/EmployeeBuilderUnitTest.java diff --git a/patterns/design-patterns/src/test/java/com/baeldung/singleton/synchronization/SingletonSynchronizationIntegrationTest.java b/patterns/design-patterns-creational/src/test/java/com/baeldung/singleton/synchronization/SingletonSynchronizationIntegrationTest.java similarity index 100% rename from patterns/design-patterns/src/test/java/com/baeldung/singleton/synchronization/SingletonSynchronizationIntegrationTest.java rename to patterns/design-patterns-creational/src/test/java/com/baeldung/singleton/synchronization/SingletonSynchronizationIntegrationTest.java diff --git a/patterns/design-patterns-functional/README.md b/patterns/design-patterns-functional/README.md new file mode 100644 index 0000000000..04e21bafd5 --- /dev/null +++ b/patterns/design-patterns-functional/README.md @@ -0,0 +1,2 @@ +### Relevant Articles: +- [Currying in Java](https://www.baeldung.com/java-currying) diff --git a/patterns/design-patterns-functional/pom.xml b/patterns/design-patterns-functional/pom.xml new file mode 100644 index 0000000000..5df7cc0cb9 --- /dev/null +++ b/patterns/design-patterns-functional/pom.xml @@ -0,0 +1,25 @@ + + + 4.0.0 + design-patterns-functional + 1.0 + design-patterns-functional + jar + + + com.baeldung + patterns + 1.0.0-SNAPSHOT + .. + + + + + + + UTF-8 + 1.8 + 1.8 + + diff --git a/patterns/design-patterns/src/main/java/com/baeldung/currying/Letter.java b/patterns/design-patterns-functional/src/main/java/com/baeldung/currying/Letter.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/currying/Letter.java rename to patterns/design-patterns-functional/src/main/java/com/baeldung/currying/Letter.java diff --git a/patterns/design-patterns/src/test/java/com/baeldung/currying/LetterUnitTest.java b/patterns/design-patterns-functional/src/test/java/com/baeldung/currying/LetterUnitTest.java similarity index 100% rename from patterns/design-patterns/src/test/java/com/baeldung/currying/LetterUnitTest.java rename to patterns/design-patterns-functional/src/test/java/com/baeldung/currying/LetterUnitTest.java diff --git a/patterns/design-patterns-structural/README.md b/patterns/design-patterns-structural/README.md new file mode 100644 index 0000000000..91620a522e --- /dev/null +++ b/patterns/design-patterns-structural/README.md @@ -0,0 +1,7 @@ +### Relevant Articles: +- [Facade Design Pattern in Java](https://www.baeldung.com/java-facade-pattern) +- [Proxy, Decorator, Adapter and Bridge Patterns](https://www.baeldung.com/java-structural-design-patterns) +- [Composite Design Pattern in Java](https://www.baeldung.com/java-composite-pattern) +- [The Decorator Pattern in Java](https://www.baeldung.com/java-decorator-pattern) +- [The Adapter Pattern in Java](https://www.baeldung.com/java-adapter-pattern) +- [The Proxy Pattern in Java](https://www.baeldung.com/java-proxy-pattern) diff --git a/patterns/design-patterns-structural/pom.xml b/patterns/design-patterns-structural/pom.xml new file mode 100644 index 0000000000..63806058c9 --- /dev/null +++ b/patterns/design-patterns-structural/pom.xml @@ -0,0 +1,30 @@ + + + 4.0.0 + design-patterns-structural + 1.0 + design-patterns-structural + jar + + + com.baeldung + patterns + 1.0.0-SNAPSHOT + .. + + + + + log4j + log4j + ${log4j.version} + + + + + UTF-8 + 1.8 + 1.8 + + diff --git a/patterns/design-patterns/src/main/java/com/baeldung/adapter/AdapterPatternDriver.java b/patterns/design-patterns-structural/src/main/java/com/baeldung/adapter/AdapterPatternDriver.java similarity index 94% rename from patterns/design-patterns/src/main/java/com/baeldung/adapter/AdapterPatternDriver.java rename to patterns/design-patterns-structural/src/main/java/com/baeldung/adapter/AdapterPatternDriver.java index a4e10a0868..9f696a5f40 100644 --- a/patterns/design-patterns/src/main/java/com/baeldung/adapter/AdapterPatternDriver.java +++ b/patterns/design-patterns-structural/src/main/java/com/baeldung/adapter/AdapterPatternDriver.java @@ -1,6 +1,6 @@ package com.baeldung.adapter; -import static com.baeldung.util.LogerUtil.LOG; +import static com.baeldung.util.LoggerUtil.LOG; public class AdapterPatternDriver { diff --git a/patterns/design-patterns/src/main/java/com/baeldung/adapter/AstonMartin.java b/patterns/design-patterns-structural/src/main/java/com/baeldung/adapter/AstonMartin.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/adapter/AstonMartin.java rename to patterns/design-patterns-structural/src/main/java/com/baeldung/adapter/AstonMartin.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/adapter/BugattiVeyron.java b/patterns/design-patterns-structural/src/main/java/com/baeldung/adapter/BugattiVeyron.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/adapter/BugattiVeyron.java rename to patterns/design-patterns-structural/src/main/java/com/baeldung/adapter/BugattiVeyron.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/adapter/McLaren.java b/patterns/design-patterns-structural/src/main/java/com/baeldung/adapter/McLaren.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/adapter/McLaren.java rename to patterns/design-patterns-structural/src/main/java/com/baeldung/adapter/McLaren.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/adapter/Movable.java b/patterns/design-patterns-structural/src/main/java/com/baeldung/adapter/Movable.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/adapter/Movable.java rename to patterns/design-patterns-structural/src/main/java/com/baeldung/adapter/Movable.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/adapter/MovableAdapter.java b/patterns/design-patterns-structural/src/main/java/com/baeldung/adapter/MovableAdapter.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/adapter/MovableAdapter.java rename to patterns/design-patterns-structural/src/main/java/com/baeldung/adapter/MovableAdapter.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/adapter/MovableAdapterImpl.java b/patterns/design-patterns-structural/src/main/java/com/baeldung/adapter/MovableAdapterImpl.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/adapter/MovableAdapterImpl.java rename to patterns/design-patterns-structural/src/main/java/com/baeldung/adapter/MovableAdapterImpl.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/bridge/Blue.java b/patterns/design-patterns-structural/src/main/java/com/baeldung/bridge/Blue.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/bridge/Blue.java rename to patterns/design-patterns-structural/src/main/java/com/baeldung/bridge/Blue.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/bridge/BridgePatternDriver.java b/patterns/design-patterns-structural/src/main/java/com/baeldung/bridge/BridgePatternDriver.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/bridge/BridgePatternDriver.java rename to patterns/design-patterns-structural/src/main/java/com/baeldung/bridge/BridgePatternDriver.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/bridge/Color.java b/patterns/design-patterns-structural/src/main/java/com/baeldung/bridge/Color.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/bridge/Color.java rename to patterns/design-patterns-structural/src/main/java/com/baeldung/bridge/Color.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/bridge/Red.java b/patterns/design-patterns-structural/src/main/java/com/baeldung/bridge/Red.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/bridge/Red.java rename to patterns/design-patterns-structural/src/main/java/com/baeldung/bridge/Red.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/bridge/Shape.java b/patterns/design-patterns-structural/src/main/java/com/baeldung/bridge/Shape.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/bridge/Shape.java rename to patterns/design-patterns-structural/src/main/java/com/baeldung/bridge/Shape.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/bridge/Square.java b/patterns/design-patterns-structural/src/main/java/com/baeldung/bridge/Square.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/bridge/Square.java rename to patterns/design-patterns-structural/src/main/java/com/baeldung/bridge/Square.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/bridge/Triangle.java b/patterns/design-patterns-structural/src/main/java/com/baeldung/bridge/Triangle.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/bridge/Triangle.java rename to patterns/design-patterns-structural/src/main/java/com/baeldung/bridge/Triangle.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/composite/CompositeDemo.java b/patterns/design-patterns-structural/src/main/java/com/baeldung/composite/CompositeDemo.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/composite/CompositeDemo.java rename to patterns/design-patterns-structural/src/main/java/com/baeldung/composite/CompositeDemo.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/composite/Department.java b/patterns/design-patterns-structural/src/main/java/com/baeldung/composite/Department.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/composite/Department.java rename to patterns/design-patterns-structural/src/main/java/com/baeldung/composite/Department.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/composite/FinancialDepartment.java b/patterns/design-patterns-structural/src/main/java/com/baeldung/composite/FinancialDepartment.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/composite/FinancialDepartment.java rename to patterns/design-patterns-structural/src/main/java/com/baeldung/composite/FinancialDepartment.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/composite/HeadDepartment.java b/patterns/design-patterns-structural/src/main/java/com/baeldung/composite/HeadDepartment.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/composite/HeadDepartment.java rename to patterns/design-patterns-structural/src/main/java/com/baeldung/composite/HeadDepartment.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/composite/SalesDepartment.java b/patterns/design-patterns-structural/src/main/java/com/baeldung/composite/SalesDepartment.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/composite/SalesDepartment.java rename to patterns/design-patterns-structural/src/main/java/com/baeldung/composite/SalesDepartment.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/decorator/BubbleLights.java b/patterns/design-patterns-structural/src/main/java/com/baeldung/decorator/BubbleLights.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/decorator/BubbleLights.java rename to patterns/design-patterns-structural/src/main/java/com/baeldung/decorator/BubbleLights.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/decorator/ChristmasTree.java b/patterns/design-patterns-structural/src/main/java/com/baeldung/decorator/ChristmasTree.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/decorator/ChristmasTree.java rename to patterns/design-patterns-structural/src/main/java/com/baeldung/decorator/ChristmasTree.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/decorator/ChristmasTreeImpl.java b/patterns/design-patterns-structural/src/main/java/com/baeldung/decorator/ChristmasTreeImpl.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/decorator/ChristmasTreeImpl.java rename to patterns/design-patterns-structural/src/main/java/com/baeldung/decorator/ChristmasTreeImpl.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/decorator/DecoratorPatternDriver.java b/patterns/design-patterns-structural/src/main/java/com/baeldung/decorator/DecoratorPatternDriver.java similarity index 90% rename from patterns/design-patterns/src/main/java/com/baeldung/decorator/DecoratorPatternDriver.java rename to patterns/design-patterns-structural/src/main/java/com/baeldung/decorator/DecoratorPatternDriver.java index c20c23ff6e..6a9da7c78c 100644 --- a/patterns/design-patterns/src/main/java/com/baeldung/decorator/DecoratorPatternDriver.java +++ b/patterns/design-patterns-structural/src/main/java/com/baeldung/decorator/DecoratorPatternDriver.java @@ -1,6 +1,6 @@ package com.baeldung.decorator; -import static com.baeldung.util.LogerUtil.LOG; +import static com.baeldung.util.LoggerUtil.LOG; public class DecoratorPatternDriver { diff --git a/patterns/design-patterns/src/main/java/com/baeldung/decorator/Garland.java b/patterns/design-patterns-structural/src/main/java/com/baeldung/decorator/Garland.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/decorator/Garland.java rename to patterns/design-patterns-structural/src/main/java/com/baeldung/decorator/Garland.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/decorator/TreeDecorator.java b/patterns/design-patterns-structural/src/main/java/com/baeldung/decorator/TreeDecorator.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/decorator/TreeDecorator.java rename to patterns/design-patterns-structural/src/main/java/com/baeldung/decorator/TreeDecorator.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/facade/CarEngineFacade.java b/patterns/design-patterns-structural/src/main/java/com/baeldung/facade/CarEngineFacade.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/facade/CarEngineFacade.java rename to patterns/design-patterns-structural/src/main/java/com/baeldung/facade/CarEngineFacade.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/facade/carsystem/AirFlowController.java b/patterns/design-patterns-structural/src/main/java/com/baeldung/facade/carsystem/AirFlowController.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/facade/carsystem/AirFlowController.java rename to patterns/design-patterns-structural/src/main/java/com/baeldung/facade/carsystem/AirFlowController.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/facade/carsystem/AirFlowMeter.java b/patterns/design-patterns-structural/src/main/java/com/baeldung/facade/carsystem/AirFlowMeter.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/facade/carsystem/AirFlowMeter.java rename to patterns/design-patterns-structural/src/main/java/com/baeldung/facade/carsystem/AirFlowMeter.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/facade/carsystem/CatalyticConverter.java b/patterns/design-patterns-structural/src/main/java/com/baeldung/facade/carsystem/CatalyticConverter.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/facade/carsystem/CatalyticConverter.java rename to patterns/design-patterns-structural/src/main/java/com/baeldung/facade/carsystem/CatalyticConverter.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/facade/carsystem/CoolingController.java b/patterns/design-patterns-structural/src/main/java/com/baeldung/facade/carsystem/CoolingController.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/facade/carsystem/CoolingController.java rename to patterns/design-patterns-structural/src/main/java/com/baeldung/facade/carsystem/CoolingController.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/facade/carsystem/FuelInjector.java b/patterns/design-patterns-structural/src/main/java/com/baeldung/facade/carsystem/FuelInjector.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/facade/carsystem/FuelInjector.java rename to patterns/design-patterns-structural/src/main/java/com/baeldung/facade/carsystem/FuelInjector.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/facade/carsystem/FuelPump.java b/patterns/design-patterns-structural/src/main/java/com/baeldung/facade/carsystem/FuelPump.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/facade/carsystem/FuelPump.java rename to patterns/design-patterns-structural/src/main/java/com/baeldung/facade/carsystem/FuelPump.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/facade/carsystem/Radiator.java b/patterns/design-patterns-structural/src/main/java/com/baeldung/facade/carsystem/Radiator.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/facade/carsystem/Radiator.java rename to patterns/design-patterns-structural/src/main/java/com/baeldung/facade/carsystem/Radiator.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/facade/carsystem/Starter.java b/patterns/design-patterns-structural/src/main/java/com/baeldung/facade/carsystem/Starter.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/facade/carsystem/Starter.java rename to patterns/design-patterns-structural/src/main/java/com/baeldung/facade/carsystem/Starter.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/facade/carsystem/TemperatureSensor.java b/patterns/design-patterns-structural/src/main/java/com/baeldung/facade/carsystem/TemperatureSensor.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/facade/carsystem/TemperatureSensor.java rename to patterns/design-patterns-structural/src/main/java/com/baeldung/facade/carsystem/TemperatureSensor.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/proxy/ExpensiveObject.java b/patterns/design-patterns-structural/src/main/java/com/baeldung/proxy/ExpensiveObject.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/proxy/ExpensiveObject.java rename to patterns/design-patterns-structural/src/main/java/com/baeldung/proxy/ExpensiveObject.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/proxy/ExpensiveObjectImpl.java b/patterns/design-patterns-structural/src/main/java/com/baeldung/proxy/ExpensiveObjectImpl.java similarity index 88% rename from patterns/design-patterns/src/main/java/com/baeldung/proxy/ExpensiveObjectImpl.java rename to patterns/design-patterns-structural/src/main/java/com/baeldung/proxy/ExpensiveObjectImpl.java index 7ade31da88..6d38672a63 100644 --- a/patterns/design-patterns/src/main/java/com/baeldung/proxy/ExpensiveObjectImpl.java +++ b/patterns/design-patterns-structural/src/main/java/com/baeldung/proxy/ExpensiveObjectImpl.java @@ -1,6 +1,6 @@ package com.baeldung.proxy; -import static com.baeldung.util.LogerUtil.LOG;; +import static com.baeldung.util.LoggerUtil.LOG; public class ExpensiveObjectImpl implements ExpensiveObject { diff --git a/patterns/design-patterns/src/main/java/com/baeldung/proxy/ExpensiveObjectProxy.java b/patterns/design-patterns-structural/src/main/java/com/baeldung/proxy/ExpensiveObjectProxy.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/proxy/ExpensiveObjectProxy.java rename to patterns/design-patterns-structural/src/main/java/com/baeldung/proxy/ExpensiveObjectProxy.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/proxy/ProxyPatternDriver.java b/patterns/design-patterns-structural/src/main/java/com/baeldung/proxy/ProxyPatternDriver.java similarity index 100% rename from patterns/design-patterns/src/main/java/com/baeldung/proxy/ProxyPatternDriver.java rename to patterns/design-patterns-structural/src/main/java/com/baeldung/proxy/ProxyPatternDriver.java diff --git a/patterns/design-patterns/src/main/java/com/baeldung/util/LogerUtil.java b/patterns/design-patterns-structural/src/main/java/com/baeldung/util/LoggerUtil.java similarity index 87% rename from patterns/design-patterns/src/main/java/com/baeldung/util/LogerUtil.java rename to patterns/design-patterns-structural/src/main/java/com/baeldung/util/LoggerUtil.java index 7217a4bc40..9702cba0f5 100644 --- a/patterns/design-patterns/src/main/java/com/baeldung/util/LogerUtil.java +++ b/patterns/design-patterns-structural/src/main/java/com/baeldung/util/LoggerUtil.java @@ -8,7 +8,7 @@ import java.util.Properties; import org.apache.log4j.Logger; import org.apache.log4j.PropertyConfigurator; -public class LogerUtil { +public class LoggerUtil { public final static Logger LOG = Logger.getLogger("GLOBAL"); @@ -22,7 +22,7 @@ public class LogerUtil { props.load( new BufferedReader( new InputStreamReader( - LogerUtil.class.getResourceAsStream("/log4jstructuraldp.properties") + LoggerUtil.class.getResourceAsStream("/log4jstructuraldp.properties") ) ) ); diff --git a/patterns/design-patterns/src/main/resources/log4jstructuraldp.properties b/patterns/design-patterns-structural/src/main/resources/log4jstructuraldp.properties similarity index 100% rename from patterns/design-patterns/src/main/resources/log4jstructuraldp.properties rename to patterns/design-patterns-structural/src/main/resources/log4jstructuraldp.properties diff --git a/patterns/design-patterns/src/test/java/com/baeldung/AdapterPatternIntegrationTest.java b/patterns/design-patterns-structural/src/test/java/com/baeldung/adapter/AdapterPatternIntegrationTest.java similarity index 75% rename from patterns/design-patterns/src/test/java/com/baeldung/AdapterPatternIntegrationTest.java rename to patterns/design-patterns-structural/src/test/java/com/baeldung/adapter/AdapterPatternIntegrationTest.java index 78a1492d83..536caf7341 100644 --- a/patterns/design-patterns/src/test/java/com/baeldung/AdapterPatternIntegrationTest.java +++ b/patterns/design-patterns-structural/src/test/java/com/baeldung/adapter/AdapterPatternIntegrationTest.java @@ -1,16 +1,9 @@ -package com.baeldung; +package com.baeldung.adapter; import static org.junit.Assert.assertEquals; import org.junit.Test; -import com.baeldung.adapter.AstonMartin; -import com.baeldung.adapter.BugattiVeyron; -import com.baeldung.adapter.McLaren; -import com.baeldung.adapter.Movable; -import com.baeldung.adapter.MovableAdapter; -import com.baeldung.adapter.MovableAdapterImpl; - public class AdapterPatternIntegrationTest { @Test public void givenMovableAdapter_WhenConvertingMPHToKMPH_thenSuccessfullyConverted() { diff --git a/patterns/design-patterns/src/test/java/com/baeldung/BridgePatternIntegrationTest.java b/patterns/design-patterns-structural/src/test/java/com/baeldung/bridge/BridgePatternIntegrationTest.java similarity index 72% rename from patterns/design-patterns/src/test/java/com/baeldung/BridgePatternIntegrationTest.java rename to patterns/design-patterns-structural/src/test/java/com/baeldung/bridge/BridgePatternIntegrationTest.java index adcb5cdd2c..814a91c070 100644 --- a/patterns/design-patterns/src/test/java/com/baeldung/BridgePatternIntegrationTest.java +++ b/patterns/design-patterns-structural/src/test/java/com/baeldung/bridge/BridgePatternIntegrationTest.java @@ -1,15 +1,9 @@ -package com.baeldung; +package com.baeldung.bridge; import static org.junit.Assert.*; import org.junit.Test; -import com.baeldung.bridge.Blue; -import com.baeldung.bridge.Red; -import com.baeldung.bridge.Shape; -import com.baeldung.bridge.Square; -import com.baeldung.bridge.Triangle; - public class BridgePatternIntegrationTest { @Test diff --git a/patterns/design-patterns/src/test/java/com/baeldung/DecoratorPatternIntegrationTest.java b/patterns/design-patterns-structural/src/test/java/com/baeldung/decorator/DecoratorPatternIntegrationTest.java similarity index 75% rename from patterns/design-patterns/src/test/java/com/baeldung/DecoratorPatternIntegrationTest.java rename to patterns/design-patterns-structural/src/test/java/com/baeldung/decorator/DecoratorPatternIntegrationTest.java index 23a717ae2e..0f2e262346 100644 --- a/patterns/design-patterns/src/test/java/com/baeldung/DecoratorPatternIntegrationTest.java +++ b/patterns/design-patterns-structural/src/test/java/com/baeldung/decorator/DecoratorPatternIntegrationTest.java @@ -1,14 +1,9 @@ -package com.baeldung; +package com.baeldung.decorator; import static org.junit.Assert.assertEquals; import org.junit.Test; -import com.baeldung.decorator.BubbleLights; -import com.baeldung.decorator.ChristmasTree; -import com.baeldung.decorator.ChristmasTreeImpl; -import com.baeldung.decorator.Garland; - public class DecoratorPatternIntegrationTest { @Test public void givenDecoratorPattern_WhenDecoratorsInjectedAtRuntime_thenConfigSuccess() { diff --git a/patterns/design-patterns/src/test/java/com/baeldung/facade/CarEngineFacadeIntegrationTest.java b/patterns/design-patterns-structural/src/test/java/com/baeldung/facade/CarEngineFacadeIntegrationTest.java similarity index 100% rename from patterns/design-patterns/src/test/java/com/baeldung/facade/CarEngineFacadeIntegrationTest.java rename to patterns/design-patterns-structural/src/test/java/com/baeldung/facade/CarEngineFacadeIntegrationTest.java diff --git a/patterns/design-patterns/src/test/java/com/baeldung/ProxyPatternIntegrationTest.java b/patterns/design-patterns-structural/src/test/java/com/baeldung/proxy/ProxyPatternIntegrationTest.java similarity index 87% rename from patterns/design-patterns/src/test/java/com/baeldung/ProxyPatternIntegrationTest.java rename to patterns/design-patterns-structural/src/test/java/com/baeldung/proxy/ProxyPatternIntegrationTest.java index c035793b64..6db19f7cea 100644 --- a/patterns/design-patterns/src/test/java/com/baeldung/ProxyPatternIntegrationTest.java +++ b/patterns/design-patterns-structural/src/test/java/com/baeldung/proxy/ProxyPatternIntegrationTest.java @@ -1,6 +1,6 @@ -package com.baeldung; +package com.baeldung.proxy; -import static com.baeldung.util.LogerUtil.LOG; +import static com.baeldung.util.LoggerUtil.LOG; import static org.hamcrest.CoreMatchers.is; import static org.junit.Assert.assertThat; @@ -11,9 +11,6 @@ import org.junit.After; import org.junit.Before; import org.junit.Test; -import com.baeldung.proxy.ExpensiveObject; -import com.baeldung.proxy.ExpensiveObjectProxy; - public class ProxyPatternIntegrationTest { public static TestAppenderDP appender; diff --git a/patterns/design-patterns/src/test/java/com/baeldung/TestAppenderDP.java b/patterns/design-patterns-structural/src/test/java/com/baeldung/proxy/TestAppenderDP.java similarity index 95% rename from patterns/design-patterns/src/test/java/com/baeldung/TestAppenderDP.java rename to patterns/design-patterns-structural/src/test/java/com/baeldung/proxy/TestAppenderDP.java index 2b3bc47292..1c6d9a2064 100644 --- a/patterns/design-patterns/src/test/java/com/baeldung/TestAppenderDP.java +++ b/patterns/design-patterns-structural/src/test/java/com/baeldung/proxy/TestAppenderDP.java @@ -1,4 +1,4 @@ -package com.baeldung; +package com.baeldung.proxy; import java.util.ArrayList; import java.util.List; diff --git a/patterns/design-patterns/README.md b/patterns/design-patterns/README.md deleted file mode 100644 index 1c611f05d2..0000000000 --- a/patterns/design-patterns/README.md +++ /dev/null @@ -1,23 +0,0 @@ -### Relevant Articles: -- [Facade Design Pattern in Java](http://www.baeldung.com/java-facade-pattern) -- [Singletons in Java](http://www.baeldung.com/java-singleton) -- [Proxy, Decorator, Adapter and Bridge Patterns](http://www.baeldung.com/java-structural-design-patterns) -- [Introduction to Creational Design Patterns](http://www.baeldung.com/creational-design-patterns) -- [The Observer Pattern in Java](http://www.baeldung.com/java-observer-pattern) -- [Flyweight Pattern in Java](http://www.baeldung.com/java-flyweight) -- [Service Locator Pattern](http://www.baeldung.com/java-service-locator-pattern) -- [Double-Checked Locking with Singleton](http://www.baeldung.com/java-singleton-double-checked-locking) -- [Composite Design Pattern in Java](http://www.baeldung.com/java-composite-pattern) -- [Visitor Design Pattern in Java](http://www.baeldung.com/java-visitor-pattern) -- [The DAO Pattern in Java](http://www.baeldung.com/java-dao-pattern) -- [Interpreter Design Pattern in Java](http://www.baeldung.com/java-interpreter-pattern) -- [State Design Pattern in Java](https://www.baeldung.com/java-state-design-pattern) -- [The Decorator Pattern in Java](https://www.baeldung.com/java-decorator-pattern) -- [Abstract Factory Pattern in Java](https://www.baeldung.com/java-abstract-factory-pattern) -- [Implementing the Template Method Pattern in Java](http://www.baeldung.com/java-template-method-pattern) -- [Chain of Responsibility Design Pattern in Java](http://www.baeldung.com/chain-of-responsibility-pattern) -- [The Command Pattern in Java](http://www.baeldung.com/java-command-pattern) -- [Java Constructors vs Static Factory Methods](https://www.baeldung.com/java-constructors-vs-static-factory-methods) -- [The Adapter Pattern in Java](https://www.baeldung.com/java-adapter-pattern) -- [Currying in Java](https://www.baeldung.com/java-currying) -- [The Proxy Pattern in Java](https://www.baeldung.com/java-proxy-pattern) diff --git a/patterns/pom.xml b/patterns/pom.xml index 7f7368ca07..196c3c3319 100644 --- a/patterns/pom.xml +++ b/patterns/pom.xml @@ -16,8 +16,12 @@ front-controller intercepting-filter - design-patterns - design-patterns-2 + design-patterns-architectural + design-patterns-behavioral + design-patterns-behavioral-2 + design-patterns-creational + design-patterns-functional + design-patterns-structural solid dip backoff-jitter