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
This commit is contained in:
parent
b92eb5229d
commit
f0f0143d48
@ -26,12 +26,14 @@ package com.iluwatar.trampoline;
|
|||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Trampoline pattern allows to define recursive algorithms by iterative loop </p>
|
* Trampoline pattern allows to define recursive algorithms by iterative loop.
|
||||||
|
*
|
||||||
* <p>When get is called on the returned Trampoline, internally it will iterate calling ‘jump’
|
* <p>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)},
|
* on the returned Trampoline as long as the concrete instance returned is {@link
|
||||||
* stopping once the returned instance is {@link #done(Object)}.</p>
|
* #more(Trampoline)}, stopping once the returned instance is {@link #done(Object)}.
|
||||||
|
*
|
||||||
* <p>Essential we convert looping via recursion into iteration,
|
* <p>Essential we convert looping via recursion into iteration,
|
||||||
* the key enabling mechanism is the fact that {@link #more(Trampoline)} is a lazy operation.</p>
|
* the key enabling mechanism is the fact that {@link #more(Trampoline)} is a lazy operation.
|
||||||
*
|
*
|
||||||
* @param <T> is type for returning result.
|
* @param <T> is type for returning result.
|
||||||
*/
|
*/
|
||||||
@ -40,6 +42,8 @@ public interface Trampoline<T> {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Jump to next stage.
|
||||||
|
*
|
||||||
* @return next stage
|
* @return next stage
|
||||||
*/
|
*/
|
||||||
default Trampoline<T> jump() {
|
default Trampoline<T> jump() {
|
||||||
@ -52,6 +56,8 @@ public interface Trampoline<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Checks if complete.
|
||||||
|
*
|
||||||
* @return true if complete
|
* @return true if complete
|
||||||
*/
|
*/
|
||||||
default boolean complete() {
|
default boolean complete() {
|
||||||
@ -59,7 +65,7 @@ public interface Trampoline<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created a completed Trampoline
|
* Created a completed Trampoline.
|
||||||
*
|
*
|
||||||
* @param result Completed result
|
* @param result Completed result
|
||||||
* @return Completed Trampoline
|
* @return Completed Trampoline
|
||||||
@ -70,7 +76,7 @@ public interface Trampoline<T> {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a Trampoline that has more work to do
|
* Create a Trampoline that has more work to do.
|
||||||
*
|
*
|
||||||
* @param trampoline Next stage in Trampoline
|
* @param trampoline Next stage in Trampoline
|
||||||
* @return Trampoline with more work
|
* @return Trampoline with more work
|
||||||
|
@ -23,20 +23,21 @@
|
|||||||
|
|
||||||
package com.iluwatar.trampoline;
|
package com.iluwatar.trampoline;
|
||||||
|
|
||||||
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Trampoline pattern allows to define recursive algorithms by iterative loop </p>
|
* Trampoline pattern allows to define recursive algorithms by iterative loop.
|
||||||
* <p>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.</p>
|
* <p>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
|
@Slf4j
|
||||||
public class TrampolineApp {
|
public class TrampolineApp {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Main program for showing pattern. It does loop with factorial function.
|
* Main program for showing pattern. It does loop with factorial function.
|
||||||
* */
|
*/
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
log.info("start pattern");
|
log.info("start pattern");
|
||||||
Integer result = loop(10, 1).result();
|
Integer result = loop(10, 1).result();
|
||||||
|
@ -26,16 +26,16 @@ package com.iluwatar.twin;
|
|||||||
/**
|
/**
|
||||||
* Twin pattern is a design pattern which provides a standard solution to simulate multiple
|
* Twin pattern is a design pattern which provides a standard solution to simulate multiple
|
||||||
* inheritance in java.
|
* inheritance in java.
|
||||||
* <p>
|
*
|
||||||
* In this example, the essence of the Twin pattern is the {@link BallItem} class and
|
* <p>In this example, the essence of the Twin pattern is the {@link BallItem} class and {@link
|
||||||
* {@link BallThread} class represent the twin objects to coordinate with each other(via the twin
|
* 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}.
|
* reference) like a single class inheriting from {@link GameItem} and {@link Thread}.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class App {
|
public class App {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Program entry point
|
* Program entry point.
|
||||||
*
|
*
|
||||||
* @param args command line args
|
* @param args command line args
|
||||||
*/
|
*/
|
||||||
|
@ -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
|
* 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.
|
* and resume. It hold the reference of {@link BallItem} to delegate the draw task.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class BallThread extends Thread {
|
public class BallThread extends Thread {
|
||||||
@ -47,7 +46,7 @@ public class BallThread extends Thread {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Run the thread
|
* Run the thread.
|
||||||
*/
|
*/
|
||||||
public void run() {
|
public void run() {
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ public abstract class GameItem {
|
|||||||
private static final Logger LOGGER = LoggerFactory.getLogger(GameItem.class);
|
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() {
|
public void draw() {
|
||||||
LOGGER.info("draw");
|
LOGGER.info("draw");
|
||||||
|
@ -29,7 +29,8 @@ import org.json.simple.parser.ParseException;
|
|||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
/**<p>Type object pattern is the pattern we use when the OOP concept of creating a base class and
|
/**
|
||||||
|
* <p>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
|
* 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
|
* 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
|
* recompiling repeatedly. The pattern provides a solution by allowing flexible creation of required
|
||||||
@ -49,8 +50,10 @@ import org.slf4j.LoggerFactory;
|
|||||||
public class App {
|
public class App {
|
||||||
|
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(App.class);
|
private static final Logger LOGGER = LoggerFactory.getLogger(App.class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Program entry point.
|
* Program entry point.
|
||||||
|
*
|
||||||
* @param args command line args
|
* @param args command line args
|
||||||
*/
|
*/
|
||||||
public static void main(String[] args) throws FileNotFoundException, IOException, ParseException {
|
public static void main(String[] args) throws FileNotFoundException, IOException, ParseException {
|
||||||
|
@ -24,13 +24,15 @@
|
|||||||
package com.iluwatar.typeobject;
|
package com.iluwatar.typeobject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Candy class has a field type, which represents the 'type' of candy. The objects
|
* The Candy class has a field type, which represents the 'type' of candy. The objects are created
|
||||||
* are created by parsing the candy.json file.
|
* by parsing the candy.json file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class Candy {
|
public class Candy {
|
||||||
|
|
||||||
enum Type { crushableCandy, rewardFruit };
|
enum Type {
|
||||||
|
crushableCandy,
|
||||||
|
rewardFruit
|
||||||
|
}
|
||||||
|
|
||||||
String name;
|
String name;
|
||||||
Candy parent;
|
Candy parent;
|
||||||
|
@ -23,14 +23,14 @@
|
|||||||
|
|
||||||
package com.iluwatar.typeobject;
|
package com.iluwatar.typeobject;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import com.iluwatar.typeobject.Candy.Type;
|
import com.iluwatar.typeobject.Candy.Type;
|
||||||
|
import java.util.ArrayList;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The CandyGame class contains the rules for the continuation of the game and has
|
* The CandyGame class contains the rules for the continuation of the game and has the game matrix
|
||||||
* the game matrix (field 'cells') and totalPoints gained during the game.
|
* (field 'cells') and totalPoints gained during the game.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class CandyGame {
|
public class CandyGame {
|
||||||
@ -48,8 +48,8 @@ public class CandyGame {
|
|||||||
for (var i = 0; i < num; i++) {
|
for (var i = 0; i < num; i++) {
|
||||||
for (var j = 0; j < num; j++) {
|
for (var j = 0; j < num; j++) {
|
||||||
this.cells[i][j] = this.pool.getNewCell();
|
this.cells[i][j] = this.pool.getNewCell();
|
||||||
this.cells[i][j].xIndex = j;
|
this.cells[i][j].positionX = j;
|
||||||
this.cells[i][j].yIndex = i;
|
this.cells[i][j].positionY = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -80,27 +80,27 @@ public class CandyGame {
|
|||||||
LOGGER.info("");
|
LOGGER.info("");
|
||||||
}
|
}
|
||||||
|
|
||||||
ArrayList<Cell> adjacentCells(int yIndex, int xIndex) {
|
ArrayList<Cell> adjacentCells(int y, int x) {
|
||||||
ArrayList<Cell> adjacent = new ArrayList<Cell>();
|
ArrayList<Cell> adjacent = new ArrayList<Cell>();
|
||||||
if (yIndex == 0) {
|
if (y == 0) {
|
||||||
adjacent.add(this.cells[1][xIndex]);
|
adjacent.add(this.cells[1][x]);
|
||||||
}
|
}
|
||||||
if (xIndex == 0) {
|
if (x == 0) {
|
||||||
adjacent.add(this.cells[yIndex][1]);
|
adjacent.add(this.cells[y][1]);
|
||||||
}
|
}
|
||||||
if (yIndex == cells.length - 1) {
|
if (y == cells.length - 1) {
|
||||||
adjacent.add(this.cells[cells.length - 2][xIndex]);
|
adjacent.add(this.cells[cells.length - 2][x]);
|
||||||
}
|
}
|
||||||
if (xIndex == cells.length - 1) {
|
if (x == cells.length - 1) {
|
||||||
adjacent.add(this.cells[yIndex][cells.length - 2]);
|
adjacent.add(this.cells[y][cells.length - 2]);
|
||||||
}
|
}
|
||||||
if (yIndex > 0 && yIndex < cells.length - 1) {
|
if (y > 0 && y < cells.length - 1) {
|
||||||
adjacent.add(this.cells[yIndex - 1][xIndex]);
|
adjacent.add(this.cells[y - 1][x]);
|
||||||
adjacent.add(this.cells[yIndex + 1][xIndex]);
|
adjacent.add(this.cells[y + 1][x]);
|
||||||
}
|
}
|
||||||
if (xIndex > 0 && xIndex < cells.length - 1) {
|
if (x > 0 && x < cells.length - 1) {
|
||||||
adjacent.add(this.cells[yIndex][xIndex - 1]);
|
adjacent.add(this.cells[y][x - 1]);
|
||||||
adjacent.add(this.cells[yIndex][xIndex + 1]);
|
adjacent.add(this.cells[y][x + 1]);
|
||||||
}
|
}
|
||||||
return adjacent;
|
return adjacent;
|
||||||
}
|
}
|
||||||
|
@ -26,25 +26,24 @@ package com.iluwatar.typeobject;
|
|||||||
import com.iluwatar.typeobject.Candy.Type;
|
import com.iluwatar.typeobject.Candy.Type;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Cell object is what the game matrix is made of and contains the candy which is
|
* The Cell object is what the game matrix is made of and contains the candy which is to be crushed
|
||||||
* to be crushed or collected as reward.
|
* or collected as reward.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class Cell {
|
public class Cell {
|
||||||
Candy candy;
|
Candy candy;
|
||||||
int xIndex;
|
int positionX;
|
||||||
int yIndex;
|
int positionY;
|
||||||
|
|
||||||
Cell(Candy candy, int xIndex, int yIndex) {
|
Cell(Candy candy, int positionX, int positionY) {
|
||||||
this.candy = candy;
|
this.candy = candy;
|
||||||
this.xIndex = xIndex;
|
this.positionX = positionX;
|
||||||
this.yIndex = yIndex;
|
this.positionY = positionY;
|
||||||
}
|
}
|
||||||
|
|
||||||
Cell() {
|
Cell() {
|
||||||
this.candy = null;
|
this.candy = null;
|
||||||
this.xIndex = 0;
|
this.positionX = 0;
|
||||||
this.yIndex = 0;
|
this.positionY = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void crush(CellPool pool, Cell[][] cellMatrix) {
|
void crush(CellPool pool, Cell[][] cellMatrix) {
|
||||||
@ -54,18 +53,18 @@ public class Cell {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void fillThisSpace(CellPool pool, Cell[][] cellMatrix) {
|
void fillThisSpace(CellPool pool, Cell[][] cellMatrix) {
|
||||||
for (var y = this.yIndex; y > 0; y--) {
|
for (var y = this.positionY; y > 0; y--) {
|
||||||
cellMatrix[y][this.xIndex] = cellMatrix[y - 1][this.xIndex];
|
cellMatrix[y][this.positionX] = cellMatrix[y - 1][this.positionX];
|
||||||
cellMatrix[y][this.xIndex].yIndex = y;
|
cellMatrix[y][this.positionX].positionY = y;
|
||||||
}
|
}
|
||||||
var newC = pool.getNewCell();
|
var newC = pool.getNewCell();
|
||||||
cellMatrix[0][this.xIndex] = newC;
|
cellMatrix[0][this.positionX] = newC;
|
||||||
cellMatrix[0][this.xIndex].xIndex = this.xIndex;
|
cellMatrix[0][this.positionX].positionX = this.positionX;
|
||||||
cellMatrix[0][this.xIndex].yIndex = 0;
|
cellMatrix[0][this.positionX].positionY = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleCrush(Cell c, CellPool pool, Cell[][] cellMatrix) {
|
void handleCrush(Cell c, CellPool pool, Cell[][] cellMatrix) {
|
||||||
if (this.yIndex >= c.yIndex) {
|
if (this.positionY >= c.positionY) {
|
||||||
this.crush(pool, cellMatrix);
|
this.crush(pool, cellMatrix);
|
||||||
c.crush(pool, cellMatrix);
|
c.crush(pool, cellMatrix);
|
||||||
} else {
|
} else {
|
||||||
@ -75,7 +74,8 @@ public class Cell {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int interact(Cell c, CellPool pool, Cell[][] 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;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
if (this.candy.name.equals(c.candy.name)) {
|
if (this.candy.name.equals(c.candy.name)) {
|
||||||
|
@ -23,18 +23,17 @@
|
|||||||
|
|
||||||
package com.iluwatar.typeobject;
|
package com.iluwatar.typeobject;
|
||||||
|
|
||||||
|
import com.iluwatar.typeobject.Candy.Type;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Enumeration;
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import org.json.simple.parser.ParseException;
|
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
|
* The CellPool class allows the reuse of crushed cells instead of creation of new cells each time.
|
||||||
* cells each time. The reused cell is given a new candy to hold using the randomCode
|
* The reused cell is given a new candy to hold using the randomCode field which holds all the
|
||||||
* field which holds all the candies available.
|
* candies available.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class CellPool {
|
public class CellPool {
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
|
|
||||||
package com.iluwatar.typeobject;
|
package com.iluwatar.typeobject;
|
||||||
|
|
||||||
|
import com.iluwatar.typeobject.Candy.Type;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.FileReader;
|
import java.io.FileReader;
|
||||||
@ -33,11 +34,9 @@ import org.json.simple.JSONArray;
|
|||||||
import org.json.simple.JSONObject;
|
import org.json.simple.JSONObject;
|
||||||
import org.json.simple.parser.JSONParser;
|
import org.json.simple.parser.JSONParser;
|
||||||
import org.json.simple.parser.ParseException;
|
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
|
* The JsonParser class helps parse the json file candy.json to get all the different candies.
|
||||||
* different candies.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class JsonParser {
|
public class JsonParser {
|
||||||
|
@ -31,6 +31,7 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
public class App {
|
public class App {
|
||||||
/**
|
/**
|
||||||
|
* Program entry point.
|
||||||
*
|
*
|
||||||
* @param args no argument sent
|
* @param args no argument sent
|
||||||
*/
|
*/
|
||||||
|
@ -24,6 +24,8 @@
|
|||||||
package com.iluwatar.unitofwork;
|
package com.iluwatar.unitofwork;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* UnitOfWork interface.
|
||||||
|
*
|
||||||
* @param <T> Any generic entity
|
* @param <T> Any generic entity
|
||||||
*/
|
*/
|
||||||
public interface IUnitOfWork<T> {
|
public interface IUnitOfWork<T> {
|
||||||
@ -46,7 +48,7 @@ public interface IUnitOfWork<T> {
|
|||||||
*/
|
*/
|
||||||
void registerDeleted(T entity);
|
void registerDeleted(T entity);
|
||||||
|
|
||||||
/***
|
/**
|
||||||
* All UnitOfWork operations batched together executed in commit only.
|
* All UnitOfWork operations batched together executed in commit only.
|
||||||
*/
|
*/
|
||||||
void commit();
|
void commit();
|
||||||
|
@ -32,6 +32,8 @@ public class Student {
|
|||||||
private final String address;
|
private final String address;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Constructor.
|
||||||
|
*
|
||||||
* @param id student unique id
|
* @param id student unique id
|
||||||
* @param name name of student
|
* @param name name of student
|
||||||
* @param address address of student
|
* @param address address of student
|
||||||
|
@ -23,16 +23,14 @@
|
|||||||
|
|
||||||
package com.iluwatar.unitofwork;
|
package com.iluwatar.unitofwork;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@link StudentRepository} Student database repository.
|
* {@link StudentRepository} Student database repository. supports unit of work for student data.
|
||||||
* supports unit of work for student data.
|
|
||||||
*/
|
*/
|
||||||
public class StudentRepository implements IUnitOfWork<Student> {
|
public class StudentRepository implements IUnitOfWork<Student> {
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(StudentRepository.class);
|
private static final Logger LOGGER = LoggerFactory.getLogger(StudentRepository.class);
|
||||||
@ -41,6 +39,8 @@ public class StudentRepository implements IUnitOfWork<Student> {
|
|||||||
private StudentDatabase studentDatabase;
|
private StudentDatabase studentDatabase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Constructor.
|
||||||
|
*
|
||||||
* @param context set of operations to be perform during commit.
|
* @param context set of operations to be perform during commit.
|
||||||
* @param studentDatabase Database for student records.
|
* @param studentDatabase Database for student records.
|
||||||
*/
|
*/
|
||||||
|
@ -31,14 +31,13 @@ import org.slf4j.LoggerFactory;
|
|||||||
* means value objects' equality are not based on identity. Two value objects are equal when they
|
* 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..
|
* have the same value, not necessarily being the same object..
|
||||||
*
|
*
|
||||||
* Value Objects must override equals(), hashCode() to check the equality with values.
|
* <p>Value Objects must override equals(), hashCode() to check the equality with values. Value
|
||||||
* Value Objects should be immutable so declare members final.
|
* Objects should be immutable so declare members final. Obtain instances by static factory methods.
|
||||||
* Obtain instances by static factory methods.
|
* The elements of the state must be other values, including primitive types. Provide methods,
|
||||||
* The elements of the state must be other values, including primitive types.
|
* typically simple getters, to get the elements of the state. A Value Object must check equality
|
||||||
* Provide methods, typically simple getters, to get the elements of the state.
|
* with equals() not ==
|
||||||
* A Value Object must check equality with equals() not ==
|
|
||||||
*
|
*
|
||||||
* For more specific and strict rules to implement value objects check the rules from Stephen
|
* <p>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
|
* Colebourne's term VALJO : http://blog.joda.org/2014/03/valjos-value-java-objects.html
|
||||||
*/
|
*/
|
||||||
public class App {
|
public class App {
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
package com.iluwatar.value.object;
|
package com.iluwatar.value.object;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* HeroStat is a value object
|
* HeroStat is a value object.
|
||||||
*
|
*
|
||||||
* @see <a href="http://docs.oracle.com/javase/8/docs/api/java/lang/doc-files/ValueBased.html">
|
* @see <a href="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
|
* http://docs.oracle.com/javase/8/docs/api/java/lang/doc-files/ValueBased.html
|
||||||
|
Loading…
x
Reference in New Issue
Block a user