diff --git a/dao/src/main/java/com/iluwatar/dao/App.java b/dao/src/main/java/com/iluwatar/dao/App.java index 78406208a..9faa8577a 100644 --- a/dao/src/main/java/com/iluwatar/dao/App.java +++ b/dao/src/main/java/com/iluwatar/dao/App.java @@ -26,12 +26,9 @@ package com.iluwatar.dao; import java.sql.Connection; import java.sql.SQLException; import java.sql.Statement; -import java.util.ArrayList; import java.util.List; import java.util.stream.Stream; - import javax.sql.DataSource; - import org.h2.jdbcx.JdbcDataSource; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -44,27 +41,25 @@ import org.slf4j.LoggerFactory; * application needs, in terms of domain-specific objects and data types (the public interface of * the DAO), from how these needs can be satisfied with a specific DBMS. * - *
With the DAO pattern, we can use various method calls to retrieve/add/delete/update data - * without directly interacting with the data source. The below example demonstrates basic CRUD + *
With the DAO pattern, we can use various method calls to retrieve/add/delete/update data
+ * without directly interacting with the data source. The below example demonstrates basic CRUD
* operations: select, add, update, and delete.
- *
- *
*/
public class App {
private static final String DB_URL = "jdbc:h2:~/dao";
private static Logger log = LoggerFactory.getLogger(App.class);
private static final String ALL_CUSTOMERS = "customerDao.getAllCustomers(): ";
-
+
/**
* Program entry point.
- *
+ *
* @param args command line args.
- * @throws Exception if any error occurs.
+ * @throws Exception if any error occurs.
*/
public static void main(final String[] args) throws Exception {
final CustomerDao inMemoryDao = new InMemoryCustomerDao();
performOperationsUsing(inMemoryDao);
-
+
final DataSource dataSource = createDataSource();
createSchema(dataSource);
final CustomerDao dbDao = new DbCustomerDao(dataSource);
@@ -74,14 +69,14 @@ public class App {
private static void deleteSchema(DataSource dataSource) throws SQLException {
try (Connection connection = dataSource.getConnection();
- Statement statement = connection.createStatement()) {
+ Statement statement = connection.createStatement()) {
statement.execute(CustomerSchemaSql.DELETE_SCHEMA_SQL);
}
}
private static void createSchema(DataSource dataSource) throws SQLException {
try (Connection connection = dataSource.getConnection();
- Statement statement = connection.createStatement()) {
+ Statement statement = connection.createStatement()) {
statement.execute(CustomerSchemaSql.CREATE_SCHEMA_SQL);
}
}
@@ -121,7 +116,7 @@ public class App {
/**
* Generate customers.
- *
+ *
* @return list of customers.
*/
public static List Any change in the way data is stored and retrieved will not change the client code as the
+ * that provides an interface to some type of persistence mechanism. By mapping application calls to
+ * the persistence layer, DAO provides some specific data operations without exposing details of the
+ * database. This isolation supports the Single responsibility principle. It separates what data
+ * accesses the application needs, in terms of domain-specific objects and data types (the public
+ * interface of the DAO), from how these needs can be satisfied with a specific DBMS, database
+ * schema, etc.
+ *
+ * Any change in the way data is stored and retrieved will not change the client code as the
* client will be using interface and need not worry about exact source.
- *
+ *
* @see InMemoryCustomerDao
* @see DbCustomerDao
*/
public interface CustomerDao {
/**
- * @return all the customers as a stream. The stream may be lazily or eagerly evaluated based
- * on the implementation. The stream must be closed after use.
+ * Get all customers.
+ *
+ * @return all the customers as a stream. The stream may be lazily or eagerly evaluated based on
+ * the implementation. The stream must be closed after use.
* @throws Exception if any error occurs.
*/
Stream
- * @see http://wiki.c2.com/?DataBusPattern
- * The Data-Bus pattern provides a method where different parts of an application may
- * pass messages between each other without needing to be aware of the other's existence. Similar to the {@code ObserverPattern}, members register themselves with the {@link DataBus}
- * and may then receive each piece of data that is published to the Data-Bus. The member
- * may react to any given message or not. It allows for Many-to-Many distribution of data, as there may be any number of
- * publishers to a Data-Bus, and any number of members receiving the data. All members
- * will receive the same data, the order each receives a given piece of data, is an
- * implementation detail. Members may unsubscribe from the Data-Bus to stop receiving data. This example of the pattern implements a Synchronous Data-Bus, meaning that
- * when data is published to the Data-Bus, the publish method will not return until
- * all members have received the data and returned. The {@link DataBus} class is a Singleton. Members of the Data-Bus must implement the {@link Member} interface. Data to be published via the Data-Bus must implement the {@link DataType} interface. The {@code data} package contains example {@link DataType} implementations. The {@code members} package contains example {@link Member} implementations. The {@link StatusMember} demonstrates using the DataBus to publish a message
- * to the Data-Bus when it receives a message. The Data-Bus pattern provides a method where different parts of an application may
+ * pass messages between each other without needing to be aware of the other's existence. Similar to the {@code ObserverPattern}, members register themselves with the {@link
+ * DataBus} and may then receive each piece of data that is published to the Data-Bus. The
+ * member may react to any given message or not. It allows for Many-to-Many distribution of data, as there may be any number of
+ * publishers to a Data-Bus, and any number of members receiving the data. All members will
+ * receive the same data, the order each receives a given piece of data, is an implementation
+ * detail. Members may unsubscribe from the Data-Bus to stop receiving data. This example of the pattern implements a Synchronous Data-Bus, meaning that
+ * when data is published to the Data-Bus, the publish method will not return until all members
+ * have received the data and returned. The {@link DataBus} class is a Singleton. Members of the Data-Bus must implement the {@link Member} interface. Data to be published via the Data-Bus must implement the {@link DataType} interface. The {@code data} package contains example {@link DataType} implementations. The {@code members} package contains example {@link Member} implementations. The {@link StatusMember} demonstrates using the DataBus to publish a message
+ * to the Data-Bus when it receives a message. Example: Game loop that processes a bunch of game entities. Those entities are decomposed
+ * into different domains — AI, physics, and rendering — using the Component pattern.
*/
public class Application {
private static final Logger LOGGER = LoggerFactory.getLogger(Application.class);
private static final int NUM_ENTITIES = 5;
+
/**
- * Start game loop with each component have NUM_ENTITIES instance
+ * Start game loop with each component have NUM_ENTITIES instance.
*/
public static void main(String[] args) {
LOGGER.info("Start Game Application using Data-Locality pattern");
diff --git a/data-locality/src/main/java/com/iluwatar/data/locality/game/GameEntity.java b/data-locality/src/main/java/com/iluwatar/data/locality/game/GameEntity.java
index 33f139948..337532175 100644
--- a/data-locality/src/main/java/com/iluwatar/data/locality/game/GameEntity.java
+++ b/data-locality/src/main/java/com/iluwatar/data/locality/game/GameEntity.java
@@ -30,14 +30,14 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
- * The game Entity maintains a big array of pointers .
- * Each spin of the game loop, we need to run the following:
+ * The game Entity maintains a big array of pointers . Each spin of the game loop, we need to run
+ * the following:
*
- * Update the AI components .
+ * Update the AI components.
*
- * Update the physics components for them.
+ * Update the physics components for them.
*
- * Render them using their render components.
+ * Render them using their render components.
*/
public class GameEntity {
private static final Logger LOGGER = LoggerFactory.getLogger(GameEntity.class);
@@ -47,7 +47,7 @@ public class GameEntity {
private final RenderComponentManager renderComponentManager;
/**
- * Init components
+ * Init components.
*/
public GameEntity(int numEntities) {
LOGGER.info("Init Game with #Entity : {}", numEntities);
@@ -57,7 +57,7 @@ public class GameEntity {
}
/**
- * start all component
+ * start all component.
*/
public void start() {
LOGGER.info("Start Game");
@@ -67,7 +67,7 @@ public class GameEntity {
}
/**
- * update all component
+ * update all component.
*/
public void update() {
LOGGER.info("Update Game Component");
@@ -80,5 +80,5 @@ public class GameEntity {
// Draw to screen.
renderComponentManager.render();
}
-
+
}
diff --git a/data-locality/src/main/java/com/iluwatar/data/locality/game/component/AiComponent.java b/data-locality/src/main/java/com/iluwatar/data/locality/game/component/AiComponent.java
index c31f2ce66..5b1be9e35 100644
--- a/data-locality/src/main/java/com/iluwatar/data/locality/game/component/AiComponent.java
+++ b/data-locality/src/main/java/com/iluwatar/data/locality/game/component/AiComponent.java
@@ -27,14 +27,14 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
- * Implementation of AI component for Game
+ * Implementation of AI component for Game.
*/
public class AiComponent implements Component {
-
+
private static final Logger LOGGER = LoggerFactory.getLogger(AiComponent.class);
/**
- * Update ai component
+ * Update ai component.
*/
@Override
public void update() {
diff --git a/data-locality/src/main/java/com/iluwatar/data/locality/game/component/Component.java b/data-locality/src/main/java/com/iluwatar/data/locality/game/component/Component.java
index c877fbe01..f159df4f6 100644
--- a/data-locality/src/main/java/com/iluwatar/data/locality/game/component/Component.java
+++ b/data-locality/src/main/java/com/iluwatar/data/locality/game/component/Component.java
@@ -24,7 +24,7 @@
package com.iluwatar.data.locality.game.component;
/**
- * Implement different Game component update and render process
+ * Implement different Game component update and render process.
*/
public interface Component {
diff --git a/data-locality/src/main/java/com/iluwatar/data/locality/game/component/PhysicsComponent.java b/data-locality/src/main/java/com/iluwatar/data/locality/game/component/PhysicsComponent.java
index 3c5f0950e..89c6f1503 100644
--- a/data-locality/src/main/java/com/iluwatar/data/locality/game/component/PhysicsComponent.java
+++ b/data-locality/src/main/java/com/iluwatar/data/locality/game/component/PhysicsComponent.java
@@ -27,13 +27,14 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
- * Implementation of Physics Component of Game
+ * Implementation of Physics Component of Game.
*/
public class PhysicsComponent implements Component {
private static final Logger LOGGER = LoggerFactory.getLogger(PhysicsComponent.class);
+
/**
- * update physics component of game
+ * update physics component of game.
*/
@Override
public void update() {
diff --git a/data-locality/src/main/java/com/iluwatar/data/locality/game/component/RenderComponent.java b/data-locality/src/main/java/com/iluwatar/data/locality/game/component/RenderComponent.java
index 0f3e0ca1a..0b49da056 100644
--- a/data-locality/src/main/java/com/iluwatar/data/locality/game/component/RenderComponent.java
+++ b/data-locality/src/main/java/com/iluwatar/data/locality/game/component/RenderComponent.java
@@ -27,7 +27,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
- * Implementation of Render Component of Game
+ * Implementation of Render Component of Game.
*/
public class RenderComponent implements Component {
@@ -39,7 +39,7 @@ public class RenderComponent implements Component {
}
/**
- * render
+ * render.
*/
@Override
public void render() {
diff --git a/data-locality/src/main/java/com/iluwatar/data/locality/game/component/manager/AiComponentManager.java b/data-locality/src/main/java/com/iluwatar/data/locality/game/component/manager/AiComponentManager.java
index 1fc5419cc..20fac0107 100644
--- a/data-locality/src/main/java/com/iluwatar/data/locality/game/component/manager/AiComponentManager.java
+++ b/data-locality/src/main/java/com/iluwatar/data/locality/game/component/manager/AiComponentManager.java
@@ -29,7 +29,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
- * AI component manager for Game
+ * AI component manager for Game.
*/
public class AiComponentManager {
@@ -46,7 +46,7 @@ public class AiComponentManager {
}
/**
- * start AI component of Game
+ * start AI component of Game.
*/
public void start() {
LOGGER.info("Start AI Game Component");
@@ -56,7 +56,7 @@ public class AiComponentManager {
}
/**
- * Update AI component of Game
+ * Update AI component of Game.
*/
public void update() {
LOGGER.info("Update AI Game Component");
diff --git a/data-locality/src/main/java/com/iluwatar/data/locality/game/component/manager/PhysicsComponentManager.java b/data-locality/src/main/java/com/iluwatar/data/locality/game/component/manager/PhysicsComponentManager.java
index 6ac6f5c09..36f762587 100644
--- a/data-locality/src/main/java/com/iluwatar/data/locality/game/component/manager/PhysicsComponentManager.java
+++ b/data-locality/src/main/java/com/iluwatar/data/locality/game/component/manager/PhysicsComponentManager.java
@@ -46,7 +46,7 @@ public class PhysicsComponentManager {
}
/**
- * Start physics component of Game
+ * Start physics component of Game.
*/
public void start() {
LOGGER.info("Start Physics Game Component ");
@@ -57,7 +57,7 @@ public class PhysicsComponentManager {
/**
- * Update physics component of Game
+ * Update physics component of Game.
*/
public void update() {
LOGGER.info("Update Physics Game Component ");
diff --git a/data-locality/src/main/java/com/iluwatar/data/locality/game/component/manager/RenderComponentManager.java b/data-locality/src/main/java/com/iluwatar/data/locality/game/component/manager/RenderComponentManager.java
index 7360f208b..fd6ef9640 100644
--- a/data-locality/src/main/java/com/iluwatar/data/locality/game/component/manager/RenderComponentManager.java
+++ b/data-locality/src/main/java/com/iluwatar/data/locality/game/component/manager/RenderComponentManager.java
@@ -29,7 +29,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
- * Render component manager for Game
+ * Render component manager for Game.
*/
public class RenderComponentManager {
@@ -46,7 +46,7 @@ public class RenderComponentManager {
}
/**
- * Start render component
+ * Start render component.
*/
public void start() {
LOGGER.info("Start Render Game Component ");
@@ -57,7 +57,7 @@ public class RenderComponentManager {
/**
- * render component
+ * render component.
*/
public void render() {
LOGGER.info("Update Render Game Component ");
diff --git a/data-mapper/src/main/java/com/iluwatar/datamapper/App.java b/data-mapper/src/main/java/com/iluwatar/datamapper/App.java
index 50857729a..49d6c63d3 100644
--- a/data-mapper/src/main/java/com/iluwatar/datamapper/App.java
+++ b/data-mapper/src/main/java/com/iluwatar/datamapper/App.java
@@ -23,11 +23,10 @@
package com.iluwatar.datamapper;
+import java.util.Optional;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.util.Optional;
-
/**
* The Data Mapper (DM) is a layer of software that separates the in-memory objects from the
* database. Its responsibility is to transfer data between the two and also to isolate them from
@@ -35,19 +34,18 @@ import java.util.Optional;
* present; they need no SQL interface code, and certainly no knowledge of the database schema. (The
* database schema is always ignorant of the objects that use it.) Since it's a form of Mapper ,
* Data Mapper itself is even unknown to the domain layer.
- *
- * The below example demonstrates basic CRUD operations: Create, Read, Update, and Delete.
- *
+ *
+ * The below example demonstrates basic CRUD operations: Create, Read, Update, and Delete.
*/
public final class App {
private static Logger log = LoggerFactory.getLogger(App.class);
private static final String STUDENT_STRING = "App.main(), student : ";
-
+
/**
* Program entry point.
- *
+ *
* @param args command line args.
*/
public static void main(final String... args) {
@@ -81,5 +79,6 @@ public final class App {
mapper.delete(student);
}
- private App() {}
+ private App() {
+ }
}
diff --git a/data-mapper/src/main/java/com/iluwatar/datamapper/DataMapperException.java b/data-mapper/src/main/java/com/iluwatar/datamapper/DataMapperException.java
index 57aec04a8..4f354c7eb 100644
--- a/data-mapper/src/main/java/com/iluwatar/datamapper/DataMapperException.java
+++ b/data-mapper/src/main/java/com/iluwatar/datamapper/DataMapperException.java
@@ -26,9 +26,8 @@ package com.iluwatar.datamapper;
/**
* Using Runtime Exception for avoiding dependancy on implementation exceptions. This helps in
* decoupling.
- *
- * @author amit.dixit
*
+ * @author amit.dixit
*/
public final class DataMapperException extends RuntimeException {
@@ -39,7 +38,7 @@ public final class DataMapperException extends RuntimeException {
* initialized, and may subsequently be initialized by a call to {@link #initCause}.
*
* @param message the detail message. The detail message is saved for later retrieval by the
- * {@link #getMessage()} method.
+ * {@link #getMessage()} method.
*/
public DataMapperException(final String message) {
super(message);
diff --git a/data-mapper/src/main/java/com/iluwatar/datamapper/Student.java b/data-mapper/src/main/java/com/iluwatar/datamapper/Student.java
index e52d293ce..5a368f9ce 100644
--- a/data-mapper/src/main/java/com/iluwatar/datamapper/Student.java
+++ b/data-mapper/src/main/java/com/iluwatar/datamapper/Student.java
@@ -23,11 +23,10 @@
package com.iluwatar.datamapper;
-
import java.io.Serializable;
/**
- * Class defining Student
+ * Class defining Student.
*/
public final class Student implements Serializable {
@@ -39,11 +38,11 @@ public final class Student implements Serializable {
/**
- * Use this constructor to create a Student with all details
+ * Use this constructor to create a Student with all details.
*
* @param studentId as unique student id
- * @param name as student name
- * @param grade as respective grade of student
+ * @param name as student name
+ * @param grade as respective grade of student
*/
public Student(final int studentId, final String name, final char grade) {
this.studentId = studentId;
@@ -51,57 +50,30 @@ public final class Student implements Serializable {
this.grade = grade;
}
- /**
- *
- * @return the student id
- */
public int getStudentId() {
return studentId;
}
- /**
- *
- * @param studentId as unique student id
- */
public void setStudentId(final int studentId) {
this.studentId = studentId;
}
- /**
- *
- * @return name of student
- */
public String getName() {
return name;
}
- /**
- *
- * @param name as 'name' of student
- */
public void setName(final String name) {
this.name = name;
}
- /**
- *
- * @return grade of student
- */
public char getGrade() {
return grade;
}
- /**
- *
- * @param grade as 'grade of student'
- */
public void setGrade(final char grade) {
this.grade = grade;
}
- /**
- *
- */
@Override
public boolean equals(final Object inputObject) {
@@ -125,9 +97,6 @@ public final class Student implements Serializable {
return isEqual;
}
- /**
- *
- */
@Override
public int hashCode() {
@@ -135,9 +104,6 @@ public final class Student implements Serializable {
return this.getStudentId();
}
- /**
- *
- */
@Override
public String toString() {
return "Student [studentId=" + studentId + ", name=" + name + ", grade=" + grade + "]";
diff --git a/data-mapper/src/main/java/com/iluwatar/datamapper/StudentDataMapper.java b/data-mapper/src/main/java/com/iluwatar/datamapper/StudentDataMapper.java
index 18ce1685c..3dfe4787f 100644
--- a/data-mapper/src/main/java/com/iluwatar/datamapper/StudentDataMapper.java
+++ b/data-mapper/src/main/java/com/iluwatar/datamapper/StudentDataMapper.java
@@ -26,7 +26,7 @@ package com.iluwatar.datamapper;
import java.util.Optional;
/**
- * Interface lists out the possible behaviour for all possible student mappers
+ * Interface lists out the possible behaviour for all possible student mappers.
*/
public interface StudentDataMapper {
diff --git a/data-mapper/src/main/java/com/iluwatar/datamapper/StudentDataMapperImpl.java b/data-mapper/src/main/java/com/iluwatar/datamapper/StudentDataMapperImpl.java
index 117015f00..cc92ab81e 100644
--- a/data-mapper/src/main/java/com/iluwatar/datamapper/StudentDataMapperImpl.java
+++ b/data-mapper/src/main/java/com/iluwatar/datamapper/StudentDataMapperImpl.java
@@ -28,7 +28,7 @@ import java.util.List;
import java.util.Optional;
/**
- * Implementation of Actions on Students Data
+ * Implementation of Actions on Students Data.
*/
public final class StudentDataMapperImpl implements StudentDataMapper {
@@ -84,7 +84,8 @@ public final class StudentDataMapperImpl implements StudentDataMapper {
} else {
/* Throw user error after wrapping in a runtime exception */
- throw new DataMapperException("Student already [" + studentToBeInserted.getName() + "] exists");
+ throw new DataMapperException("Student already [" + studentToBeInserted
+ .getName() + "] exists");
}
}
diff --git a/data-transfer-object/src/main/java/com/iluwatar/datatransfer/CustomerClientApp.java b/data-transfer-object/src/main/java/com/iluwatar/datatransfer/CustomerClientApp.java
index 7a660705a..860faf478 100644
--- a/data-transfer-object/src/main/java/com/iluwatar/datatransfer/CustomerClientApp.java
+++ b/data-transfer-object/src/main/java/com/iluwatar/datatransfer/CustomerClientApp.java
@@ -23,21 +23,20 @@
package com.iluwatar.datatransfer;
+import java.util.ArrayList;
+import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.util.ArrayList;
-import java.util.List;
-
/**
- * The Data Transfer Object pattern is a design pattern in which an data transfer object is used to serve related
- * information together to avoid multiple call for each piece of information.
- *
- * In this example, ({@link CustomerClientApp}) as as customer details consumer i.e. client to request for
- * customer details to server.
- *
- * CustomerResource ({@link CustomerResource}) act as server to serve customer information.
- * And The CustomerDto ({@link CustomerDto} is data transfer object to share customer information.
+ * The Data Transfer Object pattern is a design pattern in which an data transfer object is used to
+ * serve related information together to avoid multiple call for each piece of information.
+ *
+ * In this example, ({@link CustomerClientApp}) as as customer details consumer i.e. client to
+ * request for customer details to server.
+ *
+ * CustomerResource ({@link CustomerResource}) act as server to serve customer information. And
+ * The CustomerDto ({@link CustomerDto} is data transfer object to share customer information.
*/
public class CustomerClientApp {
diff --git a/data-transfer-object/src/main/java/com/iluwatar/datatransfer/CustomerDto.java b/data-transfer-object/src/main/java/com/iluwatar/datatransfer/CustomerDto.java
index d05d970d2..a77eb8702 100644
--- a/data-transfer-object/src/main/java/com/iluwatar/datatransfer/CustomerDto.java
+++ b/data-transfer-object/src/main/java/com/iluwatar/datatransfer/CustomerDto.java
@@ -24,10 +24,10 @@
package com.iluwatar.datatransfer;
/**
- * {@link CustomerDto} is a data transfer object POJO. Instead of sending individual information to client
- * We can send related information together in POJO.
- *
- * Dto will not have any business logic in it.
+ * {@link CustomerDto} is a data transfer object POJO. Instead of sending individual information to
+ * client We can send related information together in POJO.
+ *
+ * Dto will not have any business logic in it.
*/
public class CustomerDto {
private final String id;
@@ -35,6 +35,8 @@ public class CustomerDto {
private final String lastName;
/**
+ * Constructor.
+ *
* @param id customer id
* @param firstName customer first name
* @param lastName customer last name
diff --git a/data-transfer-object/src/main/java/com/iluwatar/datatransfer/CustomerResource.java b/data-transfer-object/src/main/java/com/iluwatar/datatransfer/CustomerResource.java
index 5dee3c8f8..7e4b8340d 100644
--- a/data-transfer-object/src/main/java/com/iluwatar/datatransfer/CustomerResource.java
+++ b/data-transfer-object/src/main/java/com/iluwatar/datatransfer/CustomerResource.java
@@ -26,13 +26,15 @@ package com.iluwatar.datatransfer;
import java.util.List;
/**
- * The resource class which serves customer information.
- * This class act as server in the demo. Which has all customer details.
+ * The resource class which serves customer information. This class act as server in the demo. Which
+ * has all customer details.
*/
public class CustomerResource {
private List
- * In this example we show how the simple {@link SimpleTroll} first attacks and then flees the battle.
- * Then we decorate the {@link SimpleTroll} with a {@link ClubbedTroll} and perform the attack again. You
- * can see how the behavior changes after the decoration.
- *
+ *
+ * In this example we show how the simple {@link SimpleTroll} first attacks and then flees the
+ * battle. Then we decorate the {@link SimpleTroll} with a {@link ClubbedTroll} and perform the
+ * attack again. You can see how the behavior changes after the decoration.
*/
public class App {
private static final Logger LOGGER = LoggerFactory.getLogger(App.class);
/**
- * Program entry point
- *
+ * Program entry point.
+ *
* @param args command line args
*/
public static void main(String[] args) {
diff --git a/decorator/src/main/java/com/iluwatar/decorator/ClubbedTroll.java b/decorator/src/main/java/com/iluwatar/decorator/ClubbedTroll.java
index 90eb893a7..70fd15489 100644
--- a/decorator/src/main/java/com/iluwatar/decorator/ClubbedTroll.java
+++ b/decorator/src/main/java/com/iluwatar/decorator/ClubbedTroll.java
@@ -27,7 +27,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
- * Decorator that adds a club for the troll
+ * Decorator that adds a club for the troll.
*/
public class ClubbedTroll implements Troll {
diff --git a/decorator/src/main/java/com/iluwatar/decorator/SimpleTroll.java b/decorator/src/main/java/com/iluwatar/decorator/SimpleTroll.java
index e2095a2ad..08eed94fc 100644
--- a/decorator/src/main/java/com/iluwatar/decorator/SimpleTroll.java
+++ b/decorator/src/main/java/com/iluwatar/decorator/SimpleTroll.java
@@ -27,9 +27,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
- *
* SimpleTroll implements {@link Troll} interface directly.
- *
*/
public class SimpleTroll implements Troll {
diff --git a/decorator/src/main/java/com/iluwatar/decorator/Troll.java b/decorator/src/main/java/com/iluwatar/decorator/Troll.java
index faeca11c9..43f9ac916 100644
--- a/decorator/src/main/java/com/iluwatar/decorator/Troll.java
+++ b/decorator/src/main/java/com/iluwatar/decorator/Troll.java
@@ -24,9 +24,7 @@
package com.iluwatar.decorator;
/**
- *
- * Interface for trolls
- *
+ * Interface for trolls.
*/
public interface Troll {
id
- * exists, empty optional otherwise.
+ * @return an optional with customer if a customer with unique identifier id
exists,
+ * empty optional otherwise.
* @throws Exception if any error occurs.
*/
OptionaldataSource
- * to store and retrieve customer information.
- *
+ * Creates an instance of {@link DbCustomerDao} which uses provided dataSource
to
+ * store and retrieve customer information.
+ *
* @param dataSource a non-null dataSource.
*/
public DbCustomerDao(DataSource dataSource) {
@@ -60,9 +57,11 @@ public class DbCustomerDao implements CustomerDao {
}
/**
- * @return a lazily populated stream of customers. Note the stream returned must be closed to
- * free all the acquired resources. The stream keeps an open connection to the database till
- * it is complete or is closed manually.
+ * Get all customers as Java Stream.
+ *
+ * @return a lazily populated stream of customers. Note the stream returned must be closed to free
+ * all the acquired resources. The stream keeps an open connection to the database till it is
+ * complete or is closed manually.
*/
@Override
public Stream
* This implementation is useful as temporary database or for testing.
*/
@@ -56,7 +56,7 @@ public class InMemoryCustomerDao implements CustomerDao {
if (getById(customer.getId()).isPresent()) {
return false;
}
-
+
idToCustomer.put(customer.getId(), customer);
return true;
}
diff --git a/data-bus/src/main/java/com/iluwatar/databus/App.java b/data-bus/src/main/java/com/iluwatar/databus/App.java
index b645dbd34..da4c6f07e 100644
--- a/data-bus/src/main/java/com/iluwatar/databus/App.java
+++ b/data-bus/src/main/java/com/iluwatar/databus/App.java
@@ -28,35 +28,33 @@ import com.iluwatar.databus.data.StartingData;
import com.iluwatar.databus.data.StoppingData;
import com.iluwatar.databus.members.MessageCollectorMember;
import com.iluwatar.databus.members.StatusMember;
-
import java.time.LocalDateTime;
/**
- * The Data Bus pattern
- *