From f0f0143d484d820277fe987e7bb96caa5e2f59b2 Mon Sep 17 00:00:00 2001 From: Anurag Agarwal Date: Sun, 10 Nov 2019 23:17:32 +0530 Subject: [PATCH] Resolves checkstyle errors for trampoline twin typeobjectpattern unit-of-work value-object (#1074) * Reduces checkstyle errors in trampoline * Reduces checkstyle errors in twin * Reduces checkstyle errors in typeobjectpattern * Reduces checkstyle errors in unit-of-work * Reduces checkstyle errors in value-object --- .../com/iluwatar/trampoline/Trampoline.java | 18 +++-- .../iluwatar/trampoline/TrampolineApp.java | 11 +-- twin/src/main/java/com/iluwatar/twin/App.java | 10 +-- .../java/com/iluwatar/twin/BallThread.java | 3 +- .../main/java/com/iluwatar/twin/GameItem.java | 2 +- .../java/com/iluwatar/typeobject/App.java | 15 ++-- .../java/com/iluwatar/typeobject/Candy.java | 22 +++--- .../com/iluwatar/typeobject/CandyGame.java | 68 +++++++++---------- .../java/com/iluwatar/typeobject/Cell.java | 52 +++++++------- .../com/iluwatar/typeobject/CellPool.java | 21 +++--- .../com/iluwatar/typeobject/JsonParser.java | 11 ++- .../java/com/iluwatar/unitofwork/App.java | 1 + .../com/iluwatar/unitofwork/IUnitOfWork.java | 4 +- .../java/com/iluwatar/unitofwork/Student.java | 2 + .../unitofwork/StudentRepository.java | 10 +-- .../java/com/iluwatar/value/object/App.java | 21 +++--- .../com/iluwatar/value/object/HeroStat.java | 8 +-- 17 files changed, 146 insertions(+), 133 deletions(-) diff --git a/trampoline/src/main/java/com/iluwatar/trampoline/Trampoline.java b/trampoline/src/main/java/com/iluwatar/trampoline/Trampoline.java index 65c5f8a5b..862300ea3 100644 --- a/trampoline/src/main/java/com/iluwatar/trampoline/Trampoline.java +++ b/trampoline/src/main/java/com/iluwatar/trampoline/Trampoline.java @@ -26,12 +26,14 @@ package com.iluwatar.trampoline; import java.util.stream.Stream; /** - *

Trampoline pattern allows to define recursive algorithms by iterative loop

+ * Trampoline pattern allows to define recursive algorithms by iterative loop. + * *

When get is called on the returned Trampoline, internally it will iterate calling ‘jump’ - * on the returned Trampoline as long as the concrete instance returned is {@link #more(Trampoline)}, - * stopping once the returned instance is {@link #done(Object)}.

+ * on the returned Trampoline as long as the concrete instance returned is {@link + * #more(Trampoline)}, stopping once the returned instance is {@link #done(Object)}. + * *

Essential we convert looping via recursion into iteration, - * the key enabling mechanism is the fact that {@link #more(Trampoline)} is a lazy operation.

+ * the key enabling mechanism is the fact that {@link #more(Trampoline)} is a lazy operation. * * @param is type for returning result. */ @@ -40,6 +42,8 @@ public interface Trampoline { /** + * Jump to next stage. + * * @return next stage */ default Trampoline jump() { @@ -52,6 +56,8 @@ public interface Trampoline { } /** + * Checks if complete. + * * @return true if complete */ default boolean complete() { @@ -59,7 +65,7 @@ public interface Trampoline { } /** - * Created a completed Trampoline + * Created a completed Trampoline. * * @param result Completed result * @return Completed Trampoline @@ -70,7 +76,7 @@ public interface Trampoline { /** - * Create a Trampoline that has more work to do + * Create a Trampoline that has more work to do. * * @param trampoline Next stage in Trampoline * @return Trampoline with more work diff --git a/trampoline/src/main/java/com/iluwatar/trampoline/TrampolineApp.java b/trampoline/src/main/java/com/iluwatar/trampoline/TrampolineApp.java index 120ba577f..6abb4d0ff 100644 --- a/trampoline/src/main/java/com/iluwatar/trampoline/TrampolineApp.java +++ b/trampoline/src/main/java/com/iluwatar/trampoline/TrampolineApp.java @@ -23,20 +23,21 @@ package com.iluwatar.trampoline; - import lombok.extern.slf4j.Slf4j; /** - *

Trampoline pattern allows to define recursive algorithms by iterative loop

- *

it is possible to implement algorithms recursively in Java without blowing the stack - * and to interleave the execution of functions without hard coding them together or even using threads.

+ * Trampoline pattern allows to define recursive algorithms by iterative loop. + * + *

It is possible to implement algorithms recursively in Java without blowing the stack + * and to interleave the execution of functions without hard coding them together or even using + * threads. */ @Slf4j public class TrampolineApp { /** * Main program for showing pattern. It does loop with factorial function. - * */ + */ public static void main(String[] args) { log.info("start pattern"); Integer result = loop(10, 1).result(); diff --git a/twin/src/main/java/com/iluwatar/twin/App.java b/twin/src/main/java/com/iluwatar/twin/App.java index 6e6ce6ab7..5789d163a 100644 --- a/twin/src/main/java/com/iluwatar/twin/App.java +++ b/twin/src/main/java/com/iluwatar/twin/App.java @@ -26,17 +26,17 @@ package com.iluwatar.twin; /** * Twin pattern is a design pattern which provides a standard solution to simulate multiple * inheritance in java. - *

- * In this example, the essence of the Twin pattern is the {@link BallItem} class and - * {@link BallThread} class represent the twin objects to coordinate with each other(via the twin + * + *

In this example, the essence of the Twin pattern is the {@link BallItem} class and {@link + * BallThread} class represent the twin objects to coordinate with each other(via the twin * reference) like a single class inheriting from {@link GameItem} and {@link Thread}. */ public class App { /** - * Program entry point - * + * Program entry point. + * * @param args command line args */ public static void main(String[] args) throws Exception { diff --git a/twin/src/main/java/com/iluwatar/twin/BallThread.java b/twin/src/main/java/com/iluwatar/twin/BallThread.java index 7567465ba..f302016c8 100644 --- a/twin/src/main/java/com/iluwatar/twin/BallThread.java +++ b/twin/src/main/java/com/iluwatar/twin/BallThread.java @@ -29,7 +29,6 @@ import org.slf4j.LoggerFactory; /** * This class is a UI thread for drawing the {@link BallItem}, and provide the method for suspend * and resume. It hold the reference of {@link BallItem} to delegate the draw task. - * */ public class BallThread extends Thread { @@ -47,7 +46,7 @@ public class BallThread extends Thread { } /** - * Run the thread + * Run the thread. */ public void run() { diff --git a/twin/src/main/java/com/iluwatar/twin/GameItem.java b/twin/src/main/java/com/iluwatar/twin/GameItem.java index dbe7e4024..cc9fb0808 100644 --- a/twin/src/main/java/com/iluwatar/twin/GameItem.java +++ b/twin/src/main/java/com/iluwatar/twin/GameItem.java @@ -34,7 +34,7 @@ public abstract class GameItem { private static final Logger LOGGER = LoggerFactory.getLogger(GameItem.class); /** - * Template method, do some common logic before draw + * Template method, do some common logic before draw. */ public void draw() { LOGGER.info("draw"); diff --git a/typeobjectpattern/src/main/java/com/iluwatar/typeobject/App.java b/typeobjectpattern/src/main/java/com/iluwatar/typeobject/App.java index 75c2a768e..e70acbf9e 100644 --- a/typeobjectpattern/src/main/java/com/iluwatar/typeobject/App.java +++ b/typeobjectpattern/src/main/java/com/iluwatar/typeobject/App.java @@ -29,8 +29,9 @@ import org.json.simple.parser.ParseException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -/**

Type object pattern is the pattern we use when the OOP concept of creating a base class and - * inheriting from it just doesn't work for the case in hand. This happens when we either don't know +/** + *

Type object pattern is the pattern we use when the OOP concept of creating a base class and + * inheriting from it just doesn't work for the case in hand. This happens when we either don't know * what types we will need upfront, or want to be able to modify or add new types conveniently w/o * recompiling repeatedly. The pattern provides a solution by allowing flexible creation of required * objects by creating one class, which has a field which represents the 'type' of the object.

@@ -40,17 +41,19 @@ import org.slf4j.LoggerFactory; * Type. We have a json file {@link candy} which contains the details about the candies, and this is * parsed to get all the different candies in {@link JsonParser}. The {@link Cell} class is what the * game matrix is made of, which has the candies that are to be crushed, and contains information on - * how crushing can be done, how the matrix is to be reconfigured and how points are to be gained. + * how crushing can be done, how the matrix is to be reconfigured and how points are to be gained. * The {@link CellPool} class is a pool which reuses the candy cells that have been crushed instead * of making new ones repeatedly. The {@link CandyGame} class has the rules for the continuation of - * the game and the {@link App} class has the game itself.

+ * the game and the {@link App} class has the game itself.

*/ public class App { private static final Logger LOGGER = LoggerFactory.getLogger(App.class); + /** * Program entry point. + * * @param args command line args */ public static void main(String[] args) throws FileNotFoundException, IOException, ParseException { @@ -61,7 +64,7 @@ public class App { var start = System.currentTimeMillis(); var end = System.currentTimeMillis(); var round = 0; - while (pointsWon < toWin && end - start < givenTime) { + while (pointsWon < toWin && end - start < givenTime) { round++; var pool = new CellPool(numOfRows * numOfRows + 5); var cg = new CandyGame(numOfRows, pool); @@ -72,7 +75,7 @@ public class App { } cg.printGameStatus(); end = System.currentTimeMillis(); - cg.round((int)(end - start), givenTime); + cg.round((int) (end - start), givenTime); pointsWon += cg.totalPoints; end = System.currentTimeMillis(); } diff --git a/typeobjectpattern/src/main/java/com/iluwatar/typeobject/Candy.java b/typeobjectpattern/src/main/java/com/iluwatar/typeobject/Candy.java index 3803dab55..ec41dc6cd 100644 --- a/typeobjectpattern/src/main/java/com/iluwatar/typeobject/Candy.java +++ b/typeobjectpattern/src/main/java/com/iluwatar/typeobject/Candy.java @@ -24,20 +24,22 @@ package com.iluwatar.typeobject; /** - * The Candy class has a field type, which represents the 'type' of candy. The objects - * are created by parsing the candy.json file. + * The Candy class has a field type, which represents the 'type' of candy. The objects are created + * by parsing the candy.json file. */ - public class Candy { - - enum Type { crushableCandy, rewardFruit }; - + + enum Type { + crushableCandy, + rewardFruit + } + String name; Candy parent; String parentName; private int points; private Type type; - + Candy(String name, String parentName, Type type, int points) { this.name = name; this.parent = null; @@ -45,15 +47,15 @@ public class Candy { this.points = points; this.parentName = parentName; } - + int getPoints() { return this.points; } - + void setPoints(int a) { this.points = a; } - + Type getType() { return this.type; } diff --git a/typeobjectpattern/src/main/java/com/iluwatar/typeobject/CandyGame.java b/typeobjectpattern/src/main/java/com/iluwatar/typeobject/CandyGame.java index c8d29d65e..6b3b138d8 100644 --- a/typeobjectpattern/src/main/java/com/iluwatar/typeobject/CandyGame.java +++ b/typeobjectpattern/src/main/java/com/iluwatar/typeobject/CandyGame.java @@ -23,24 +23,24 @@ package com.iluwatar.typeobject; -import java.util.ArrayList; import com.iluwatar.typeobject.Candy.Type; +import java.util.ArrayList; import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** - * The CandyGame class contains the rules for the continuation of the game and has - * the game matrix (field 'cells') and totalPoints gained during the game. + * The CandyGame class contains the rules for the continuation of the game and has the game matrix + * (field 'cells') and totalPoints gained during the game. */ public class CandyGame { private static final Logger LOGGER = LoggerFactory.getLogger(CandyGame.class); - + Cell[][] cells; CellPool pool; int totalPoints; - + CandyGame(int num, CellPool pool) { this.cells = new Cell[num][num]; this.pool = pool; @@ -48,12 +48,12 @@ public class CandyGame { for (var i = 0; i < num; i++) { for (var j = 0; j < num; j++) { this.cells[i][j] = this.pool.getNewCell(); - this.cells[i][j].xIndex = j; - this.cells[i][j].yIndex = i; + this.cells[i][j].positionX = j; + this.cells[i][j].positionY = i; } } } - + static String numOfSpaces(int num) { String result = ""; for (var i = 0; i < num; i++) { @@ -61,7 +61,7 @@ public class CandyGame { } return result; } - + void printGameStatus() { LOGGER.info(""); for (var i = 0; i < cells.length; i++) { @@ -79,32 +79,32 @@ public class CandyGame { } LOGGER.info(""); } - - ArrayList adjacentCells(int yIndex, int xIndex) { + + ArrayList adjacentCells(int y, int x) { ArrayList adjacent = new ArrayList(); - if (yIndex == 0) { - adjacent.add(this.cells[1][xIndex]); + if (y == 0) { + adjacent.add(this.cells[1][x]); } - if (xIndex == 0) { - adjacent.add(this.cells[yIndex][1]); + if (x == 0) { + adjacent.add(this.cells[y][1]); } - if (yIndex == cells.length - 1) { - adjacent.add(this.cells[cells.length - 2][xIndex]); + if (y == cells.length - 1) { + adjacent.add(this.cells[cells.length - 2][x]); } - if (xIndex == cells.length - 1) { - adjacent.add(this.cells[yIndex][cells.length - 2]); + if (x == cells.length - 1) { + adjacent.add(this.cells[y][cells.length - 2]); } - if (yIndex > 0 && yIndex < cells.length - 1) { - adjacent.add(this.cells[yIndex - 1][xIndex]); - adjacent.add(this.cells[yIndex + 1][xIndex]); + if (y > 0 && y < cells.length - 1) { + adjacent.add(this.cells[y - 1][x]); + adjacent.add(this.cells[y + 1][x]); } - if (xIndex > 0 && xIndex < cells.length - 1) { - adjacent.add(this.cells[yIndex][xIndex - 1]); - adjacent.add(this.cells[yIndex][xIndex + 1]); + if (x > 0 && x < cells.length - 1) { + adjacent.add(this.cells[y][x - 1]); + adjacent.add(this.cells[y][x + 1]); } return adjacent; } - + boolean continueRound() { for (var i = 0; i < this.cells.length; i++) { if (this.cells[cells.length - 1][i].candy.getType().equals(Type.rewardFruit)) { @@ -114,7 +114,7 @@ public class CandyGame { for (var i = 0; i < this.cells.length; i++) { for (var j = 0; j < this.cells.length; j++) { if (!this.cells[i][j].candy.getType().equals(Type.rewardFruit)) { - var adj = adjacentCells(i,j); + var adj = adjacentCells(i, j); for (var a = 0; a < adj.size(); a++) { if (this.cells[i][j].candy.name.equals(adj.get(a).candy.name)) { return true; @@ -125,13 +125,13 @@ public class CandyGame { } return false; } - + void handleChange(int points) { LOGGER.info("+" + points + " points!"); - this.totalPoints += points; + this.totalPoints += points; printGameStatus(); } - + void round(int timeSoFar, int totalTime) { var start = System.currentTimeMillis(); var end = System.currentTimeMillis(); @@ -148,9 +148,9 @@ public class CandyGame { for (var i = 0; i < this.cells.length; i++) { var j = cells.length - 1; var points = 0; - while (j > 0) { + while (j > 0) { points = this.cells[j][i].interact(this.cells[j - 1][i], this.pool, this.cells); - if (points != 0) { + if (points != 0) { handleChange(points); } else { j = j - 1; @@ -160,7 +160,7 @@ public class CandyGame { for (var i = 0; i < this.cells.length; i++) { var j = 0; var points = 0; - while (j < cells.length - 1) { + while (j < cells.length - 1) { points = this.cells[i][j].interact(this.cells[i][j + 1], this.pool, this.cells); if (points != 0) { handleChange(points); @@ -172,5 +172,5 @@ public class CandyGame { end = System.currentTimeMillis(); } } - + } diff --git a/typeobjectpattern/src/main/java/com/iluwatar/typeobject/Cell.java b/typeobjectpattern/src/main/java/com/iluwatar/typeobject/Cell.java index d8609aba9..e4d9d497f 100644 --- a/typeobjectpattern/src/main/java/com/iluwatar/typeobject/Cell.java +++ b/typeobjectpattern/src/main/java/com/iluwatar/typeobject/Cell.java @@ -26,61 +26,61 @@ package com.iluwatar.typeobject; import com.iluwatar.typeobject.Candy.Type; /** - * The Cell object is what the game matrix is made of and contains the candy which is - * to be crushed or collected as reward. + * The Cell object is what the game matrix is made of and contains the candy which is to be crushed + * or collected as reward. */ - public class Cell { Candy candy; - int xIndex; - int yIndex; - - Cell(Candy candy, int xIndex, int yIndex) { + int positionX; + int positionY; + + Cell(Candy candy, int positionX, int positionY) { this.candy = candy; - this.xIndex = xIndex; - this.yIndex = yIndex; + this.positionX = positionX; + this.positionY = positionY; } - + Cell() { this.candy = null; - this.xIndex = 0; - this.yIndex = 0; + this.positionX = 0; + this.positionY = 0; } - + void crush(CellPool pool, Cell[][] cellMatrix) { //take out from this position and put back in pool pool.addNewCell(this); this.fillThisSpace(pool, cellMatrix); } - + void fillThisSpace(CellPool pool, Cell[][] cellMatrix) { - for (var y = this.yIndex; y > 0; y--) { - cellMatrix[y][this.xIndex] = cellMatrix[y - 1][this.xIndex]; - cellMatrix[y][this.xIndex].yIndex = y; + for (var y = this.positionY; y > 0; y--) { + cellMatrix[y][this.positionX] = cellMatrix[y - 1][this.positionX]; + cellMatrix[y][this.positionX].positionY = y; } var newC = pool.getNewCell(); - cellMatrix[0][this.xIndex] = newC; - cellMatrix[0][this.xIndex].xIndex = this.xIndex; - cellMatrix[0][this.xIndex].yIndex = 0; + cellMatrix[0][this.positionX] = newC; + cellMatrix[0][this.positionX].positionX = this.positionX; + cellMatrix[0][this.positionX].positionY = 0; } - + void handleCrush(Cell c, CellPool pool, Cell[][] cellMatrix) { - if (this.yIndex >= c.yIndex) { - this.crush(pool, cellMatrix); + if (this.positionY >= c.positionY) { + this.crush(pool, cellMatrix); c.crush(pool, cellMatrix); } else { c.crush(pool, cellMatrix); this.crush(pool, cellMatrix); } } - + int interact(Cell c, CellPool pool, Cell[][] cellMatrix) { - if (this.candy.getType().equals(Type.rewardFruit) || c.candy.getType().equals(Type.rewardFruit)) { + if (this.candy.getType().equals(Type.rewardFruit) || c.candy.getType() + .equals(Type.rewardFruit)) { return 0; } else { if (this.candy.name.equals(c.candy.name)) { var pointsWon = this.candy.getPoints() + c.candy.getPoints(); - handleCrush(c,pool,cellMatrix); + handleCrush(c, pool, cellMatrix); return pointsWon; } else { return 0; diff --git a/typeobjectpattern/src/main/java/com/iluwatar/typeobject/CellPool.java b/typeobjectpattern/src/main/java/com/iluwatar/typeobject/CellPool.java index 91c21c1b8..3655e9e5a 100644 --- a/typeobjectpattern/src/main/java/com/iluwatar/typeobject/CellPool.java +++ b/typeobjectpattern/src/main/java/com/iluwatar/typeobject/CellPool.java @@ -23,18 +23,17 @@ package com.iluwatar.typeobject; +import com.iluwatar.typeobject.Candy.Type; import java.io.FileNotFoundException; import java.io.IOException; import java.util.ArrayList; -import java.util.Enumeration; import java.util.Random; import org.json.simple.parser.ParseException; -import com.iluwatar.typeobject.Candy.Type; /** - * The CellPool class allows the reuse of crushed cells instead of creation of new - * cells each time. The reused cell is given a new candy to hold using the randomCode - * field which holds all the candies available. + * The CellPool class allows the reuse of crushed cells instead of creation of new cells each time. + * The reused cell is given a new candy to hold using the randomCode field which holds all the + * candies available. */ public class CellPool { @@ -42,9 +41,9 @@ public class CellPool { ArrayList pool; int pointer; Candy[] randomCode; - + CellPool(int num) { - this.pool = new ArrayList(num); + this.pool = new ArrayList(num); try { this.randomCode = assignRandomCandytypes(); } catch (Exception e) { @@ -64,25 +63,25 @@ public class CellPool { } this.pointer = num - 1; } - + Cell getNewCell() { var newCell = this.pool.remove(pointer); pointer--; return newCell; } - + void addNewCell(Cell c) { c.candy = randomCode[RANDOM.nextInt(randomCode.length)]; //changing candytype to new this.pool.add(c); pointer++; } - + Candy[] assignRandomCandytypes() throws FileNotFoundException, IOException, ParseException { var jp = new JsonParser(); jp.parse(); var randomCode = new Candy[jp.candies.size() - 2]; //exclude generic types 'fruit' and 'candy' var i = 0; - for (var e = jp.candies.keys(); e.hasMoreElements();) { + for (var e = jp.candies.keys(); e.hasMoreElements(); ) { var s = e.nextElement(); if (!s.equals("fruit") && !s.equals("candy")) { //not generic diff --git a/typeobjectpattern/src/main/java/com/iluwatar/typeobject/JsonParser.java b/typeobjectpattern/src/main/java/com/iluwatar/typeobject/JsonParser.java index 5374913c1..fcab6ac29 100644 --- a/typeobjectpattern/src/main/java/com/iluwatar/typeobject/JsonParser.java +++ b/typeobjectpattern/src/main/java/com/iluwatar/typeobject/JsonParser.java @@ -23,6 +23,7 @@ package com.iluwatar.typeobject; +import com.iluwatar.typeobject.Candy.Type; import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; @@ -33,16 +34,14 @@ import org.json.simple.JSONArray; import org.json.simple.JSONObject; import org.json.simple.parser.JSONParser; import org.json.simple.parser.ParseException; -import com.iluwatar.typeobject.Candy.Type; /** - * The JsonParser class helps parse the json file candy.json to get all the - * different candies. + * The JsonParser class helps parse the json file candy.json to get all the different candies. */ public class JsonParser { Hashtable candies; - + JsonParser() { this.candies = new Hashtable(); } @@ -69,9 +68,9 @@ public class JsonParser { } setParentAndPoints(); } - + void setParentAndPoints() { - for (Enumeration e = this.candies.keys(); e.hasMoreElements();) { + for (Enumeration e = this.candies.keys(); e.hasMoreElements(); ) { var c = this.candies.get(e.nextElement()); if (c.parentName == null) { c.parent = null; diff --git a/unit-of-work/src/main/java/com/iluwatar/unitofwork/App.java b/unit-of-work/src/main/java/com/iluwatar/unitofwork/App.java index 6febfcacf..a9e41dd7c 100644 --- a/unit-of-work/src/main/java/com/iluwatar/unitofwork/App.java +++ b/unit-of-work/src/main/java/com/iluwatar/unitofwork/App.java @@ -31,6 +31,7 @@ import java.util.List; */ public class App { /** + * Program entry point. * * @param args no argument sent */ diff --git a/unit-of-work/src/main/java/com/iluwatar/unitofwork/IUnitOfWork.java b/unit-of-work/src/main/java/com/iluwatar/unitofwork/IUnitOfWork.java index 98c855348..c44a696e3 100644 --- a/unit-of-work/src/main/java/com/iluwatar/unitofwork/IUnitOfWork.java +++ b/unit-of-work/src/main/java/com/iluwatar/unitofwork/IUnitOfWork.java @@ -24,6 +24,8 @@ package com.iluwatar.unitofwork; /** + * UnitOfWork interface. + * * @param Any generic entity */ public interface IUnitOfWork { @@ -46,7 +48,7 @@ public interface IUnitOfWork { */ void registerDeleted(T entity); - /*** + /** * All UnitOfWork operations batched together executed in commit only. */ void commit(); diff --git a/unit-of-work/src/main/java/com/iluwatar/unitofwork/Student.java b/unit-of-work/src/main/java/com/iluwatar/unitofwork/Student.java index f6d8176b4..92733feba 100644 --- a/unit-of-work/src/main/java/com/iluwatar/unitofwork/Student.java +++ b/unit-of-work/src/main/java/com/iluwatar/unitofwork/Student.java @@ -32,6 +32,8 @@ public class Student { private final String address; /** + * Constructor. + * * @param id student unique id * @param name name of student * @param address address of student diff --git a/unit-of-work/src/main/java/com/iluwatar/unitofwork/StudentRepository.java b/unit-of-work/src/main/java/com/iluwatar/unitofwork/StudentRepository.java index 00b5b35fb..ee5fc613d 100644 --- a/unit-of-work/src/main/java/com/iluwatar/unitofwork/StudentRepository.java +++ b/unit-of-work/src/main/java/com/iluwatar/unitofwork/StudentRepository.java @@ -23,16 +23,14 @@ package com.iluwatar.unitofwork; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import java.util.ArrayList; import java.util.List; import java.util.Map; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** - * {@link StudentRepository} Student database repository. - * supports unit of work for student data. + * {@link StudentRepository} Student database repository. supports unit of work for student data. */ public class StudentRepository implements IUnitOfWork { private static final Logger LOGGER = LoggerFactory.getLogger(StudentRepository.class); @@ -41,6 +39,8 @@ public class StudentRepository implements IUnitOfWork { private StudentDatabase studentDatabase; /** + * Constructor. + * * @param context set of operations to be perform during commit. * @param studentDatabase Database for student records. */ diff --git a/value-object/src/main/java/com/iluwatar/value/object/App.java b/value-object/src/main/java/com/iluwatar/value/object/App.java index 1dbf6c8b3..5f0d69ecc 100644 --- a/value-object/src/main/java/com/iluwatar/value/object/App.java +++ b/value-object/src/main/java/com/iluwatar/value/object/App.java @@ -30,21 +30,20 @@ import org.slf4j.LoggerFactory; * A Value Object are objects which follow value semantics rather than reference semantics. This * means value objects' equality are not based on identity. Two value objects are equal when they * have the same value, not necessarily being the same object.. - * - * Value Objects must override equals(), hashCode() to check the equality with values. - * Value Objects should be immutable so declare members final. - * Obtain instances by static factory methods. - * The elements of the state must be other values, including primitive types. - * Provide methods, typically simple getters, to get the elements of the state. - * A Value Object must check equality with equals() not == - * - * For more specific and strict rules to implement value objects check the rules from Stephen - * Colebourne's term VALJO : http://blog.joda.org/2014/03/valjos-value-java-objects.html + * + *

Value Objects must override equals(), hashCode() to check the equality with values. Value + * Objects should be immutable so declare members final. Obtain instances by static factory methods. + * The elements of the state must be other values, including primitive types. Provide methods, + * typically simple getters, to get the elements of the state. A Value Object must check equality + * with equals() not == + * + *

For more specific and strict rules to implement value objects check the rules from Stephen + * Colebourne's term VALJO : http://blog.joda.org/2014/03/valjos-value-java-objects.html */ public class App { private static final Logger LOGGER = LoggerFactory.getLogger(App.class); - + /** * This practice creates three HeroStats(Value object) and checks equality between those. */ diff --git a/value-object/src/main/java/com/iluwatar/value/object/HeroStat.java b/value-object/src/main/java/com/iluwatar/value/object/HeroStat.java index 46cd2fb33..740be76b1 100644 --- a/value-object/src/main/java/com/iluwatar/value/object/HeroStat.java +++ b/value-object/src/main/java/com/iluwatar/value/object/HeroStat.java @@ -24,11 +24,11 @@ package com.iluwatar.value.object; /** - * HeroStat is a value object - * + * HeroStat is a value object. + * * @see - * http://docs.oracle.com/javase/8/docs/api/java/lang/doc-files/ValueBased.html - * + * http://docs.oracle.com/javase/8/docs/api/java/lang/doc-files/ValueBased.html + * */ public class HeroStat {