diff --git a/abstract-factory/src/main/java/com/iluwatar/abstractfactory/App.java b/abstract-factory/src/main/java/com/iluwatar/abstractfactory/App.java index 3f77a521c..d18f1abed 100644 --- a/abstract-factory/src/main/java/com/iluwatar/abstractfactory/App.java +++ b/abstract-factory/src/main/java/com/iluwatar/abstractfactory/App.java @@ -1,29 +1,37 @@ -package com.iluwatar.abstractfactory; - -/** - * - * The essence of the Abstract Factory pattern is a factory interface - * (KingdomFactory) and its implementations (ElfKingdomFactory, - * OrcKingdomFactory). - * - * The example uses both concrete implementations to create a king, a castle and - * an army. - * - */ -public class App { - - public static void main(String[] args) { - createKingdom(new ElfKingdomFactory()); - createKingdom(new OrcKingdomFactory()); - } - - public static void createKingdom(KingdomFactory factory) { - King king = factory.createKing(); - Castle castle = factory.createCastle(); - Army army = factory.createArmy(); - System.out.println("The kingdom was created."); - System.out.println(king); - System.out.println(castle); - System.out.println(army); - } -} +package com.iluwatar.abstractfactory; + +/** + * + * The essence of the Abstract Factory pattern is a factory interface + * ({@link KingdomFactory}) and its implementations ({@link ElfKingdomFactory}, + * {@link OrcKingdomFactory}). + *
+ * The example uses both concrete implementations to create a king, a castle and + * an army. + * + */ +public class App { + + /** + * Program entry point + * @param args command line arguments + */ + public static void main(String[] args) { + createKingdom(new ElfKingdomFactory()); + createKingdom(new OrcKingdomFactory()); + } + + /** + * Creates kingdom + * @param factory + */ + public static void createKingdom(KingdomFactory factory) { + King king = factory.createKing(); + Castle castle = factory.createCastle(); + Army army = factory.createArmy(); + System.out.println("The kingdom was created."); + System.out.println(king); + System.out.println(castle); + System.out.println(army); + } +} diff --git a/abstract-factory/src/main/java/com/iluwatar/abstractfactory/Army.java b/abstract-factory/src/main/java/com/iluwatar/abstractfactory/Army.java index 39e023e3b..225331517 100644 --- a/abstract-factory/src/main/java/com/iluwatar/abstractfactory/Army.java +++ b/abstract-factory/src/main/java/com/iluwatar/abstractfactory/Army.java @@ -1,5 +1,10 @@ -package com.iluwatar.abstractfactory; - -public interface Army { - -} +package com.iluwatar.abstractfactory; + +/** + * + * Army interface + * + */ +public interface Army { + +} diff --git a/abstract-factory/src/main/java/com/iluwatar/abstractfactory/Castle.java b/abstract-factory/src/main/java/com/iluwatar/abstractfactory/Castle.java index 277daea56..272a97bf3 100644 --- a/abstract-factory/src/main/java/com/iluwatar/abstractfactory/Castle.java +++ b/abstract-factory/src/main/java/com/iluwatar/abstractfactory/Castle.java @@ -1,5 +1,10 @@ -package com.iluwatar.abstractfactory; - -public interface Castle { - -} +package com.iluwatar.abstractfactory; + +/** + * + * Castle interface + * + */ +public interface Castle { + +} diff --git a/abstract-factory/src/main/java/com/iluwatar/abstractfactory/ElfArmy.java b/abstract-factory/src/main/java/com/iluwatar/abstractfactory/ElfArmy.java index 473106222..d77fe8ebd 100644 --- a/abstract-factory/src/main/java/com/iluwatar/abstractfactory/ElfArmy.java +++ b/abstract-factory/src/main/java/com/iluwatar/abstractfactory/ElfArmy.java @@ -1,10 +1,15 @@ -package com.iluwatar.abstractfactory; - -public class ElfArmy implements Army { - - @Override - public String toString() { - return "This is the Elven Army!"; - } - -} +package com.iluwatar.abstractfactory; + +/** + * + * ElfArmy + * + */ +public class ElfArmy implements Army { + + @Override + public String toString() { + return "This is the Elven Army!"; + } + +} diff --git a/abstract-factory/src/main/java/com/iluwatar/abstractfactory/ElfCastle.java b/abstract-factory/src/main/java/com/iluwatar/abstractfactory/ElfCastle.java index 851baf84f..5c2b2a62a 100644 --- a/abstract-factory/src/main/java/com/iluwatar/abstractfactory/ElfCastle.java +++ b/abstract-factory/src/main/java/com/iluwatar/abstractfactory/ElfCastle.java @@ -1,10 +1,15 @@ -package com.iluwatar.abstractfactory; - -public class ElfCastle implements Castle { - - @Override - public String toString() { - return "This is the Elven castle!"; - } - -} +package com.iluwatar.abstractfactory; + +/** + * + * ElfCastle + * + */ +public class ElfCastle implements Castle { + + @Override + public String toString() { + return "This is the Elven castle!"; + } + +} diff --git a/abstract-factory/src/main/java/com/iluwatar/abstractfactory/ElfKing.java b/abstract-factory/src/main/java/com/iluwatar/abstractfactory/ElfKing.java index eafaccf49..df475a354 100644 --- a/abstract-factory/src/main/java/com/iluwatar/abstractfactory/ElfKing.java +++ b/abstract-factory/src/main/java/com/iluwatar/abstractfactory/ElfKing.java @@ -1,10 +1,15 @@ -package com.iluwatar.abstractfactory; - -public class ElfKing implements King { - - @Override - public String toString() { - return "This is the Elven king!"; - } - -} +package com.iluwatar.abstractfactory; + +/** + * + * ElfKing + * + */ +public class ElfKing implements King { + + @Override + public String toString() { + return "This is the Elven king!"; + } + +} diff --git a/abstract-factory/src/main/java/com/iluwatar/abstractfactory/ElfKingdomFactory.java b/abstract-factory/src/main/java/com/iluwatar/abstractfactory/ElfKingdomFactory.java index eb4b99685..0d62fa5f2 100644 --- a/abstract-factory/src/main/java/com/iluwatar/abstractfactory/ElfKingdomFactory.java +++ b/abstract-factory/src/main/java/com/iluwatar/abstractfactory/ElfKingdomFactory.java @@ -1,22 +1,22 @@ -package com.iluwatar.abstractfactory; - -/** - * - * Concrete factory. - * - */ -public class ElfKingdomFactory implements KingdomFactory { - - public Castle createCastle() { - return new ElfCastle(); - } - - public King createKing() { - return new ElfKing(); - } - - public Army createArmy() { - return new ElfArmy(); - } - -} +package com.iluwatar.abstractfactory; + +/** + * + * ElfKingdomFactory concrete factory. + * + */ +public class ElfKingdomFactory implements KingdomFactory { + + public Castle createCastle() { + return new ElfCastle(); + } + + public King createKing() { + return new ElfKing(); + } + + public Army createArmy() { + return new ElfArmy(); + } + +} diff --git a/abstract-factory/src/main/java/com/iluwatar/abstractfactory/King.java b/abstract-factory/src/main/java/com/iluwatar/abstractfactory/King.java index 12a9c1f13..0b75dbb0a 100644 --- a/abstract-factory/src/main/java/com/iluwatar/abstractfactory/King.java +++ b/abstract-factory/src/main/java/com/iluwatar/abstractfactory/King.java @@ -1,5 +1,10 @@ -package com.iluwatar.abstractfactory; - -public interface King { - -} +package com.iluwatar.abstractfactory; + +/** + * + * King interface + * + */ +public interface King { + +} diff --git a/abstract-factory/src/main/java/com/iluwatar/abstractfactory/KingdomFactory.java b/abstract-factory/src/main/java/com/iluwatar/abstractfactory/KingdomFactory.java index e5b4b4050..00bcd1755 100644 --- a/abstract-factory/src/main/java/com/iluwatar/abstractfactory/KingdomFactory.java +++ b/abstract-factory/src/main/java/com/iluwatar/abstractfactory/KingdomFactory.java @@ -1,16 +1,16 @@ -package com.iluwatar.abstractfactory; - -/** - * - * The factory interface. - * - */ -public interface KingdomFactory { - - Castle createCastle(); - - King createKing(); - - Army createArmy(); - -} +package com.iluwatar.abstractfactory; + +/** + * + * KingdomFactory factory interface. + * + */ +public interface KingdomFactory { + + Castle createCastle(); + + King createKing(); + + Army createArmy(); + +} diff --git a/abstract-factory/src/main/java/com/iluwatar/abstractfactory/OrcArmy.java b/abstract-factory/src/main/java/com/iluwatar/abstractfactory/OrcArmy.java index b0e202d51..d331252dc 100644 --- a/abstract-factory/src/main/java/com/iluwatar/abstractfactory/OrcArmy.java +++ b/abstract-factory/src/main/java/com/iluwatar/abstractfactory/OrcArmy.java @@ -1,10 +1,15 @@ -package com.iluwatar.abstractfactory; - -public class OrcArmy implements Army { - - @Override - public String toString() { - return "This is the Orcish Army!"; - } - -} +package com.iluwatar.abstractfactory; + +/** + * + * OrcArmy + * + */ +public class OrcArmy implements Army { + + @Override + public String toString() { + return "This is the Orcish Army!"; + } + +} diff --git a/abstract-factory/src/main/java/com/iluwatar/abstractfactory/OrcCastle.java b/abstract-factory/src/main/java/com/iluwatar/abstractfactory/OrcCastle.java index 785884a59..fd09d9c17 100644 --- a/abstract-factory/src/main/java/com/iluwatar/abstractfactory/OrcCastle.java +++ b/abstract-factory/src/main/java/com/iluwatar/abstractfactory/OrcCastle.java @@ -1,10 +1,15 @@ -package com.iluwatar.abstractfactory; - -public class OrcCastle implements Castle { - - @Override - public String toString() { - return "This is the Orcish castle!"; - } - -} +package com.iluwatar.abstractfactory; + +/** + * + * OrcCastle + * + */ +public class OrcCastle implements Castle { + + @Override + public String toString() { + return "This is the Orcish castle!"; + } + +} diff --git a/abstract-factory/src/main/java/com/iluwatar/abstractfactory/OrcKing.java b/abstract-factory/src/main/java/com/iluwatar/abstractfactory/OrcKing.java index 27ea8afd4..5bae8f31b 100644 --- a/abstract-factory/src/main/java/com/iluwatar/abstractfactory/OrcKing.java +++ b/abstract-factory/src/main/java/com/iluwatar/abstractfactory/OrcKing.java @@ -1,10 +1,15 @@ -package com.iluwatar.abstractfactory; - -public class OrcKing implements King { - - @Override - public String toString() { - return "This is the Orc king!"; - } - -} +package com.iluwatar.abstractfactory; + +/** + * + * OrcKing + * + */ +public class OrcKing implements King { + + @Override + public String toString() { + return "This is the Orc king!"; + } + +} diff --git a/abstract-factory/src/main/java/com/iluwatar/abstractfactory/OrcKingdomFactory.java b/abstract-factory/src/main/java/com/iluwatar/abstractfactory/OrcKingdomFactory.java index 2f2a2a54d..4fdea6656 100644 --- a/abstract-factory/src/main/java/com/iluwatar/abstractfactory/OrcKingdomFactory.java +++ b/abstract-factory/src/main/java/com/iluwatar/abstractfactory/OrcKingdomFactory.java @@ -1,22 +1,22 @@ -package com.iluwatar.abstractfactory; - -/** - * - * Concrete factory. - * - */ -public class OrcKingdomFactory implements KingdomFactory { - - public Castle createCastle() { - return new OrcCastle(); - } - - public King createKing() { - return new OrcKing(); - } - - public Army createArmy() { - return new OrcArmy(); - } - -} +package com.iluwatar.abstractfactory; + +/** + * + * OrcKingdomFactory concrete factory. + * + */ +public class OrcKingdomFactory implements KingdomFactory { + + public Castle createCastle() { + return new OrcCastle(); + } + + public King createKing() { + return new OrcKing(); + } + + public Army createArmy() { + return new OrcArmy(); + } + +} diff --git a/abstract-factory/src/test/java/com/iluwatar/abstractfactory/AppTest.java b/abstract-factory/src/test/java/com/iluwatar/abstractfactory/AppTest.java index 0241ed8ce..91db0a4be 100644 --- a/abstract-factory/src/test/java/com/iluwatar/abstractfactory/AppTest.java +++ b/abstract-factory/src/test/java/com/iluwatar/abstractfactory/AppTest.java @@ -1,13 +1,18 @@ -package com.iluwatar.abstractfactory; -import org.junit.Test; - -import com.iluwatar.abstractfactory.App; - -public class AppTest { - - @Test - public void test() { - String[] args = {}; - App.main(args); - } -} +package com.iluwatar.abstractfactory; +import org.junit.Test; + +import com.iluwatar.abstractfactory.App; + +/** + * + * Application test + * + */ +public class AppTest { + + @Test + public void test() { + String[] args = {}; + App.main(args); + } +} diff --git a/adapter/src/main/java/com/iluwatar/adapter/App.java b/adapter/src/main/java/com/iluwatar/adapter/App.java index 43a93fa44..3d10a4d41 100644 --- a/adapter/src/main/java/com/iluwatar/adapter/App.java +++ b/adapter/src/main/java/com/iluwatar/adapter/App.java @@ -1,21 +1,25 @@ -package com.iluwatar.adapter; - -/** - * - * There are two variations of the Adapter pattern: The class adapter implements - * the adaptee's interface whereas the object adapter uses composition to - * contain the adaptee in the adapter object. This example uses the object - * adapter approach. - * - * The Adapter (GnomeEngineer) converts the interface of the target class - * (GoblinGlider) into a suitable one expected by the client - * (GnomeEngineeringManager). - * - */ -public class App { - - public static void main(String[] args) { - Engineer manager = new GnomeEngineeringManager(); - manager.operateDevice(); - } -} +package com.iluwatar.adapter; + +/** + * + * There are two variations of the Adapter pattern: The class adapter implements + * the adaptee's interface whereas the object adapter uses composition to + * contain the adaptee in the adapter object. This example uses the object + * adapter approach. + *
+ * The Adapter ({@link GnomeEngineer}) converts the interface of the target class + * ({@link GoblinGlider}) into a suitable one expected by the client + * ({@link GnomeEngineeringManager}). + * + */ +public class App { + + /** + * Program entry point + * @param args command line args + */ + public static void main(String[] args) { + Engineer manager = new GnomeEngineeringManager(); + manager.operateDevice(); + } +} diff --git a/adapter/src/main/java/com/iluwatar/adapter/GnomeEngineer.java b/adapter/src/main/java/com/iluwatar/adapter/GnomeEngineer.java index 62fab599f..35cbc9573 100644 --- a/adapter/src/main/java/com/iluwatar/adapter/GnomeEngineer.java +++ b/adapter/src/main/java/com/iluwatar/adapter/GnomeEngineer.java @@ -1,24 +1,24 @@ -package com.iluwatar.adapter; - -/** - * - * Adapter class. Adapts the interface of the device (GoblinGlider) into - * Engineer interface expected by the client (GnomeEngineeringManager). - * - */ -public class GnomeEngineer implements Engineer { - - private GoblinGlider glider; - - public GnomeEngineer() { - glider = new GoblinGlider(); - } - - @Override - public void operateDevice() { - glider.attachGlider(); - glider.gainSpeed(); - glider.takeOff(); - } - -} +package com.iluwatar.adapter; + +/** + * + * Adapter class. Adapts the interface of the device ({@link GoblinGlider}) into + * {@link Engineer} interface expected by the client ({@link GnomeEngineeringManager}). + * + */ +public class GnomeEngineer implements Engineer { + + private GoblinGlider glider; + + public GnomeEngineer() { + glider = new GoblinGlider(); + } + + @Override + public void operateDevice() { + glider.attachGlider(); + glider.gainSpeed(); + glider.takeOff(); + } + +} diff --git a/adapter/src/main/java/com/iluwatar/adapter/GnomeEngineeringManager.java b/adapter/src/main/java/com/iluwatar/adapter/GnomeEngineeringManager.java index 6d0010d74..d95065b88 100644 --- a/adapter/src/main/java/com/iluwatar/adapter/GnomeEngineeringManager.java +++ b/adapter/src/main/java/com/iluwatar/adapter/GnomeEngineeringManager.java @@ -1,20 +1,20 @@ -package com.iluwatar.adapter; - -/** - * - * GnomeEngineering manager uses Engineer to operate devices. - * - */ -public class GnomeEngineeringManager implements Engineer { - - private Engineer engineer; - - public GnomeEngineeringManager() { - engineer = new GnomeEngineer(); - } - - @Override - public void operateDevice() { - engineer.operateDevice(); - } -} +package com.iluwatar.adapter; + +/** + * + * GnomeEngineering manager uses {@link Engineer} to operate devices. + * + */ +public class GnomeEngineeringManager implements Engineer { + + private Engineer engineer; + + public GnomeEngineeringManager() { + engineer = new GnomeEngineer(); + } + + @Override + public void operateDevice() { + engineer.operateDevice(); + } +} diff --git a/adapter/src/test/java/com/iluwatar/adapter/AppTest.java b/adapter/src/test/java/com/iluwatar/adapter/AppTest.java index cd9d713b0..3d877815a 100644 --- a/adapter/src/test/java/com/iluwatar/adapter/AppTest.java +++ b/adapter/src/test/java/com/iluwatar/adapter/AppTest.java @@ -1,14 +1,19 @@ -package com.iluwatar.adapter; - -import org.junit.Test; - -import com.iluwatar.adapter.App; - -public class AppTest { - - @Test - public void test() { - String[] args = {}; - App.main(args); - } -} +package com.iluwatar.adapter; + +import org.junit.Test; + +import com.iluwatar.adapter.App; + +/** + * + * Application test + * + */ +public class AppTest { + + @Test + public void test() { + String[] args = {}; + App.main(args); + } +} diff --git a/async-method-invocation/src/main/java/com/iluwatar/async/method/invocation/App.java b/async-method-invocation/src/main/java/com/iluwatar/async/method/invocation/App.java index de4dfe926..688d8482f 100644 --- a/async-method-invocation/src/main/java/com/iluwatar/async/method/invocation/App.java +++ b/async-method-invocation/src/main/java/com/iluwatar/async/method/invocation/App.java @@ -3,29 +3,24 @@ package com.iluwatar.async.method.invocation; import java.util.concurrent.Callable; /** - *
* This application demonstrates the async method invocation pattern. Key parts of the pattern are
* AsyncResult which is an intermediate container for an asynchronously evaluated value,
* AsyncCallback which can be provided to be executed on task completion and
* AsyncExecutor that manages the execution of the async tasks.
- *
* The main method shows example flow of async invocations. The main thread starts multiple tasks with * variable durations and then continues its own work. When the main thread has done it's job it collects * the results of the async tasks. Two of the tasks are handled with callbacks, meaning the callbacks are * executed immediately when the tasks complete. - *
** Noteworthy difference of thread usage between the async results and callbacks is that the async results * are collected in the main thread but the callbacks are executed within the worker threads. This should be * noted when working with thread pools. - *
** Java provides its own implementations of async method invocation pattern. FutureTask, CompletableFuture * and ExecutorService are the real world implementations of this pattern. But due to the nature of parallel * programming, the implementations are not trivial. This example does not take all possible scenarios into * account but rather provides a simple version that helps to understand the pattern. - *
* * @see AsyncResult * @see AsyncCallback diff --git a/async-method-invocation/src/main/java/com/iluwatar/async/method/invocation/AsyncCallback.java b/async-method-invocation/src/main/java/com/iluwatar/async/method/invocation/AsyncCallback.java index 067b79d43..46556a48e 100644 --- a/async-method-invocation/src/main/java/com/iluwatar/async/method/invocation/AsyncCallback.java +++ b/async-method-invocation/src/main/java/com/iluwatar/async/method/invocation/AsyncCallback.java @@ -2,6 +2,13 @@ package com.iluwatar.async.method.invocation; import java.util.Optional; +/** + * + * AsyncCallback interface + * + * @param+ * We want to build {@link Hero} objects, but its construction is complex because of the + * many parameters needed. To aid the user we introduce {@link HeroBuilder} class. + * {@link HeroBuilder} takes the minimum parameters to build {@link Hero} object in its + * constructor. After that additional configuration for the {@link Hero} object can be + * done using the fluent {@link HeroBuilder} interface. When configuration is ready the + * build method is called to receive the final {@link Hero} object. + * + */ +public class App { + + /** + * Program entry point + * @param args command line args + */ + public static void main(String[] args) { + + Hero mage = new HeroBuilder(Profession.MAGE, "Riobard") + .withHairColor(HairColor.BLACK).withWeapon(Weapon.DAGGER) + .build(); + System.out.println(mage); + + Hero warrior = new HeroBuilder(Profession.WARRIOR, "Amberjill") + .withHairColor(HairColor.BLOND) + .withHairType(HairType.LONG_CURLY).withArmor(Armor.CHAIN_MAIL) + .withWeapon(Weapon.SWORD).build(); + System.out.println(warrior); + + Hero thief = new HeroBuilder(Profession.THIEF, "Desmond") + .withHairType(HairType.BALD).withWeapon(Weapon.BOW).build(); + System.out.println(thief); + + } +} diff --git a/builder/src/main/java/com/iluwatar/builder/Armor.java b/builder/src/main/java/com/iluwatar/builder/Armor.java index ebec6a47d..95fcba43b 100644 --- a/builder/src/main/java/com/iluwatar/builder/Armor.java +++ b/builder/src/main/java/com/iluwatar/builder/Armor.java @@ -1,17 +1,22 @@ -package com.iluwatar.builder; - -public enum Armor { - - CLOTHES("clothes"), LEATHER("leather"), CHAIN_MAIL("chain mail"), PLATE_MAIL("plate mail"); - - private String title; - - Armor(String title) { - this.title = title; - } - - @Override - public String toString() { - return title; - } -} +package com.iluwatar.builder; + +/** + * + * Armor enumeration + * + */ +public enum Armor { + + CLOTHES("clothes"), LEATHER("leather"), CHAIN_MAIL("chain mail"), PLATE_MAIL("plate mail"); + + private String title; + + Armor(String title) { + this.title = title; + } + + @Override + public String toString() { + return title; + } +} diff --git a/builder/src/main/java/com/iluwatar/builder/HairColor.java b/builder/src/main/java/com/iluwatar/builder/HairColor.java index a73044754..dd8ec2ecc 100644 --- a/builder/src/main/java/com/iluwatar/builder/HairColor.java +++ b/builder/src/main/java/com/iluwatar/builder/HairColor.java @@ -1,12 +1,17 @@ -package com.iluwatar.builder; - -public enum HairColor { - - WHITE, BLOND, RED, BROWN, BLACK; - - @Override - public String toString() { - return name().toLowerCase(); - } - -} +package com.iluwatar.builder; + +/** + * + * HairColor enumeration + * + */ +public enum HairColor { + + WHITE, BLOND, RED, BROWN, BLACK; + + @Override + public String toString() { + return name().toLowerCase(); + } + +} diff --git a/builder/src/main/java/com/iluwatar/builder/HairType.java b/builder/src/main/java/com/iluwatar/builder/HairType.java index 075699a58..ea49c0470 100644 --- a/builder/src/main/java/com/iluwatar/builder/HairType.java +++ b/builder/src/main/java/com/iluwatar/builder/HairType.java @@ -1,17 +1,22 @@ -package com.iluwatar.builder; - -public enum HairType { - - BALD("bald"), SHORT("short"), CURLY("curly"), LONG_STRAIGHT("long straight"), LONG_CURLY("long curly"); - - private String title; - - HairType(String title) { - this.title = title; - } - - @Override - public String toString() { - return title; - } -} +package com.iluwatar.builder; + +/** + * + * HairType enumeration + * + */ +public enum HairType { + + BALD("bald"), SHORT("short"), CURLY("curly"), LONG_STRAIGHT("long straight"), LONG_CURLY("long curly"); + + private String title; + + HairType(String title) { + this.title = title; + } + + @Override + public String toString() { + return title; + } +} diff --git a/builder/src/main/java/com/iluwatar/builder/Hero.java b/builder/src/main/java/com/iluwatar/builder/Hero.java index 75513eeda..05304bf09 100644 --- a/builder/src/main/java/com/iluwatar/builder/Hero.java +++ b/builder/src/main/java/com/iluwatar/builder/Hero.java @@ -2,7 +2,7 @@ package com.iluwatar.builder; /** * - * The class with many parameters. + * Hero, the class with many parameters. * */ public class Hero { diff --git a/builder/src/main/java/com/iluwatar/builder/Profession.java b/builder/src/main/java/com/iluwatar/builder/Profession.java index 487fc5133..c9a7cc4e9 100644 --- a/builder/src/main/java/com/iluwatar/builder/Profession.java +++ b/builder/src/main/java/com/iluwatar/builder/Profession.java @@ -1,12 +1,17 @@ -package com.iluwatar.builder; - -public enum Profession { - - WARRIOR, THIEF, MAGE, PRIEST; - - @Override - public String toString() { - return name().toLowerCase(); - } - -} +package com.iluwatar.builder; + +/** + * + * Profession enumeration + * + */ +public enum Profession { + + WARRIOR, THIEF, MAGE, PRIEST; + + @Override + public String toString() { + return name().toLowerCase(); + } + +} diff --git a/builder/src/main/java/com/iluwatar/builder/Weapon.java b/builder/src/main/java/com/iluwatar/builder/Weapon.java index 99622ddac..af71c596d 100644 --- a/builder/src/main/java/com/iluwatar/builder/Weapon.java +++ b/builder/src/main/java/com/iluwatar/builder/Weapon.java @@ -1,12 +1,17 @@ -package com.iluwatar.builder; - -public enum Weapon { - - DAGGER, SWORD, AXE, WARHAMMER, BOW; - - @Override - public String toString() { - return name().toLowerCase(); - } - -} +package com.iluwatar.builder; + +/** + * + * Weapon enumeration + * + */ +public enum Weapon { + + DAGGER, SWORD, AXE, WARHAMMER, BOW; + + @Override + public String toString() { + return name().toLowerCase(); + } + +} diff --git a/builder/src/test/java/com/iluwatar/builder/AppTest.java b/builder/src/test/java/com/iluwatar/builder/AppTest.java index 462ad3a9a..acae1ca70 100644 --- a/builder/src/test/java/com/iluwatar/builder/AppTest.java +++ b/builder/src/test/java/com/iluwatar/builder/AppTest.java @@ -1,14 +1,19 @@ -package com.iluwatar.builder; - -import org.junit.Test; - -import com.iluwatar. builder.App; - -public class AppTest { - - @Test - public void test() { - String[] args = {}; - App.main(args); - } -} +package com.iluwatar.builder; + +import org.junit.Test; + +import com.iluwatar. builder.App; + +/** + * + * Application test + * + */ +public class AppTest { + + @Test + public void test() { + String[] args = {}; + App.main(args); + } +} diff --git a/business-delegate/src/main/java/com/iluwatar/business/delegate/App.java b/business-delegate/src/main/java/com/iluwatar/business/delegate/App.java index 214d8232f..eea7608eb 100644 --- a/business-delegate/src/main/java/com/iluwatar/business/delegate/App.java +++ b/business-delegate/src/main/java/com/iluwatar/business/delegate/App.java @@ -2,21 +2,25 @@ package com.iluwatar.business.delegate; /** * - * The Business Delegate pattern adds an abstraction layer between presentation and business tiers. + * The Business Delegate pattern adds an abstraction layer between the presentation and business tiers. * By using the pattern we gain loose coupling between the tiers. The Business Delegate encapsulates * knowledge about how to locate, connect to, and interact with the business objects that make up * the application. - * + *
* Some of the services the Business Delegate uses are instantiated directly, and some can be retrieved * through service lookups. The Business Delegate itself may contain business logic too potentially tying * together multiple service calls, exception handling, retrying etc. - * - * In this example the client (Client) utilizes a business delegate (BusinessDelegate) to execute a task. + *
+ * In this example the client ({@link Client}) utilizes a business delegate ({@link BusinessDelegate}) to execute a task. * The Business Delegate then selects the appropriate service and makes the service call. * */ public class App { + /** + * Program entry point + * @param args command line args + */ public static void main(String[] args) { BusinessDelegate businessDelegate = new BusinessDelegate(); diff --git a/business-delegate/src/main/java/com/iluwatar/business/delegate/BusinessDelegate.java b/business-delegate/src/main/java/com/iluwatar/business/delegate/BusinessDelegate.java index d70646820..cf0809b97 100644 --- a/business-delegate/src/main/java/com/iluwatar/business/delegate/BusinessDelegate.java +++ b/business-delegate/src/main/java/com/iluwatar/business/delegate/BusinessDelegate.java @@ -2,7 +2,7 @@ package com.iluwatar.business.delegate; /** * - * BusinessDelegate separates presentation and business tiers + * BusinessDelegate separates the presentation and business tiers * */ public class BusinessDelegate { diff --git a/business-delegate/src/test/java/com/iluwatar/business/delegate/AppTest.java b/business-delegate/src/test/java/com/iluwatar/business/delegate/AppTest.java index 3a3dce68e..7ce63c2b4 100644 --- a/business-delegate/src/test/java/com/iluwatar/business/delegate/AppTest.java +++ b/business-delegate/src/test/java/com/iluwatar/business/delegate/AppTest.java @@ -4,6 +4,11 @@ import org.junit.Test; import com.iluwatar.business.delegate.App; +/** + * + * Application test + * + */ public class AppTest { @Test diff --git a/callback/src/main/java/com/iluwatar/callback/App.java b/callback/src/main/java/com/iluwatar/callback/App.java index 546a6b507..513a32415 100644 --- a/callback/src/main/java/com/iluwatar/callback/App.java +++ b/callback/src/main/java/com/iluwatar/callback/App.java @@ -1,8 +1,10 @@ package com.iluwatar.callback; /** - * Callback pattern is more native for functional languages where function is treated as first-class citizen. - * Prior to Java8 can be simulated using simple (alike command) interfaces. + * + * Callback pattern is more native for functional languages where functions are treated as first-class citizens. + * Prior to Java 8 callbacks can be simulated using simple (alike command) interfaces. + * */ public class App { diff --git a/callback/src/main/java/com/iluwatar/callback/Callback.java b/callback/src/main/java/com/iluwatar/callback/Callback.java index 9e757e218..81a421c0d 100644 --- a/callback/src/main/java/com/iluwatar/callback/Callback.java +++ b/callback/src/main/java/com/iluwatar/callback/Callback.java @@ -1,7 +1,9 @@ package com.iluwatar.callback; /** + * * Callback interface + * */ public interface Callback { diff --git a/callback/src/main/java/com/iluwatar/callback/SimpleTask.java b/callback/src/main/java/com/iluwatar/callback/SimpleTask.java index f8a27ba10..58f35709f 100644 --- a/callback/src/main/java/com/iluwatar/callback/SimpleTask.java +++ b/callback/src/main/java/com/iluwatar/callback/SimpleTask.java @@ -1,7 +1,9 @@ package com.iluwatar.callback; /** + * * Implementation of task that need to be executed + * */ public class SimpleTask extends Task { diff --git a/callback/src/main/java/com/iluwatar/callback/Task.java b/callback/src/main/java/com/iluwatar/callback/Task.java index df7bf8ae8..db4b66dc5 100644 --- a/callback/src/main/java/com/iluwatar/callback/Task.java +++ b/callback/src/main/java/com/iluwatar/callback/Task.java @@ -1,7 +1,9 @@ package com.iluwatar.callback; /** + * * Template-method class for callback hook execution + * */ public abstract class Task { diff --git a/callback/src/test/java/com/iluwatar/callback/AppTest.java b/callback/src/test/java/com/iluwatar/callback/AppTest.java index 5d7febcee..aceac1c62 100644 --- a/callback/src/test/java/com/iluwatar/callback/AppTest.java +++ b/callback/src/test/java/com/iluwatar/callback/AppTest.java @@ -4,6 +4,11 @@ import org.junit.Test; import com.iluwatar.callback.App; +/** + * + * Application test + * + */ public class AppTest { @Test diff --git a/chain/src/main/java/com/iluwatar/chain/App.java b/chain/src/main/java/com/iluwatar/chain/App.java index 21d206696..5f98b2478 100644 --- a/chain/src/main/java/com/iluwatar/chain/App.java +++ b/chain/src/main/java/com/iluwatar/chain/App.java @@ -1,22 +1,26 @@ -package com.iluwatar.chain; - -/** - * - * Chain of Responsibility organizes request handlers (RequestHandler) into a - * chain where each handler has a chance to act on the request on its turn. In - * this example the king (OrcKing) makes requests and the military orcs - * (OrcCommander, OrcOfficer, OrcSoldier) form the handler chain. - * - */ -public class App { - - public static void main(String[] args) { - - OrcKing king = new OrcKing(); - king.makeRequest(new Request(RequestType.DEFEND_CASTLE, "defend castle")); - king.makeRequest(new Request(RequestType.TORTURE_PRISONER, - "torture prisoner")); - king.makeRequest(new Request(RequestType.COLLECT_TAX, "collect tax")); - - } -} +package com.iluwatar.chain; + +/** + * + * Chain of Responsibility organizes request handlers ({@link RequestHandler}) into a + * chain where each handler has a chance to act on the request on its turn. In + * this example the king ({@link OrcKing}) makes requests and the military orcs + * ({@link OrcCommander}, {@link OrcOfficer}, {@link OrcSoldier}) form the handler chain. + * + */ +public class App { + + /** + * Program entry point + * @param args command line args + */ + public static void main(String[] args) { + + OrcKing king = new OrcKing(); + king.makeRequest(new Request(RequestType.DEFEND_CASTLE, "defend castle")); + king.makeRequest(new Request(RequestType.TORTURE_PRISONER, + "torture prisoner")); + king.makeRequest(new Request(RequestType.COLLECT_TAX, "collect tax")); + + } +} diff --git a/chain/src/main/java/com/iluwatar/chain/OrcCommander.java b/chain/src/main/java/com/iluwatar/chain/OrcCommander.java index 1f5f4de86..fb5134e01 100644 --- a/chain/src/main/java/com/iluwatar/chain/OrcCommander.java +++ b/chain/src/main/java/com/iluwatar/chain/OrcCommander.java @@ -1,22 +1,27 @@ -package com.iluwatar.chain; - -public class OrcCommander extends RequestHandler { - - public OrcCommander(RequestHandler handler) { - super(handler); - } - - @Override - public void handleRequest(Request req) { - if (req.getRequestType().equals(RequestType.DEFEND_CASTLE)) { - printHandling(req); - } else { - super.handleRequest(req); - } - } - - @Override - public String toString() { - return "Orc commander"; - } -} +package com.iluwatar.chain; + +/** + * + * OrcCommander + * + */ +public class OrcCommander extends RequestHandler { + + public OrcCommander(RequestHandler handler) { + super(handler); + } + + @Override + public void handleRequest(Request req) { + if (req.getRequestType().equals(RequestType.DEFEND_CASTLE)) { + printHandling(req); + } else { + super.handleRequest(req); + } + } + + @Override + public String toString() { + return "Orc commander"; + } +} diff --git a/chain/src/main/java/com/iluwatar/chain/OrcKing.java b/chain/src/main/java/com/iluwatar/chain/OrcKing.java index afd2616fe..b39959935 100644 --- a/chain/src/main/java/com/iluwatar/chain/OrcKing.java +++ b/chain/src/main/java/com/iluwatar/chain/OrcKing.java @@ -1,24 +1,24 @@ -package com.iluwatar.chain; - -/** - * - * Makes requests that are handled by the chain. - * - */ -public class OrcKing { - - RequestHandler chain; - - public OrcKing() { - buildChain(); - } - - private void buildChain() { - chain = new OrcCommander(new OrcOfficer(new OrcSoldier(null))); - } - - public void makeRequest(Request req) { - chain.handleRequest(req); - } - -} +package com.iluwatar.chain; + +/** + * + * OrcKing makes requests that are handled by the chain. + * + */ +public class OrcKing { + + RequestHandler chain; + + public OrcKing() { + buildChain(); + } + + private void buildChain() { + chain = new OrcCommander(new OrcOfficer(new OrcSoldier(null))); + } + + public void makeRequest(Request req) { + chain.handleRequest(req); + } + +} diff --git a/chain/src/main/java/com/iluwatar/chain/OrcOfficer.java b/chain/src/main/java/com/iluwatar/chain/OrcOfficer.java index c09729cc8..131cb1101 100644 --- a/chain/src/main/java/com/iluwatar/chain/OrcOfficer.java +++ b/chain/src/main/java/com/iluwatar/chain/OrcOfficer.java @@ -1,23 +1,28 @@ -package com.iluwatar.chain; - -public class OrcOfficer extends RequestHandler { - - public OrcOfficer(RequestHandler handler) { - super(handler); - } - - @Override - public void handleRequest(Request req) { - if (req.getRequestType().equals(RequestType.TORTURE_PRISONER)) { - printHandling(req); - } else { - super.handleRequest(req); - } - } - - @Override - public String toString() { - return "Orc officer"; - } - -} +package com.iluwatar.chain; + +/** + * + * OrcOfficer + * + */ +public class OrcOfficer extends RequestHandler { + + public OrcOfficer(RequestHandler handler) { + super(handler); + } + + @Override + public void handleRequest(Request req) { + if (req.getRequestType().equals(RequestType.TORTURE_PRISONER)) { + printHandling(req); + } else { + super.handleRequest(req); + } + } + + @Override + public String toString() { + return "Orc officer"; + } + +} diff --git a/chain/src/main/java/com/iluwatar/chain/OrcSoldier.java b/chain/src/main/java/com/iluwatar/chain/OrcSoldier.java index f52c7d543..a681dfb77 100644 --- a/chain/src/main/java/com/iluwatar/chain/OrcSoldier.java +++ b/chain/src/main/java/com/iluwatar/chain/OrcSoldier.java @@ -1,22 +1,27 @@ -package com.iluwatar.chain; - -public class OrcSoldier extends RequestHandler { - - public OrcSoldier(RequestHandler handler) { - super(handler); - } - - @Override - public void handleRequest(Request req) { - if (req.getRequestType().equals(RequestType.COLLECT_TAX)) { - printHandling(req); - } else { - super.handleRequest(req); - } - } - - @Override - public String toString() { - return "Orc soldier"; - } -} +package com.iluwatar.chain; + +/** + * + * OrcSoldier + * + */ +public class OrcSoldier extends RequestHandler { + + public OrcSoldier(RequestHandler handler) { + super(handler); + } + + @Override + public void handleRequest(Request req) { + if (req.getRequestType().equals(RequestType.COLLECT_TAX)) { + printHandling(req); + } else { + super.handleRequest(req); + } + } + + @Override + public String toString() { + return "Orc soldier"; + } +} diff --git a/chain/src/main/java/com/iluwatar/chain/Request.java b/chain/src/main/java/com/iluwatar/chain/Request.java index ad55522f0..558ee65d1 100644 --- a/chain/src/main/java/com/iluwatar/chain/Request.java +++ b/chain/src/main/java/com/iluwatar/chain/Request.java @@ -1,33 +1,38 @@ -package com.iluwatar.chain; - -public class Request { - - private String requestDescription; - private RequestType requestType; - - public Request(RequestType requestType, String requestDescription) { - this.setRequestType(requestType); - this.setRequestDescription(requestDescription); - } - - public String getRequestDescription() { - return requestDescription; - } - - public void setRequestDescription(String requestDescription) { - this.requestDescription = requestDescription; - } - - public RequestType getRequestType() { - return requestType; - } - - public void setRequestType(RequestType requestType) { - this.requestType = requestType; - } - - @Override - public String toString() { - return getRequestDescription(); - } -} +package com.iluwatar.chain; + +/** + * + * Request + * + */ +public class Request { + + private String requestDescription; + private RequestType requestType; + + public Request(RequestType requestType, String requestDescription) { + this.setRequestType(requestType); + this.setRequestDescription(requestDescription); + } + + public String getRequestDescription() { + return requestDescription; + } + + public void setRequestDescription(String requestDescription) { + this.requestDescription = requestDescription; + } + + public RequestType getRequestType() { + return requestType; + } + + public void setRequestType(RequestType requestType) { + this.requestType = requestType; + } + + @Override + public String toString() { + return getRequestDescription(); + } +} diff --git a/chain/src/main/java/com/iluwatar/chain/RequestHandler.java b/chain/src/main/java/com/iluwatar/chain/RequestHandler.java index dbb8b10a6..5570c20ce 100644 --- a/chain/src/main/java/com/iluwatar/chain/RequestHandler.java +++ b/chain/src/main/java/com/iluwatar/chain/RequestHandler.java @@ -1,23 +1,28 @@ -package com.iluwatar.chain; - -public abstract class RequestHandler { - - private RequestHandler next; - - public RequestHandler(RequestHandler next) { - this.next = next; - } - - public void handleRequest(Request req) { - if (next != null) { - next.handleRequest(req); - } - } - - protected void printHandling(Request req) { - System.out.println(this + " handling request \"" + req + "\""); - } - - @Override - public abstract String toString(); -} +package com.iluwatar.chain; + +/** + * + * RequestHandler + * + */ +public abstract class RequestHandler { + + private RequestHandler next; + + public RequestHandler(RequestHandler next) { + this.next = next; + } + + public void handleRequest(Request req) { + if (next != null) { + next.handleRequest(req); + } + } + + protected void printHandling(Request req) { + System.out.println(this + " handling request \"" + req + "\""); + } + + @Override + public abstract String toString(); +} diff --git a/chain/src/main/java/com/iluwatar/chain/RequestType.java b/chain/src/main/java/com/iluwatar/chain/RequestType.java index 21727535e..9ad975d2f 100644 --- a/chain/src/main/java/com/iluwatar/chain/RequestType.java +++ b/chain/src/main/java/com/iluwatar/chain/RequestType.java @@ -1,7 +1,12 @@ -package com.iluwatar.chain; - -public enum RequestType { - - DEFEND_CASTLE, TORTURE_PRISONER, COLLECT_TAX - -} +package com.iluwatar.chain; + +/** + * + * RequestType enumeration + * + */ +public enum RequestType { + + DEFEND_CASTLE, TORTURE_PRISONER, COLLECT_TAX + +} diff --git a/chain/src/test/java/com/iluwatar/chain/AppTest.java b/chain/src/test/java/com/iluwatar/chain/AppTest.java index 5edba69bb..aa52e60e2 100644 --- a/chain/src/test/java/com/iluwatar/chain/AppTest.java +++ b/chain/src/test/java/com/iluwatar/chain/AppTest.java @@ -1,14 +1,19 @@ -package com.iluwatar.chain; - -import org.junit.Test; - -import com.iluwatar.chain.App; - -public class AppTest { - - @Test - public void test() { - String[] args = {}; - App.main(args); - } -} +package com.iluwatar.chain; + +import org.junit.Test; + +import com.iluwatar.chain.App; + +/** + * + * Application test + * + */ +public class AppTest { + + @Test + public void test() { + String[] args = {}; + App.main(args); + } +} diff --git a/command/src/main/java/com/iluwatar/command/App.java b/command/src/main/java/com/iluwatar/command/App.java index 6d9df821c..fc05afa66 100644 --- a/command/src/main/java/com/iluwatar/command/App.java +++ b/command/src/main/java/com/iluwatar/command/App.java @@ -3,15 +3,15 @@ package com.iluwatar.command; /** * * In Command pattern actions are objects that can be executed and undone. - * + *
* Four terms always associated with the command pattern are command, receiver, invoker and client. A command - * object (spell) knows about receiver (target) and invokes a method of the receiver. Values for parameters of + * object (spell) knows about the receiver (target) and invokes a method of the receiver. Values for parameters of * the receiver method are stored in the command. The receiver then does the work. An invoker object (wizard) * knows how to execute a command, and optionally does bookkeeping about the command execution. The invoker * does not know anything about a concrete command, it knows only about command interface. Both an invoker object * and several command objects are held by a client object (app). The client decides which commands to execute at * which points. To execute a command, it passes the command object to the invoker object. - * + *
* In other words, in this example the wizard casts spells on the goblin. The wizard keeps track of the previous
* spells cast, so it is easy to undo them. In addition, the wizard keeps track of the spells undone, so they
* can be redone.
@@ -20,6 +20,10 @@ package com.iluwatar.command;
*/
public class App {
+ /**
+ * Program entry point
+ * @param args command line args
+ */
public static void main(String[] args) {
Wizard wizard = new Wizard();
Goblin goblin = new Goblin();
diff --git a/command/src/test/java/com/iluwatar/command/AppTest.java b/command/src/test/java/com/iluwatar/command/AppTest.java
index 454f92b63..2fd5c16b4 100644
--- a/command/src/test/java/com/iluwatar/command/AppTest.java
+++ b/command/src/test/java/com/iluwatar/command/AppTest.java
@@ -1,14 +1,19 @@
-package com.iluwatar.command;
-
-import org.junit.Test;
-
-import com.iluwatar.command.App;
-
-public class AppTest {
-
- @Test
- public void test() {
- String[] args = {};
- App.main(args);
- }
-}
+package com.iluwatar.command;
+
+import org.junit.Test;
+
+import com.iluwatar.command.App;
+
+/**
+ *
+ * Application test
+ *
+ */
+public class AppTest {
+
+ @Test
+ public void test() {
+ String[] args = {};
+ App.main(args);
+ }
+}
diff --git a/composite/src/main/java/com/iluwatar/composite/App.java b/composite/src/main/java/com/iluwatar/composite/App.java
index 6dd62a552..7dfd15443 100644
--- a/composite/src/main/java/com/iluwatar/composite/App.java
+++ b/composite/src/main/java/com/iluwatar/composite/App.java
@@ -1,25 +1,29 @@
-package com.iluwatar.composite;
-
-/**
- *
- * With Composite we can treat tree hierarchies of objects with uniform
- * interface (LetterComposite). In this example we have sentences composed of
- * words composed of letters.
- *
- */
-public class App {
-
- public static void main(String[] args) {
- System.out.println("Message from the orcs: ");
-
- LetterComposite orcMessage = new Messenger().messageFromOrcs();
- orcMessage.print();
-
- System.out.println("\n");
-
- System.out.println("Message from the elves: ");
-
- LetterComposite elfMessage = new Messenger().messageFromElves();
- elfMessage.print();
- }
-}
+package com.iluwatar.composite;
+
+/**
+ *
+ * With Composite we can treat tree hierarchies of objects with uniform
+ * interface ({@link LetterComposite}). In this example we have sentences composed of
+ * words composed of letters.
+ *
+ */
+public class App {
+
+ /**
+ * Program entry point
+ * @param args command line args
+ */
+ public static void main(String[] args) {
+ System.out.println("Message from the orcs: ");
+
+ LetterComposite orcMessage = new Messenger().messageFromOrcs();
+ orcMessage.print();
+
+ System.out.println("\n");
+
+ System.out.println("Message from the elves: ");
+
+ LetterComposite elfMessage = new Messenger().messageFromElves();
+ elfMessage.print();
+ }
+}
diff --git a/composite/src/main/java/com/iluwatar/composite/Letter.java b/composite/src/main/java/com/iluwatar/composite/Letter.java
index 9df8b95f7..8304ea801 100644
--- a/composite/src/main/java/com/iluwatar/composite/Letter.java
+++ b/composite/src/main/java/com/iluwatar/composite/Letter.java
@@ -1,21 +1,26 @@
-package com.iluwatar.composite;
-
-public class Letter extends LetterComposite {
-
- private char c;
-
- public Letter(char c) {
- this.c = c;
- }
-
- @Override
- protected void printThisBefore() {
- System.out.print(c);
- }
-
- @Override
- protected void printThisAfter() {
- // nop
- }
-
-}
+package com.iluwatar.composite;
+
+/**
+ *
+ * Letter
+ *
+ */
+public class Letter extends LetterComposite {
+
+ private char c;
+
+ public Letter(char c) {
+ this.c = c;
+ }
+
+ @Override
+ protected void printThisBefore() {
+ System.out.print(c);
+ }
+
+ @Override
+ protected void printThisAfter() {
+ // nop
+ }
+
+}
diff --git a/composite/src/main/java/com/iluwatar/composite/Messenger.java b/composite/src/main/java/com/iluwatar/composite/Messenger.java
index a849408ca..aa0560d4d 100644
--- a/composite/src/main/java/com/iluwatar/composite/Messenger.java
+++ b/composite/src/main/java/com/iluwatar/composite/Messenger.java
@@ -1,53 +1,58 @@
-package com.iluwatar.composite;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-public class Messenger {
-
- LetterComposite messageFromOrcs() {
-
- List
+ * Using decorator pattern it is possible to change class behavior during
+ * runtime, as the example shows.
+ *
+ */
+public class App {
+
+ /**
+ * Program entry point
+ * @param args command line args
+ */
+ public static void main(String[] args) {
+
+ // simple troll
+ System.out.println("A simple looking troll approaches.");
+ Hostile troll = new Troll();
+ troll.attack();
+ troll.fleeBattle();
+
+ // change the behavior of the simple troll by adding a decorator
+ System.out.println("\nA smart looking troll surprises you.");
+ Hostile smart = new SmartTroll(troll);
+ smart.attack();
+ smart.fleeBattle();
+ }
+}
diff --git a/decorator/src/main/java/com/iluwatar/decorator/SmartTroll.java b/decorator/src/main/java/com/iluwatar/decorator/SmartTroll.java
index 9baa729f3..22ba88dc8 100644
--- a/decorator/src/main/java/com/iluwatar/decorator/SmartTroll.java
+++ b/decorator/src/main/java/com/iluwatar/decorator/SmartTroll.java
@@ -1,30 +1,30 @@
-package com.iluwatar.decorator;
-
-/**
- * SmartTroll is a decorator for Hostile objects.
- * The calls to the Hostile interface are intercepted
- * and decorated. Finally the calls are delegated
- * to the decorated Hostile object.
- *
- */
-public class SmartTroll implements Hostile {
-
- private Hostile decorated;
-
- public SmartTroll(Hostile decorated) {
- this.decorated = decorated;
- }
-
- @Override
- public void attack() {
- System.out.println("The troll throws a rock at you!");
- decorated.attack();
- }
-
- @Override
- public void fleeBattle() {
- System.out.println("The troll calls for help!");
- decorated.fleeBattle();
- }
-
-}
+package com.iluwatar.decorator;
+
+/**
+ * SmartTroll is a decorator for {@link Hostile} objects.
+ * The calls to the {@link Hostile} interface are intercepted
+ * and decorated. Finally the calls are delegated
+ * to the decorated {@link Hostile} object.
+ *
+ */
+public class SmartTroll implements Hostile {
+
+ private Hostile decorated;
+
+ public SmartTroll(Hostile decorated) {
+ this.decorated = decorated;
+ }
+
+ @Override
+ public void attack() {
+ System.out.println("The troll throws a rock at you!");
+ decorated.attack();
+ }
+
+ @Override
+ public void fleeBattle() {
+ System.out.println("The troll calls for help!");
+ decorated.fleeBattle();
+ }
+
+}
diff --git a/decorator/src/main/java/com/iluwatar/decorator/Troll.java b/decorator/src/main/java/com/iluwatar/decorator/Troll.java
index 8d6cd0aa5..11e9b9d1a 100644
--- a/decorator/src/main/java/com/iluwatar/decorator/Troll.java
+++ b/decorator/src/main/java/com/iluwatar/decorator/Troll.java
@@ -1,18 +1,18 @@
-package com.iluwatar.decorator;
-
-/**
- *
- * Troll implements Hostile interface directly.
- *
- */
-public class Troll implements Hostile {
-
- public void attack() {
- System.out.println("The troll swings at you with a club!");
- }
-
- public void fleeBattle() {
- System.out.println("The troll shrieks in horror and runs away!");
- }
-
-}
+package com.iluwatar.decorator;
+
+/**
+ *
+ * Troll implements {@link Hostile} interface directly.
+ *
+ */
+public class Troll implements Hostile {
+
+ public void attack() {
+ System.out.println("The troll swings at you with a club!");
+ }
+
+ public void fleeBattle() {
+ System.out.println("The troll shrieks in horror and runs away!");
+ }
+
+}
diff --git a/decorator/src/test/java/com/iluwatar/decorator/AppTest.java b/decorator/src/test/java/com/iluwatar/decorator/AppTest.java
index 28776c930..b74bd3a06 100644
--- a/decorator/src/test/java/com/iluwatar/decorator/AppTest.java
+++ b/decorator/src/test/java/com/iluwatar/decorator/AppTest.java
@@ -1,14 +1,19 @@
-package com.iluwatar.decorator;
-
-import org.junit.Test;
-
-import com.iluwatar.decorator.App;
-
-public class AppTest {
-
- @Test
- public void test() {
- String[] args = {};
- App.main(args);
- }
-}
+package com.iluwatar.decorator;
+
+import org.junit.Test;
+
+import com.iluwatar.decorator.App;
+
+/**
+ *
+ * Application test
+ *
+ */
+public class AppTest {
+
+ @Test
+ public void test() {
+ String[] args = {};
+ App.main(args);
+ }
+}
diff --git a/dependency-injection/src/main/java/com/iluwatar/dependency/injection/App.java b/dependency-injection/src/main/java/com/iluwatar/dependency/injection/App.java
index 5d15e3742..a882863b7 100644
--- a/dependency-injection/src/main/java/com/iluwatar/dependency/injection/App.java
+++ b/dependency-injection/src/main/java/com/iluwatar/dependency/injection/App.java
@@ -9,23 +9,27 @@ import com.google.inject.Injector;
* implements so called inversion of control principle. Inversion of control has two specific rules:
* - High-level modules should not depend on low-level modules. Both should depend on abstractions.
* - Abstractions should not depend on details. Details should depend on abstractions.
- *
- * In this example we show you three different wizards. The first one (SimpleWizard) is a naive
+ *
+ * In this example we show you three different wizards. The first one ({@link SimpleWizard}) is a naive
* implementation violating the inversion of control principle. It depends directly on a concrete
* implementation which cannot be changed.
- *
- * The second wizard (AdvancedWizard) is more flexible. It does not depend on any concrete implementation
- * but abstraction. It utilizes Dependency Injection pattern allowing its Tobacco dependency to be
+ *
+ * The second wizard ({@link AdvancedWizard}) is more flexible. It does not depend on any concrete implementation
+ * but abstraction. It utilizes Dependency Injection pattern allowing its {@link Tobacco} dependency to be
* injected through its constructor. This way, handling the dependency is no longer the wizard's
* responsibility. It is resolved outside the wizard class.
- *
+ *
* The third example takes the pattern a step further. It uses Guice framework for Dependency Injection.
- * TobaccoModule binds a concrete implementation to abstraction. Injector is then used to create
- * GuiceWizard object with correct dependencies.
+ * {@link TobaccoModule} binds a concrete implementation to abstraction. Injector is then used to create
+ * {@link GuiceWizard} object with correct dependencies.
*
*/
public class App {
+ /**
+ * Program entry point
+ * @param args command line args
+ */
public static void main( String[] args ) {
SimpleWizard simpleWizard = new SimpleWizard();
simpleWizard.smoke();
diff --git a/dependency-injection/src/main/java/com/iluwatar/dependency/injection/OldTobyTobacco.java b/dependency-injection/src/main/java/com/iluwatar/dependency/injection/OldTobyTobacco.java
index 08d9c0d12..9197066ee 100644
--- a/dependency-injection/src/main/java/com/iluwatar/dependency/injection/OldTobyTobacco.java
+++ b/dependency-injection/src/main/java/com/iluwatar/dependency/injection/OldTobyTobacco.java
@@ -2,7 +2,7 @@ package com.iluwatar.dependency.injection;
/**
*
- * OldTobyTobacco concrete Tobacco implementation
+ * OldTobyTobacco concrete {@link Tobacco} implementation
*
*/
public class OldTobyTobacco extends Tobacco {
diff --git a/dependency-injection/src/main/java/com/iluwatar/dependency/injection/RivendellTobacco.java b/dependency-injection/src/main/java/com/iluwatar/dependency/injection/RivendellTobacco.java
index b64a6b93b..9eb137a05 100644
--- a/dependency-injection/src/main/java/com/iluwatar/dependency/injection/RivendellTobacco.java
+++ b/dependency-injection/src/main/java/com/iluwatar/dependency/injection/RivendellTobacco.java
@@ -2,7 +2,7 @@ package com.iluwatar.dependency.injection;
/**
*
- * RivendellTobacco concrete Tobacco implementation
+ * RivendellTobacco concrete {@link Tobacco} implementation
*
*/
public class RivendellTobacco extends Tobacco {
diff --git a/dependency-injection/src/main/java/com/iluwatar/dependency/injection/SecondBreakfastTobacco.java b/dependency-injection/src/main/java/com/iluwatar/dependency/injection/SecondBreakfastTobacco.java
index 1826f269a..269f531d3 100644
--- a/dependency-injection/src/main/java/com/iluwatar/dependency/injection/SecondBreakfastTobacco.java
+++ b/dependency-injection/src/main/java/com/iluwatar/dependency/injection/SecondBreakfastTobacco.java
@@ -2,7 +2,7 @@ package com.iluwatar.dependency.injection;
/**
*
- * SecondBreakfastTobacco concrete Tobacco implementation
+ * SecondBreakfastTobacco concrete {@link Tobacco} implementation
*
*/
public class SecondBreakfastTobacco extends Tobacco {
diff --git a/dependency-injection/src/main/java/com/iluwatar/dependency/injection/TobaccoModule.java b/dependency-injection/src/main/java/com/iluwatar/dependency/injection/TobaccoModule.java
index 12c5a57ff..d2dd1072e 100644
--- a/dependency-injection/src/main/java/com/iluwatar/dependency/injection/TobaccoModule.java
+++ b/dependency-injection/src/main/java/com/iluwatar/dependency/injection/TobaccoModule.java
@@ -4,7 +4,7 @@ import com.google.inject.AbstractModule;
/**
*
- * Guice module for binding certain concrete Tobacco implementation.
+ * Guice module for binding certain concrete {@link Tobacco} implementation.
*
*/
public class TobaccoModule extends AbstractModule {
diff --git a/dependency-injection/src/test/java/com/iluwatar/dependency/injection/AppTest.java b/dependency-injection/src/test/java/com/iluwatar/dependency/injection/AppTest.java
index d01bc7cbe..5315fe1db 100644
--- a/dependency-injection/src/test/java/com/iluwatar/dependency/injection/AppTest.java
+++ b/dependency-injection/src/test/java/com/iluwatar/dependency/injection/AppTest.java
@@ -4,6 +4,11 @@ import org.junit.Test;
import com.iluwatar.dependency.injection.App;
+/**
+ *
+ * Application test
+ *
+ */
public class AppTest {
@Test
diff --git a/double-checked-locking/src/main/java/com/iluwatar/doublechecked/locking/App.java b/double-checked-locking/src/main/java/com/iluwatar/doublechecked/locking/App.java
index 10d22a5b2..2a5c65813 100644
--- a/double-checked-locking/src/main/java/com/iluwatar/doublechecked/locking/App.java
+++ b/double-checked-locking/src/main/java/com/iluwatar/doublechecked/locking/App.java
@@ -5,13 +5,18 @@ import java.util.concurrent.Executors;
/**
*
- * In Inventory we store the items with a given size. However, we do not store
+ * In {@link Inventory} we store the items with a given size. However, we do not store
* more items than the inventory size. To address concurrent access problems we
* use double checked locking to add item to inventory. In this method, the
* thread which gets the lock first adds the item.
+ *
*/
public class App {
+ /**
+ * Program entry point
+ * @param args command line args
+ */
public static void main(String[] args) {
final Inventory inventory = new Inventory(1000);
ExecutorService executorService = Executors.newFixedThreadPool(3);
diff --git a/double-checked-locking/src/main/java/com/iluwatar/doublechecked/locking/Inventory.java b/double-checked-locking/src/main/java/com/iluwatar/doublechecked/locking/Inventory.java
index e69d30b10..9f663f272 100644
--- a/double-checked-locking/src/main/java/com/iluwatar/doublechecked/locking/Inventory.java
+++ b/double-checked-locking/src/main/java/com/iluwatar/doublechecked/locking/Inventory.java
@@ -5,6 +5,11 @@ import java.util.List;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
+/**
+ *
+ * Inventory
+ *
+ */
public class Inventory {
private int inventorySize;
diff --git a/double-checked-locking/src/main/java/com/iluwatar/doublechecked/locking/Item.java b/double-checked-locking/src/main/java/com/iluwatar/doublechecked/locking/Item.java
index 81db22115..8fc7f3888 100644
--- a/double-checked-locking/src/main/java/com/iluwatar/doublechecked/locking/Item.java
+++ b/double-checked-locking/src/main/java/com/iluwatar/doublechecked/locking/Item.java
@@ -1,6 +1,12 @@
package com.iluwatar.doublechecked.locking;
+/**
+ *
+ * Item
+ *
+ */
public class Item {
- String name;
- int level;
+
+ private String name;
+ private int level;
}
diff --git a/double-checked-locking/src/test/java/com/iluwatar/doublechecked/locking/AppTest.java b/double-checked-locking/src/test/java/com/iluwatar/doublechecked/locking/AppTest.java
index 51db32c4f..14fd47488 100644
--- a/double-checked-locking/src/test/java/com/iluwatar/doublechecked/locking/AppTest.java
+++ b/double-checked-locking/src/test/java/com/iluwatar/doublechecked/locking/AppTest.java
@@ -4,6 +4,11 @@ import org.junit.Test;
import com.iluwatar.doublechecked.locking.App;
+/**
+ *
+ * Application test
+ *
+ */
public class AppTest {
@Test
diff --git a/double-dispatch/src/main/java/com/iluwatar/doubledispatch/App.java b/double-dispatch/src/main/java/com/iluwatar/doubledispatch/App.java
index fa799ecfc..f32c93cb1 100644
--- a/double-dispatch/src/main/java/com/iluwatar/doubledispatch/App.java
+++ b/double-dispatch/src/main/java/com/iluwatar/doubledispatch/App.java
@@ -8,23 +8,27 @@ import java.util.List;
* When a message with a parameter is sent to an object, the resultant behaviour is defined by the
* implementation of that method in the receiver. Sometimes the behaviour must also be determined
* by the type of the parameter.
- *
+ *
* One way to implement this would be to create multiple instanceof-checks for the methods parameter.
* However, this creates a maintenance issue. When new types are added we would also need to change
* the method's implementation and add a new instanceof-check. This violates the single responsibility
* principle - a class should have only one reason to change.
- *
+ *
* Instead of the instanceof-checks a better way is to make another virtual call on the parameter
* object. This way new functionality can be easily added without the need to modify existing
* implementation (open-closed principle).
- *
- * In this example we have hierarchy of objects (GameObject) that can collide to each other. Each
+ *
+ * In this example we have hierarchy of objects ({@link GameObject}) that can collide to each other. Each
* object has its own coordinates which are checked against the other objects' coordinates. If
* there is an overlap, then the objects collide utilizing the Double Dispatch pattern.
*
*/
public class App {
+ /**
+ * Program entry point
+ * @param args command line args
+ */
public static void main( String[] args ) {
// initialize game objects and print their status
List
+ * In the example {@link LordBaelish}, {@link LordVarys} and {@link Scout} deliver events to
+ * {@link KingsHand}. {@link KingsHand}, the event aggregator, then delivers the events
+ * to {@link KingJoffrey}.
*
*/
public class App {
+ /**
+ * Program entry point
+ * @param args command line args
+ */
public static void main(String[] args) {
KingJoffrey kingJoffrey = new KingJoffrey();
diff --git a/event-aggregator/src/main/java/com/iluwatar/event/aggregator/KingJoffrey.java b/event-aggregator/src/main/java/com/iluwatar/event/aggregator/KingJoffrey.java
index c94d821be..da45f2f1e 100644
--- a/event-aggregator/src/main/java/com/iluwatar/event/aggregator/KingJoffrey.java
+++ b/event-aggregator/src/main/java/com/iluwatar/event/aggregator/KingJoffrey.java
@@ -2,7 +2,7 @@ package com.iluwatar.event.aggregator;
/**
*
- * KingJoffrey observes events from KingsHand.
+ * KingJoffrey observes events from {@link KingsHand}.
*
*/
public class KingJoffrey implements EventObserver {
diff --git a/event-aggregator/src/main/java/com/iluwatar/event/aggregator/Weekday.java b/event-aggregator/src/main/java/com/iluwatar/event/aggregator/Weekday.java
index 651a4e71c..bafc4f36a 100644
--- a/event-aggregator/src/main/java/com/iluwatar/event/aggregator/Weekday.java
+++ b/event-aggregator/src/main/java/com/iluwatar/event/aggregator/Weekday.java
@@ -1,5 +1,10 @@
package com.iluwatar.event.aggregator;
+/**
+ *
+ * Weekday enumeration
+ *
+ */
public enum Weekday {
MONDAY("Monday"), TUESDAY("Tuesday"), WEDNESDAY("Wednesday"), THURSDAY("Thursday"), FRIDAY("Friday"), SATURDAY("Saturday"), SUNDAY("Sunday");
diff --git a/event-aggregator/src/test/java/com/iluwatar/event/aggregator/AppTest.java b/event-aggregator/src/test/java/com/iluwatar/event/aggregator/AppTest.java
index 1d2562e2c..f8f765880 100644
--- a/event-aggregator/src/test/java/com/iluwatar/event/aggregator/AppTest.java
+++ b/event-aggregator/src/test/java/com/iluwatar/event/aggregator/AppTest.java
@@ -3,6 +3,11 @@ import org.junit.Test;
import com.iluwatar.event.aggregator.App;
+/**
+ *
+ * Application test
+ *
+ */
public class AppTest {
@Test
diff --git a/execute-around/src/main/java/com/iluwatar/execute/around/App.java b/execute-around/src/main/java/com/iluwatar/execute/around/App.java
index 8603a12bc..910a024de 100644
--- a/execute-around/src/main/java/com/iluwatar/execute/around/App.java
+++ b/execute-around/src/main/java/com/iluwatar/execute/around/App.java
@@ -7,14 +7,19 @@ import java.io.IOException;
* The Execute Around idiom specifies some code to be executed before and after
* a method. Typically the idiom is used when the API has methods to be executed in
* pairs, such as resource allocation/deallocation or lock acquisition/release.
- *
- * In this example, we have SimpleFileWriter class that opens and closes the file
+ *
+ * In this example, we have {@link SimpleFileWriter} class that opens and closes the file
* for the user. The user specifies only what to do with the file by providing the
- * FileWriterAction implementation.
+ * {@link FileWriterAction} implementation.
*
*/
public class App {
+ /**
+ * Program entry point
+ * @param args command line args
+ * @throws IOException
+ */
public static void main( String[] args ) throws IOException {
new SimpleFileWriter("testfile.txt", new FileWriterAction() {
diff --git a/execute-around/src/main/java/com/iluwatar/execute/around/SimpleFileWriter.java b/execute-around/src/main/java/com/iluwatar/execute/around/SimpleFileWriter.java
index 2de1e5d67..a7ee11d15 100644
--- a/execute-around/src/main/java/com/iluwatar/execute/around/SimpleFileWriter.java
+++ b/execute-around/src/main/java/com/iluwatar/execute/around/SimpleFileWriter.java
@@ -6,7 +6,7 @@ import java.io.IOException;
/**
*
* SimpleFileWriter handles opening and closing file for the user. The user
- * only has to specify what to do with the file resource through FileWriterAction
+ * only has to specify what to do with the file resource through {@link FileWriterAction}
* parameter.
*
*/
diff --git a/facade/src/main/java/com/iluwatar/facade/App.java b/facade/src/main/java/com/iluwatar/facade/App.java
index 09d5d1a0b..0d8eccd4b 100644
--- a/facade/src/main/java/com/iluwatar/facade/App.java
+++ b/facade/src/main/java/com/iluwatar/facade/App.java
@@ -1,17 +1,22 @@
-package com.iluwatar.facade;
-
-/**
- *
- * Facade (DwarvenGoldmineFacade) provides simpler interface to subsystem.
- * http://en.wikipedia.org/wiki/Facade_pattern
- *
- */
-public class App {
-
- public static void main(String[] args) {
- DwarvenGoldmineFacade facade = new DwarvenGoldmineFacade();
- facade.startNewDay();
- facade.digOutGold();
- facade.endDay();
- }
-}
+package com.iluwatar.facade;
+
+/**
+ *
+ * Facade ({@link DwarvenGoldmineFacade}) provides simpler interface to subsystem.
+ *
+ * http://en.wikipedia.org/wiki/Facade_pattern
+ *
+ */
+public class App {
+
+ /**
+ * Program entry point
+ * @param args command line args
+ */
+ public static void main(String[] args) {
+ DwarvenGoldmineFacade facade = new DwarvenGoldmineFacade();
+ facade.startNewDay();
+ facade.digOutGold();
+ facade.endDay();
+ }
+}
diff --git a/facade/src/test/java/com/iluwatar/facade/AppTest.java b/facade/src/test/java/com/iluwatar/facade/AppTest.java
index b32b16bb1..bfca5473a 100644
--- a/facade/src/test/java/com/iluwatar/facade/AppTest.java
+++ b/facade/src/test/java/com/iluwatar/facade/AppTest.java
@@ -1,14 +1,19 @@
-package com.iluwatar.facade;
-
-import org.junit.Test;
-
-import com.iluwatar.facade.App;
-
-public class AppTest {
-
- @Test
- public void test() {
- String[] args = {};
- App.main(args);
- }
-}
+package com.iluwatar.facade;
+
+import org.junit.Test;
+
+import com.iluwatar.facade.App;
+
+/**
+ *
+ * Application test
+ *
+ */
+public class AppTest {
+
+ @Test
+ public void test() {
+ String[] args = {};
+ App.main(args);
+ }
+}
diff --git a/factory-method/src/main/java/com/iluwatar/factory/method/App.java b/factory-method/src/main/java/com/iluwatar/factory/method/App.java
index 41b234791..69bda3489 100644
--- a/factory-method/src/main/java/com/iluwatar/factory/method/App.java
+++ b/factory-method/src/main/java/com/iluwatar/factory/method/App.java
@@ -2,13 +2,18 @@ package com.iluwatar.factory.method;
/**
*
- * In Factory Method we have an interface (Blacksmith) with a method for
- * creating objects (manufactureWeapon). The concrete subclasses (OrcBlacksmith,
- * ElfBlacksmith) then override the method to produce objects of their liking.
+ * In Factory Method we have an interface ({@link Blacksmith}) with a method for
+ * creating objects ({@link Blacksmith#manufactureWeapon}). The concrete subclasses
+ * ({@link OrcBlacksmith}, {@link ElfBlacksmith}) then override the method to produce
+ * objects of their liking.
*
*/
public class App {
+ /**
+ * Program entry point
+ * @param args command line args
+ */
public static void main(String[] args) {
Blacksmith blacksmith;
Weapon weapon;
diff --git a/factory-method/src/main/java/com/iluwatar/factory/method/ElfWeapon.java b/factory-method/src/main/java/com/iluwatar/factory/method/ElfWeapon.java
index a425d3ce7..75bb8a9e0 100644
--- a/factory-method/src/main/java/com/iluwatar/factory/method/ElfWeapon.java
+++ b/factory-method/src/main/java/com/iluwatar/factory/method/ElfWeapon.java
@@ -1,5 +1,10 @@
package com.iluwatar.factory.method;
+/**
+ *
+ * ElfWeapon
+ *
+ */
public class ElfWeapon implements Weapon {
private WeaponType weaponType;
diff --git a/factory-method/src/main/java/com/iluwatar/factory/method/OrcWeapon.java b/factory-method/src/main/java/com/iluwatar/factory/method/OrcWeapon.java
index ab9b83991..85500799e 100644
--- a/factory-method/src/main/java/com/iluwatar/factory/method/OrcWeapon.java
+++ b/factory-method/src/main/java/com/iluwatar/factory/method/OrcWeapon.java
@@ -1,5 +1,10 @@
package com.iluwatar.factory.method;
+/**
+ *
+ * OrcWeapon
+ *
+ */
public class OrcWeapon implements Weapon {
private WeaponType weaponType;
diff --git a/factory-method/src/main/java/com/iluwatar/factory/method/Weapon.java b/factory-method/src/main/java/com/iluwatar/factory/method/Weapon.java
index 80e7c911f..a5ae99254 100644
--- a/factory-method/src/main/java/com/iluwatar/factory/method/Weapon.java
+++ b/factory-method/src/main/java/com/iluwatar/factory/method/Weapon.java
@@ -1,5 +1,10 @@
package com.iluwatar.factory.method;
+/**
+ *
+ * Weapon interface
+ *
+ */
public interface Weapon {
}
diff --git a/factory-method/src/main/java/com/iluwatar/factory/method/WeaponType.java b/factory-method/src/main/java/com/iluwatar/factory/method/WeaponType.java
index 9ef82fff6..1c0341670 100644
--- a/factory-method/src/main/java/com/iluwatar/factory/method/WeaponType.java
+++ b/factory-method/src/main/java/com/iluwatar/factory/method/WeaponType.java
@@ -1,5 +1,10 @@
package com.iluwatar.factory.method;
+/**
+ *
+ * WeaponType enumeration
+ *
+ */
public enum WeaponType {
SHORT_SWORD("short sword"), SPEAR("spear"), AXE("axe"), UNDEFINED("");
diff --git a/factory-method/src/test/java/com/iluwatar/factory/method/AppTest.java b/factory-method/src/test/java/com/iluwatar/factory/method/AppTest.java
index 9fa0cc5eb..c6db18b3e 100644
--- a/factory-method/src/test/java/com/iluwatar/factory/method/AppTest.java
+++ b/factory-method/src/test/java/com/iluwatar/factory/method/AppTest.java
@@ -4,6 +4,11 @@ import org.junit.Test;
import com.iluwatar.factory.method.App;
+/**
+ *
+ * Application test
+ *
+ */
public class AppTest {
@Test
diff --git a/flux/src/main/java/com/iluwatar/flux/app/App.java b/flux/src/main/java/com/iluwatar/flux/app/App.java
index d0c7763e7..a567a92d3 100644
--- a/flux/src/main/java/com/iluwatar/flux/app/App.java
+++ b/flux/src/main/java/com/iluwatar/flux/app/App.java
@@ -13,18 +13,23 @@ import com.iluwatar.flux.view.MenuView;
* applications. Flux eschews MVC in favor of a unidirectional data flow. When a user interacts with
* a React view, the view propagates an action through a central dispatcher, to the various stores that
* hold the application's data and business logic, which updates all of the views that are affected.
- *
+ *
* This example has two views: menu and content. They represent typical main menu and content area of
* a web page. When menu item is clicked it triggers events through the dispatcher. The events are
* received and handled by the stores updating their data as needed. The stores then notify the views
* that they should rerender themselves.
- *
+ *
* http://facebook.github.io/flux/docs/overview.html
*
*/
public class App {
+ /**
+ * Program entry point
+ * @param args command line args
+ */
public static void main( String[] args ) {
+
// initialize and wire the system
MenuStore menuStore = new MenuStore();
Dispatcher.getInstance().registerStore(menuStore);
diff --git a/flux/src/test/java/com/iluwatar/flux/app/AppTest.java b/flux/src/test/java/com/iluwatar/flux/app/AppTest.java
index 902e5872e..ba4b592a1 100644
--- a/flux/src/test/java/com/iluwatar/flux/app/AppTest.java
+++ b/flux/src/test/java/com/iluwatar/flux/app/AppTest.java
@@ -4,6 +4,11 @@ import org.junit.Test;
import com.iluwatar.flux.app.App;
+/**
+ *
+ * Application test
+ *
+ */
public class AppTest {
@Test
diff --git a/flyweight/src/main/java/com/iluwatar/flyweight/App.java b/flyweight/src/main/java/com/iluwatar/flyweight/App.java
index 3aa41cf2c..c08ba78a3 100644
--- a/flyweight/src/main/java/com/iluwatar/flyweight/App.java
+++ b/flyweight/src/main/java/com/iluwatar/flyweight/App.java
@@ -4,18 +4,22 @@ package com.iluwatar.flyweight;
*
* Flyweight pattern is useful when the program needs a huge amount of objects.
* It provides means to decrease resource usage by sharing object instances.
- *
- * In this example AlchemistShop has great amount of potions on its shelves.
- * To fill the shelves AlchemistShop uses PotionFactory (which represents
- * the Flyweight in this example). Internally PotionFactory holds a map
+ *
+ * In this example {@link AlchemistShop} has great amount of potions on its shelves.
+ * To fill the shelves {@link AlchemistShop} uses {@link PotionFactory} (which represents
+ * the Flyweight in this example). Internally {@link PotionFactory} holds a map
* of the potions and lazily creates new ones when requested.
- *
+ *
* To enable safe sharing, between clients and threads, Flyweight objects must
* be immutable. Flyweight objects are by definition value objects.
*
*/
public class App {
+ /**
+ * Program entry point
+ * @param args command line args
+ */
public static void main(String[] args) {
AlchemistShop alchemistShop = new AlchemistShop();
alchemistShop.enumerate();
diff --git a/flyweight/src/main/java/com/iluwatar/flyweight/HealingPotion.java b/flyweight/src/main/java/com/iluwatar/flyweight/HealingPotion.java
index 397cca428..a5f8f4fb8 100644
--- a/flyweight/src/main/java/com/iluwatar/flyweight/HealingPotion.java
+++ b/flyweight/src/main/java/com/iluwatar/flyweight/HealingPotion.java
@@ -1,11 +1,16 @@
-package com.iluwatar.flyweight;
-
-public class HealingPotion implements Potion {
-
- @Override
- public void drink() {
- System.out.println("You feel healed. (Potion="
- + System.identityHashCode(this) + ")");
- }
-
-}
+package com.iluwatar.flyweight;
+
+/**
+ *
+ * HealingPotion
+ *
+ */
+public class HealingPotion implements Potion {
+
+ @Override
+ public void drink() {
+ System.out.println("You feel healed. (Potion="
+ + System.identityHashCode(this) + ")");
+ }
+
+}
diff --git a/flyweight/src/main/java/com/iluwatar/flyweight/HolyWaterPotion.java b/flyweight/src/main/java/com/iluwatar/flyweight/HolyWaterPotion.java
index df4c4009e..750e3c568 100644
--- a/flyweight/src/main/java/com/iluwatar/flyweight/HolyWaterPotion.java
+++ b/flyweight/src/main/java/com/iluwatar/flyweight/HolyWaterPotion.java
@@ -1,11 +1,16 @@
-package com.iluwatar.flyweight;
-
-public class HolyWaterPotion implements Potion {
-
- @Override
- public void drink() {
- System.out.println("You feel blessed. (Potion="
- + System.identityHashCode(this) + ")");
- }
-
-}
+package com.iluwatar.flyweight;
+
+/**
+ *
+ * HolyWaterPotion
+ *
+ */
+public class HolyWaterPotion implements Potion {
+
+ @Override
+ public void drink() {
+ System.out.println("You feel blessed. (Potion="
+ + System.identityHashCode(this) + ")");
+ }
+
+}
diff --git a/flyweight/src/main/java/com/iluwatar/flyweight/InvisibilityPotion.java b/flyweight/src/main/java/com/iluwatar/flyweight/InvisibilityPotion.java
index 2156b1017..db9d261d5 100644
--- a/flyweight/src/main/java/com/iluwatar/flyweight/InvisibilityPotion.java
+++ b/flyweight/src/main/java/com/iluwatar/flyweight/InvisibilityPotion.java
@@ -1,11 +1,16 @@
-package com.iluwatar.flyweight;
-
-public class InvisibilityPotion implements Potion {
-
- @Override
- public void drink() {
- System.out.println("You become invisible. (Potion="
- + System.identityHashCode(this) + ")");
- }
-
-}
+package com.iluwatar.flyweight;
+
+/**
+ *
+ * InvisibilityPotion
+ *
+ */
+public class InvisibilityPotion implements Potion {
+
+ @Override
+ public void drink() {
+ System.out.println("You become invisible. (Potion="
+ + System.identityHashCode(this) + ")");
+ }
+
+}
diff --git a/flyweight/src/main/java/com/iluwatar/flyweight/PoisonPotion.java b/flyweight/src/main/java/com/iluwatar/flyweight/PoisonPotion.java
index 2dcfab7d3..dfcd3c38d 100644
--- a/flyweight/src/main/java/com/iluwatar/flyweight/PoisonPotion.java
+++ b/flyweight/src/main/java/com/iluwatar/flyweight/PoisonPotion.java
@@ -1,11 +1,16 @@
-package com.iluwatar.flyweight;
-
-public class PoisonPotion implements Potion {
-
- @Override
- public void drink() {
- System.out.println("Urgh! This is poisonous. (Potion="
- + System.identityHashCode(this) + ")");
- }
-
-}
+package com.iluwatar.flyweight;
+
+/**
+ *
+ * PoisonPotion
+ *
+ */
+public class PoisonPotion implements Potion {
+
+ @Override
+ public void drink() {
+ System.out.println("Urgh! This is poisonous. (Potion="
+ + System.identityHashCode(this) + ")");
+ }
+
+}
diff --git a/flyweight/src/main/java/com/iluwatar/flyweight/StrengthPotion.java b/flyweight/src/main/java/com/iluwatar/flyweight/StrengthPotion.java
index a1ffcdc53..49083cf7c 100644
--- a/flyweight/src/main/java/com/iluwatar/flyweight/StrengthPotion.java
+++ b/flyweight/src/main/java/com/iluwatar/flyweight/StrengthPotion.java
@@ -1,10 +1,15 @@
-package com.iluwatar.flyweight;
-
-public class StrengthPotion implements Potion {
-
- @Override
- public void drink() {
- System.out.println("You feel strong. (Potion="
- + System.identityHashCode(this) + ")");
- }
-}
+package com.iluwatar.flyweight;
+
+/**
+ *
+ * StrengthPotion
+ *
+ */
+public class StrengthPotion implements Potion {
+
+ @Override
+ public void drink() {
+ System.out.println("You feel strong. (Potion="
+ + System.identityHashCode(this) + ")");
+ }
+}
diff --git a/flyweight/src/test/java/com/iluwatar/flyweight/AppTest.java b/flyweight/src/test/java/com/iluwatar/flyweight/AppTest.java
index 2c93d0e10..f3b033ba7 100644
--- a/flyweight/src/test/java/com/iluwatar/flyweight/AppTest.java
+++ b/flyweight/src/test/java/com/iluwatar/flyweight/AppTest.java
@@ -1,14 +1,19 @@
-package com.iluwatar.flyweight;
-
-import org.junit.Test;
-
-import com.iluwatar.flyweight.App;
-
-public class AppTest {
-
- @Test
- public void test() {
- String[] args = {};
- App.main(args);
- }
-}
+package com.iluwatar.flyweight;
+
+import org.junit.Test;
+
+import com.iluwatar.flyweight.App;
+
+/**
+ *
+ * Application test
+ *
+ */
+public class AppTest {
+
+ @Test
+ public void test() {
+ String[] args = {};
+ App.main(args);
+ }
+}
diff --git a/front-controller/src/main/java/com/iluwatar/front/controller/App.java b/front-controller/src/main/java/com/iluwatar/front/controller/App.java
index d17987823..18a92d37d 100644
--- a/front-controller/src/main/java/com/iluwatar/front/controller/App.java
+++ b/front-controller/src/main/java/com/iluwatar/front/controller/App.java
@@ -4,22 +4,26 @@ package com.iluwatar.front.controller;
*
* The Front Controller is a presentation tier pattern. Essentially it defines a
* controller that handles all requests for a web site.
- *
+ *
* The Front Controller pattern consolidates request handling through a single handler
- * object (FrontController). This object can carry out the common the behavior such as
+ * object ({@link FrontController}). This object can carry out the common the behavior such as
* authorization, request logging and routing requests to corresponding views.
- *
- * Typically the requests are mapped to command objects (Command) which then display
- * the correct view (View).
- *
- * In this example we have implemented two views: ArcherView and CatapultView. These
- * are displayed by sending correct request to the FrontController object. For example,
- * the ArcherView gets displayed when FrontController receives request "Archer". When
- * the request is unknown, we display the error view (ErrorView).
+ *
+ * Typically the requests are mapped to command objects ({@link Command}) which then display
+ * the correct view ({@link View}).
+ *
+ * In this example we have implemented two views: {@link ArcherView} and {@link CatapultView}. These
+ * are displayed by sending correct request to the {@link FrontController} object. For example,
+ * the {@link ArcherView} gets displayed when {@link FrontController} receives request "Archer". When
+ * the request is unknown, we display the error view ({@link ErrorView}).
*
*/
public class App {
+ /**
+ * Program entry point
+ * @param args command line args
+ */
public static void main(String[] args) {
FrontController controller = new FrontController();
controller.handleRequest("Archer");
diff --git a/front-controller/src/main/java/com/iluwatar/front/controller/ApplicationException.java b/front-controller/src/main/java/com/iluwatar/front/controller/ApplicationException.java
index 3a0191831..b3963d8e9 100644
--- a/front-controller/src/main/java/com/iluwatar/front/controller/ApplicationException.java
+++ b/front-controller/src/main/java/com/iluwatar/front/controller/ApplicationException.java
@@ -1,8 +1,15 @@
package com.iluwatar.front.controller;
+/**
+ *
+ * Custom exception type
+ *
+ */
public class ApplicationException extends RuntimeException {
- public ApplicationException(Throwable cause) {
+ private static final long serialVersionUID = 1L;
+
+ public ApplicationException(Throwable cause) {
super(cause);
}
}
diff --git a/front-controller/src/test/java/com/iluwatar/front/controller/AppTest.java b/front-controller/src/test/java/com/iluwatar/front/controller/AppTest.java
index 2c05cf9c4..2c28aa8ce 100644
--- a/front-controller/src/test/java/com/iluwatar/front/controller/AppTest.java
+++ b/front-controller/src/test/java/com/iluwatar/front/controller/AppTest.java
@@ -4,6 +4,11 @@ import org.junit.Test;
import com.iluwatar.front.controller.App;
+/**
+ *
+ * Application test
+ *
+ */
public class AppTest {
@Test
diff --git a/half-sync-half-async/src/main/java/com/iluwatar/halfsynchalfasync/App.java b/half-sync-half-async/src/main/java/com/iluwatar/halfsynchalfasync/App.java
index 77b1988ba..b8cec89e3 100644
--- a/half-sync-half-async/src/main/java/com/iluwatar/halfsynchalfasync/App.java
+++ b/half-sync-half-async/src/main/java/com/iluwatar/halfsynchalfasync/App.java
@@ -3,6 +3,7 @@ package com.iluwatar.halfsynchalfasync;
import java.util.concurrent.LinkedBlockingQueue;
/**
+ *
* This application demonstrates Half-Sync/Half-Async pattern. Key parts of the pattern are
* {@link AsyncTask} and {@link AsynchronousService}.
*
@@ -44,9 +45,14 @@ import java.util.concurrent.LinkedBlockingQueue;
* Such as Priority Queue can be used as queuing layer to prioritize the way tasks are executed.
* Our implementation is just one simple way of implementing this pattern, there are many variants possible
* as described in its applications.
+ *
*/
public class App {
+ /**
+ * Program entry point
+ * @param args command line args
+ */
public static void main(String[] args) {
AsynchronousService service = new AsynchronousService(new LinkedBlockingQueue<>());
/*
@@ -66,6 +72,11 @@ public class App {
service.execute(new ArithmeticSumTask(1));
}
+ /**
+ *
+ * ArithmeticSumTask
+ *
+ */
static class ArithmeticSumTask implements AsyncTask
+ * Expressions can be evaluated using prefix, infix or postfix notations
+ * This sample uses postfix, where operator comes after the operands
+ *
+ * @param args command line args
+ *
+ */
+ public static void main(String[] args) {
+ String tokenString = "4 3 2 - 1 + *";
+ Stack
* Layers is an architectural style where software responsibilities are
* divided among the different layers of the application.
- *
* This example demonstrates a traditional 3-layer architecture consisting of data access
* layer, business layer and presentation layer.
- *
* The data access layer is formed of Spring Data repositories
* The business layer is built on top of the data access layer.
* The presentation layer is built on the business layer and in this example it simply lists
* the cakes that have been baked.
- *
* We have applied so called strict layering which means that the layers can only access
* the classes directly beneath them. This leads the solution to create an additional set of
@@ -41,7 +30,6 @@ import java.util.Arrays;
* layer DTOs (
* This example shows different implementations of the pattern
* with increasing sophistication.
- *
+ *
* Additional information and lazy loading flavours are described in
* http://martinfowler.com/eaaCatalog/lazyLoad.html
*
*/
public class App
{
+ /**
+ * Program entry point
+ * @param args command line args
+ */
public static void main( String[] args ) {
// Simple lazy loader - not thread safe
diff --git a/lazy-loading/src/main/java/com/iluwatar/lazy/loading/Java8Holder.java b/lazy-loading/src/main/java/com/iluwatar/lazy/loading/Java8Holder.java
index 6bd2382c1..a03aae352 100644
--- a/lazy-loading/src/main/java/com/iluwatar/lazy/loading/Java8Holder.java
+++ b/lazy-loading/src/main/java/com/iluwatar/lazy/loading/Java8Holder.java
@@ -4,8 +4,8 @@ import java.util.function.Supplier;
/**
*
- * This lazy loader is thread safe and more efficient than HolderThreadSafe.
- * It utilizes Java 8 functional interface Supplier
* The central component of MVC, the model, captures the behavior of the application in terms of its problem
* domain, independent of the user interface. The model directly manages the data, logic and rules of the
* application. A view can be any output representation of information, such as a chart or a diagram
* The third part, the controller, accepts input and converts it to commands for the model or view.
- *
- * In this example we have a giant (GiantModel) with statuses for health, fatigue and nourishment. GiantView
- * can display the giant with its current status. GiantController receives input affecting the model and
+ *
+ * In this example we have a giant ({@link GiantModel}) with statuses for health, fatigue and nourishment. {@link GiantView}
+ * can display the giant with its current status. {@link GiantController} receives input affecting the model and
* delegates redrawing the giant to the view.
*
*/
public class App {
+ /**
+ * Program entry point
+ * @param args command line args
+ */
public static void main( String[] args ) {
// create model, view and controller
GiantModel giant = new GiantModel(Health.HEALTHY, Fatigue.ALERT, Nourishment.SATURATED);
diff --git a/model-view-controller/src/test/java/com/iluwatar/model/view/controller/AppTest.java b/model-view-controller/src/test/java/com/iluwatar/model/view/controller/AppTest.java
index b6e2f1bff..4bb31f6e6 100644
--- a/model-view-controller/src/test/java/com/iluwatar/model/view/controller/AppTest.java
+++ b/model-view-controller/src/test/java/com/iluwatar/model/view/controller/AppTest.java
@@ -4,6 +4,11 @@ import org.junit.Test;
import com.iluwatar.model.view.controller.App;
+/**
+ *
+ * Application test
+ *
+ */
public class AppTest {
@Test
diff --git a/model-view-presenter/src/main/java/com/iluwatar/model/view/presenter/MainApp.java b/model-view-presenter/src/main/java/com/iluwatar/model/view/presenter/App.java
similarity index 65%
rename from model-view-presenter/src/main/java/com/iluwatar/model/view/presenter/MainApp.java
rename to model-view-presenter/src/main/java/com/iluwatar/model/view/presenter/App.java
index 73da4f733..ac6ccf091 100644
--- a/model-view-presenter/src/main/java/com/iluwatar/model/view/presenter/MainApp.java
+++ b/model-view-presenter/src/main/java/com/iluwatar/model/view/presenter/App.java
@@ -4,19 +4,23 @@ package com.iluwatar.model.view.presenter;
*
* The Model-View-Presenter(MVP) architectural pattern, helps us achieve what is
* called "The separation of concerns" principle. This is accomplished
- * by separating the application's logic(Model), GUIs(View), and finally
- * the way that the user's actions update the application's logic(Presenter).
- *
- * In the following example, The FileLoader class represents the app's logic,
- * the FileSelectorJFrame is the GUI and the FileSelectorPresenter is
+ * by separating the application's logic (Model), GUIs (View), and finally
+ * the way that the user's actions update the application's logic (Presenter).
+ *
+ * In the following example, The {@link FileLoader} class represents the app's logic,
+ * the {@link FileSelectorJFrame} is the GUI and the {@link FileSelectorPresenter} is
* responsible to respond to users' actions.
- *
+ *
* Finally, please notice the wiring between the Presenter and the View
* and between the Presenter and the Model.
*
*/
-public class MainApp {
+public class App {
+ /**
+ * Program entry point
+ * @param args command line args
+ */
public static void main(String[] args) {
FileLoader loader = new FileLoader();
FileSelectorJFrame jFrame = new FileSelectorJFrame();
diff --git a/model-view-presenter/src/main/java/com/iluwatar/model/view/presenter/FileLoader.java b/model-view-presenter/src/main/java/com/iluwatar/model/view/presenter/FileLoader.java
index aef5bade9..96d843f83 100644
--- a/model-view-presenter/src/main/java/com/iluwatar/model/view/presenter/FileLoader.java
+++ b/model-view-presenter/src/main/java/com/iluwatar/model/view/presenter/FileLoader.java
@@ -7,7 +7,7 @@ import java.io.FileReader;
/**
* Every instance of this class represents the Model component in the
* Model-View-Presenter architectural pattern.
- *
+ *
* It is responsible for reading and loading the contents of a given file.
*/
public class FileLoader {
@@ -51,9 +51,7 @@ public class FileLoader {
/**
* Sets the path of the file to be loaded, to the given value.
- *
- * @param fileName
- * The path of the file to be loaded.
+ * @param fileName The path of the file to be loaded.
*/
public void setFileName(String fileName) {
this.fileName = fileName;
diff --git a/model-view-presenter/src/main/java/com/iluwatar/model/view/presenter/FileSelectorJFrame.java b/model-view-presenter/src/main/java/com/iluwatar/model/view/presenter/FileSelectorJFrame.java
index be3c253ed..f4d24f59f 100644
--- a/model-view-presenter/src/main/java/com/iluwatar/model/view/presenter/FileSelectorJFrame.java
+++ b/model-view-presenter/src/main/java/com/iluwatar/model/view/presenter/FileSelectorJFrame.java
@@ -14,7 +14,7 @@ import javax.swing.JTextArea;
import javax.swing.JTextField;
/**
- * This class is the GUI implementation of the View component In the
+ * This class is the GUI implementation of the View component in the
* Model-View-Presenter pattern.
*/
public class FileSelectorJFrame extends JFrame implements FileSelectorView,
diff --git a/model-view-presenter/src/main/java/com/iluwatar/model/view/presenter/FileSelectorPresenter.java b/model-view-presenter/src/main/java/com/iluwatar/model/view/presenter/FileSelectorPresenter.java
index a7842e932..7119d60bf 100644
--- a/model-view-presenter/src/main/java/com/iluwatar/model/view/presenter/FileSelectorPresenter.java
+++ b/model-view-presenter/src/main/java/com/iluwatar/model/view/presenter/FileSelectorPresenter.java
@@ -3,7 +3,7 @@ package com.iluwatar.model.view.presenter;
/**
* Every instance of this class represents the Presenter component in the
* Model-View-Presenter architectural pattern.
- *
+ *
* It is responsible for reacting to the user's actions and update the View
* component.
*/
@@ -21,19 +21,15 @@ public class FileSelectorPresenter {
/**
* Constructor
- *
- * @param view
- * The view component that the presenter will interact with.
+ * @param view The view component that the presenter will interact with.
*/
public FileSelectorPresenter(FileSelectorView view) {
this.view = view;
}
/**
- * Sets the FileLoader object, to the value given as parameter.
- *
- * @param loader
- * The new FileLoader object(the Model component).
+ * Sets the {@link FileLoader} object, to the value given as parameter.
+ * @param loader The new {@link FileLoader} object(the Model component).
*/
public void setLoader(FileLoader loader) {
this.loader = loader;
diff --git a/model-view-presenter/src/main/java/com/iluwatar/model/view/presenter/FileSelectorStub.java b/model-view-presenter/src/main/java/com/iluwatar/model/view/presenter/FileSelectorStub.java
index 7aa88e922..d0cec4c40 100644
--- a/model-view-presenter/src/main/java/com/iluwatar/model/view/presenter/FileSelectorStub.java
+++ b/model-view-presenter/src/main/java/com/iluwatar/model/view/presenter/FileSelectorStub.java
@@ -3,10 +3,10 @@ package com.iluwatar.model.view.presenter;
/**
* Every instance of this class represents the Stub component in the
* Model-View-Presenter architectural pattern.
- *
+ *
* The stub implements the View interface and it is useful when we want the test
* the reaction to user events, such as mouse clicks.
- *
+ *
* Since we can not test the GUI directly, the MVP pattern provides this
* functionality through the View's dummy implementation, the Stub.
*/
diff --git a/model-view-presenter/src/main/java/com/iluwatar/model/view/presenter/FileSelectorView.java b/model-view-presenter/src/main/java/com/iluwatar/model/view/presenter/FileSelectorView.java
index e4a7efaee..8cd265f9b 100644
--- a/model-view-presenter/src/main/java/com/iluwatar/model/view/presenter/FileSelectorView.java
+++ b/model-view-presenter/src/main/java/com/iluwatar/model/view/presenter/FileSelectorView.java
@@ -23,9 +23,7 @@ public interface FileSelectorView {
/**
* Sets the presenter component, to the one given as parameter.
- *
- * @param presenter
- * The new presenter component.
+ * @param presenter The new presenter component.
*/
public void setPresenter(FileSelectorPresenter presenter);
@@ -36,9 +34,7 @@ public interface FileSelectorView {
/**
* Sets the file's name, to the value given as parameter.
- *
- * @param name
- * The new name of the file.
+ * @param name The new name of the file.
*/
public void setFileName(String name);
@@ -49,17 +45,13 @@ public interface FileSelectorView {
/**
* Displays a message to the users.
- *
- * @param message
- * The message to be displayed.
+ * @param message The message to be displayed.
*/
public void showMessage(String message);
/**
* Displays the data to the view.
- *
- * @param data
- * The data to be written.
+ * @param data The data to be written.
*/
public void displayData(String data);
}
diff --git a/multiton/src/main/java/com/iluwatar/multiton/App.java b/multiton/src/main/java/com/iluwatar/multiton/App.java
index 7e3da2123..9f2c5da78 100644
--- a/multiton/src/main/java/com/iluwatar/multiton/App.java
+++ b/multiton/src/main/java/com/iluwatar/multiton/App.java
@@ -6,14 +6,18 @@ package com.iluwatar.multiton;
* accessible object the Multiton pattern defines many globally
* accessible objects. The client asks for the correct instance
* from the Multiton by passing an enumeration as parameter.
- *
- * In this example Nazgul is the Multiton and we can ask single
- * Nazgul from it using NazgulName. The Nazguls are statically
+ *
+ * In this example {@link Nazgul} is the Multiton and we can ask single
+ * {@link Nazgul} from it using {@link NazgulName}. The {@link Nazgul}s are statically
* initialized and stored in concurrent hash map.
*
*/
public class App {
+ /**
+ * Program entry point
+ * @param args command line args
+ */
public static void main( String[] args ) {
System.out.println("KHAMUL=" + Nazgul.getInstance(NazgulName.KHAMUL));
System.out.println("MURAZOR=" + Nazgul.getInstance(NazgulName.MURAZOR));
diff --git a/multiton/src/main/java/com/iluwatar/multiton/Nazgul.java b/multiton/src/main/java/com/iluwatar/multiton/Nazgul.java
index a099f9322..833923f75 100644
--- a/multiton/src/main/java/com/iluwatar/multiton/Nazgul.java
+++ b/multiton/src/main/java/com/iluwatar/multiton/Nazgul.java
@@ -6,7 +6,7 @@ import java.util.concurrent.ConcurrentHashMap;
/**
*
* Nazgul is a Multiton class. Nazgul instances can be queried
- * using getInstance() method.
+ * using {@link #getInstance} method.
*
*/
public class Nazgul {
diff --git a/multiton/src/main/java/com/iluwatar/multiton/NazgulName.java b/multiton/src/main/java/com/iluwatar/multiton/NazgulName.java
index f0db192a4..cef1e43a9 100644
--- a/multiton/src/main/java/com/iluwatar/multiton/NazgulName.java
+++ b/multiton/src/main/java/com/iluwatar/multiton/NazgulName.java
@@ -2,7 +2,7 @@ package com.iluwatar.multiton;
/**
*
- * Each Nazgul has different NazgulName.
+ * Each Nazgul has different {@link NazgulName}.
*
*/
public enum NazgulName {
diff --git a/multiton/src/test/java/com/iluwatar/multiton/AppTest.java b/multiton/src/test/java/com/iluwatar/multiton/AppTest.java
index 9f5f96792..439f08e24 100644
--- a/multiton/src/test/java/com/iluwatar/multiton/AppTest.java
+++ b/multiton/src/test/java/com/iluwatar/multiton/AppTest.java
@@ -4,6 +4,11 @@ import org.junit.Test;
import com.iluwatar.multiton.App;
+/**
+ *
+ * Application test
+ *
+ */
public class AppTest {
@Test
diff --git a/null-object/src/main/java/com/iluwatar/nullobject/App.java b/null-object/src/main/java/com/iluwatar/nullobject/App.java
index 35b05061e..9cc4a14da 100644
--- a/null-object/src/main/java/com/iluwatar/nullobject/App.java
+++ b/null-object/src/main/java/com/iluwatar/nullobject/App.java
@@ -5,7 +5,7 @@ package com.iluwatar.nullobject;
* Null Object pattern replaces null values with neutral objects.
* Many times this simplifies algorithms since no extra null checks
* are needed.
- *
+ *
* In this example we build a binary tree where the nodes are either
* normal or Null Objects. No null values are used in the tree making
* the traversal easy.
@@ -13,6 +13,10 @@ package com.iluwatar.nullobject;
*/
public class App
{
+ /**
+ * Program entry point
+ * @param args command line args
+ */
public static void main( String[] args ) {
Node root = new NodeImpl("1",
diff --git a/null-object/src/main/java/com/iluwatar/nullobject/NullNode.java b/null-object/src/main/java/com/iluwatar/nullobject/NullNode.java
index dfa6963d0..4a0f4cd2b 100644
--- a/null-object/src/main/java/com/iluwatar/nullobject/NullNode.java
+++ b/null-object/src/main/java/com/iluwatar/nullobject/NullNode.java
@@ -3,7 +3,7 @@ package com.iluwatar.nullobject;
/**
*
* Null Object implementation for binary tree node.
- *
+ *
* Implemented as Singleton, since all the NullNodes are the same.
*
*/
diff --git a/null-object/src/test/java/com/iluwatar/nullobject/AppTest.java b/null-object/src/test/java/com/iluwatar/nullobject/AppTest.java
index eb12f3c4d..7ddf2cabc 100644
--- a/null-object/src/test/java/com/iluwatar/nullobject/AppTest.java
+++ b/null-object/src/test/java/com/iluwatar/nullobject/AppTest.java
@@ -4,6 +4,11 @@ import org.junit.Test;
import com.iluwatar.nullobject.App;
+/**
+ *
+ * Application test
+ *
+ */
public class AppTest {
@Test
diff --git a/object-pool/src/main/java/com/iluwatar/object/pool/App.java b/object-pool/src/main/java/com/iluwatar/object/pool/App.java
index d47bc51be..c1893a774 100644
--- a/object-pool/src/main/java/com/iluwatar/object/pool/App.java
+++ b/object-pool/src/main/java/com/iluwatar/object/pool/App.java
@@ -5,21 +5,25 @@ package com.iluwatar.object.pool;
* When it is necessary to work with a large number of objects that are particularly expensive to instantiate
* and each object is only needed for a short period of time, the performance of an entire application may be
* adversely affected. An object pool design pattern may be deemed desirable in cases such as these.
- *
+ *
* The object pool design pattern creates a set of objects that may be reused. When a new object is needed, it
* is requested from the pool. If a previously prepared object is available it is returned immediately, avoiding
* the instantiation cost. If no objects are present in the pool, a new item is created and returned. When the
* object has been used and is no longer needed, it is returned to the pool, allowing it to be used again in the
* future without repeating the computationally expensive instantiation process. It is important to note that
* once an object has been used and returned, existing references will become invalid.
- *
- * In this example we have created OliphauntPool inheriting from generic ObjectPool. Oliphaunts can be checked
+ *
+ * In this example we have created {@link OliphauntPool} inheriting from generic {@link ObjectPool}. {@link Oliphaunt}s can be checked
* out from the pool and later returned to it. The pool tracks created instances and their status (available,
* inUse).
*
*/
public class App {
+ /**
+ * Program entry point
+ * @param args command line args
+ */
public static void main( String[] args ) {
OliphauntPool pool = new OliphauntPool();
System.out.println(pool);
diff --git a/object-pool/src/test/java/com/iluwatar/object/pool/AppTest.java b/object-pool/src/test/java/com/iluwatar/object/pool/AppTest.java
index c856141db..4114590ec 100644
--- a/object-pool/src/test/java/com/iluwatar/object/pool/AppTest.java
+++ b/object-pool/src/test/java/com/iluwatar/object/pool/AppTest.java
@@ -4,6 +4,11 @@ import org.junit.Test;
import com.iluwatar.object.pool.App;
+/**
+ *
+ * Application test
+ *
+ */
public class AppTest {
@Test
diff --git a/observer/src/main/java/com/iluwatar/observer/App.java b/observer/src/main/java/com/iluwatar/observer/App.java
index 9d97084c8..bd99da841 100644
--- a/observer/src/main/java/com/iluwatar/observer/App.java
+++ b/observer/src/main/java/com/iluwatar/observer/App.java
@@ -1,38 +1,41 @@
-package com.iluwatar.observer;
-
-import com.iluwatar.observer.generic.GHobbits;
-import com.iluwatar.observer.generic.GOrcs;
-import com.iluwatar.observer.generic.GWeather;
-
-/**
- *
- * Observer pattern defines one-to-many relationship between objects. The target
- * object sends change notifications to its registered observers.
- *
- */
-public class App {
-
- public static void main(String[] args) {
-
- Weather weather = new Weather();
- weather.addObserver(new Orcs());
- weather.addObserver(new Hobbits());
-
- weather.timePasses();
- weather.timePasses();
- weather.timePasses();
- weather.timePasses();
-
- // Generic observer inspired by Java Generics and Collection by Naftalin & Wadler
- System.out.println("\n--Running generic version--");
- GWeather gWeather = new GWeather();
- gWeather.addObserver(new GOrcs());
- gWeather.addObserver(new GHobbits());
-
- gWeather.timePasses();
- gWeather.timePasses();
- gWeather.timePasses();
- gWeather.timePasses();
-
- }
-}
+package com.iluwatar.observer;
+
+import com.iluwatar.observer.generic.GHobbits;
+import com.iluwatar.observer.generic.GOrcs;
+import com.iluwatar.observer.generic.GWeather;
+
+/**
+ *
+ * Observer pattern defines one-to-many relationship between objects. The target
+ * object sends change notifications to its registered observers.
+ *
+ */
+public class App {
+
+ /**
+ * Program entry point
+ * @param args command line args
+ */
+ public static void main(String[] args) {
+
+ Weather weather = new Weather();
+ weather.addObserver(new Orcs());
+ weather.addObserver(new Hobbits());
+
+ weather.timePasses();
+ weather.timePasses();
+ weather.timePasses();
+ weather.timePasses();
+
+ // Generic observer inspired by Java Generics and Collection by Naftalin & Wadler
+ System.out.println("\n--Running generic version--");
+ GWeather gWeather = new GWeather();
+ gWeather.addObserver(new GOrcs());
+ gWeather.addObserver(new GHobbits());
+
+ gWeather.timePasses();
+ gWeather.timePasses();
+ gWeather.timePasses();
+ gWeather.timePasses();
+ }
+}
diff --git a/observer/src/main/java/com/iluwatar/observer/Hobbits.java b/observer/src/main/java/com/iluwatar/observer/Hobbits.java
index b8a4f5b4f..d15ce6109 100644
--- a/observer/src/main/java/com/iluwatar/observer/Hobbits.java
+++ b/observer/src/main/java/com/iluwatar/observer/Hobbits.java
@@ -1,25 +1,30 @@
-package com.iluwatar.observer;
-
-public class Hobbits implements WeatherObserver {
-
- @Override
- public void update(WeatherType currentWeather) {
- switch (currentWeather) {
- case COLD:
- System.out.println("The hobbits are shivering in the cold weather.");
- break;
- case RAINY:
- System.out.println("The hobbits look for cover from the rain.");
- break;
- case SUNNY:
- System.out.println("The happy hobbits bade in the warm sun.");
- break;
- case WINDY:
- System.out.println("The hobbits hold their hats tightly in the windy weather.");
- break;
- default:
- break;
- }
- }
-
-}
+package com.iluwatar.observer;
+
+/**
+ *
+ * Hobbits
+ *
+ */
+public class Hobbits implements WeatherObserver {
+
+ @Override
+ public void update(WeatherType currentWeather) {
+ switch (currentWeather) {
+ case COLD:
+ System.out.println("The hobbits are shivering in the cold weather.");
+ break;
+ case RAINY:
+ System.out.println("The hobbits look for cover from the rain.");
+ break;
+ case SUNNY:
+ System.out.println("The happy hobbits bade in the warm sun.");
+ break;
+ case WINDY:
+ System.out.println("The hobbits hold their hats tightly in the windy weather.");
+ break;
+ default:
+ break;
+ }
+ }
+
+}
diff --git a/observer/src/main/java/com/iluwatar/observer/Orcs.java b/observer/src/main/java/com/iluwatar/observer/Orcs.java
index 0e51ab450..26049bf4b 100644
--- a/observer/src/main/java/com/iluwatar/observer/Orcs.java
+++ b/observer/src/main/java/com/iluwatar/observer/Orcs.java
@@ -1,25 +1,30 @@
-package com.iluwatar.observer;
-
-public class Orcs implements WeatherObserver {
-
- @Override
- public void update(WeatherType currentWeather) {
- switch (currentWeather) {
- case COLD:
- System.out.println("The orcs are freezing cold.");
- break;
- case RAINY:
- System.out.println("The orcs are dripping wet.");
- break;
- case SUNNY:
- System.out.println("The sun hurts the orcs' eyes.");
- break;
- case WINDY:
- System.out.println("The orc smell almost vanishes in the wind.");
- break;
- default:
- break;
- }
- }
-
-}
+package com.iluwatar.observer;
+
+/**
+ *
+ * Orcs
+ *
+ */
+public class Orcs implements WeatherObserver {
+
+ @Override
+ public void update(WeatherType currentWeather) {
+ switch (currentWeather) {
+ case COLD:
+ System.out.println("The orcs are freezing cold.");
+ break;
+ case RAINY:
+ System.out.println("The orcs are dripping wet.");
+ break;
+ case SUNNY:
+ System.out.println("The sun hurts the orcs' eyes.");
+ break;
+ case WINDY:
+ System.out.println("The orc smell almost vanishes in the wind.");
+ break;
+ default:
+ break;
+ }
+ }
+
+}
diff --git a/observer/src/main/java/com/iluwatar/observer/Weather.java b/observer/src/main/java/com/iluwatar/observer/Weather.java
index 32ff13d03..c5b03c7a3 100644
--- a/observer/src/main/java/com/iluwatar/observer/Weather.java
+++ b/observer/src/main/java/com/iluwatar/observer/Weather.java
@@ -1,42 +1,42 @@
-package com.iluwatar.observer;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- *
- * Weather can be observed by implementing WeatherObserver interface and
- * registering as listener.
- *
- */
-public class Weather {
-
- private WeatherType currentWeather;
- private List
+ * In simple cases as Poison Pill can be used just null-reference, but holding unique separate shared
+ * object-marker (with name "Poison" or "Poison Pill") is more clear and self describing.
+ *
*/
public class App {
+ /**
+ * Program entry point
+ * @param args command line args
+ */
public static void main(String[] args) {
MessageQueue queue = new SimpleMessageQueue(10000);
diff --git a/poison-pill/src/main/java/com/iluwatar/poison/pill/Message.java b/poison-pill/src/main/java/com/iluwatar/poison/pill/Message.java
index f306e0385..8e167790f 100644
--- a/poison-pill/src/main/java/com/iluwatar/poison/pill/Message.java
+++ b/poison-pill/src/main/java/com/iluwatar/poison/pill/Message.java
@@ -3,7 +3,8 @@ package com.iluwatar.poison.pill;
import java.util.Map;
/**
- * Interface that implements the Message pattern and represents an inbound or outbound message as part of an {@link Producer}-{@link Consumer} exchange.
+ * Interface that implements the Message pattern and represents an inbound or outbound
+ * message as part of an {@link Producer}-{@link Consumer} exchange.
*/
public interface Message {
diff --git a/poison-pill/src/test/java/com/iluwatar/poison/pill/AppTest.java b/poison-pill/src/test/java/com/iluwatar/poison/pill/AppTest.java
index 625d849a2..0730e5b10 100644
--- a/poison-pill/src/test/java/com/iluwatar/poison/pill/AppTest.java
+++ b/poison-pill/src/test/java/com/iluwatar/poison/pill/AppTest.java
@@ -4,6 +4,11 @@ import org.junit.Test;
import com.iluwatar.poison.pill.App;
+/**
+ *
+ * Application test
+ *
+ */
public class AppTest {
@Test
diff --git a/private-class-data/src/main/java/com/iluwatar/privateclassdata/App.java b/private-class-data/src/main/java/com/iluwatar/privateclassdata/App.java
index 8cc5254d6..a4e2ffa87 100644
--- a/private-class-data/src/main/java/com/iluwatar/privateclassdata/App.java
+++ b/private-class-data/src/main/java/com/iluwatar/privateclassdata/App.java
@@ -1,34 +1,38 @@
-package com.iluwatar.privateclassdata;
-
-/**
- *
- * The Private Class Data design pattern seeks to reduce exposure of attributes
- * by limiting their visibility. It reduces the number of class attributes by
- * encapsulating them in single data object. It allows the class designer to
- * remove write privilege of attributes that are intended to be set only during
- * construction, even from methods of the target class.
- *
- * In the example we have normal Stew class with some ingredients given in
- * constructor. Then we have methods to enumerate the ingredients and to taste
- * the stew. The method for tasting the stew alters the private members of the
- * stew class.
- *
- * The problem is solved with the Private Class Data pattern. We introduce
- * ImmutableStew class that contains StewData. The private data members of
- * Stew are now in StewData and cannot be altered by ImmutableStew methods.
- *
- */
-public class App {
-
- public static void main( String[] args ) {
- // stew is mutable
- Stew stew = new Stew(1, 2, 3, 4);
- stew.mix();
- stew.taste();
- stew.mix();
-
- // immutable stew protected with Private Class Data pattern
- ImmutableStew immutableStew = new ImmutableStew(2, 4, 3, 6);
- immutableStew.mix();
- }
-}
+package com.iluwatar.privateclassdata;
+
+/**
+ *
+ * The Private Class Data design pattern seeks to reduce exposure of attributes
+ * by limiting their visibility. It reduces the number of class attributes by
+ * encapsulating them in single data object. It allows the class designer to
+ * remove write privilege of attributes that are intended to be set only during
+ * construction, even from methods of the target class.
+ *
+ * In the example we have normal {@link Stew} class with some ingredients given in
+ * constructor. Then we have methods to enumerate the ingredients and to taste
+ * the stew. The method for tasting the stew alters the private members of the
+ * {@link Stew} class.
+ *
+ * The problem is solved with the Private Class Data pattern. We introduce
+ * {@link ImmutableStew} class that contains {@link StewData}. The private data members of
+ * {@link Stew} are now in {@link StewData} and cannot be altered by {@link ImmutableStew} methods.
+ *
+ */
+public class App {
+
+ /**
+ * Program entry point
+ * @param args command line args
+ */
+ public static void main( String[] args ) {
+ // stew is mutable
+ Stew stew = new Stew(1, 2, 3, 4);
+ stew.mix();
+ stew.taste();
+ stew.mix();
+
+ // immutable stew protected with Private Class Data pattern
+ ImmutableStew immutableStew = new ImmutableStew(2, 4, 3, 6);
+ immutableStew.mix();
+ }
+}
diff --git a/private-class-data/src/test/java/com/iluwatar/privateclassdata/AppTest.java b/private-class-data/src/test/java/com/iluwatar/privateclassdata/AppTest.java
index 8ba8c4b80..92fc9b46a 100644
--- a/private-class-data/src/test/java/com/iluwatar/privateclassdata/AppTest.java
+++ b/private-class-data/src/test/java/com/iluwatar/privateclassdata/AppTest.java
@@ -1,14 +1,19 @@
-package com.iluwatar.privateclassdata;
-
-import org.junit.Test;
-
-import com.iluwatar.privateclassdata.App;
-
-public class AppTest {
-
- @Test
- public void test() {
- String[] args = {};
- App.main(args);
- }
-}
+package com.iluwatar.privateclassdata;
+
+import org.junit.Test;
+
+import com.iluwatar.privateclassdata.App;
+
+/**
+ *
+ * Application test
+ *
+ */
+public class AppTest {
+
+ @Test
+ public void test() {
+ String[] args = {};
+ App.main(args);
+ }
+}
diff --git a/property/src/main/java/com/iluwatar/property/App.java b/property/src/main/java/com/iluwatar/property/App.java
index 40972ab59..54c140574 100644
--- a/property/src/main/java/com/iluwatar/property/App.java
+++ b/property/src/main/java/com/iluwatar/property/App.java
@@ -3,14 +3,21 @@ package com.iluwatar.property;
import com.iluwatar.property.Character.Type;
/**
- * Example of Character instantiation using Property pattern (as concept also known like Prototype inheritance).
+ *
+ * Example of {@link Character} instantiation using the Property pattern (also known as Prototype inheritance).
+ *
* In prototype inheritance instead of classes, as opposite to Java class inheritance,
- * objects are used to create another objects and object hierarchies.
- * Hierarchies are created using prototype chain through delegation: every object has link to parent object.
- * Any base (parent) object can be amended at runtime (by adding or removal of some property), and all child objects will be affected as result.
+ * objects are used to create another objects and object hierarchies. Hierarchies are created using prototype chain
+ * through delegation: every object has link to parent object. Any base (parent) object can be amended at runtime
+ * (by adding or removal of some property), and all child objects will be affected as result.
+ *
*/
public class App {
+ /**
+ * Program entry point
+ * @param args command line args
+ */
public static void main(String[] args) {
/* set up */
Prototype charProto = new Character();
diff --git a/property/src/test/java/com/iluwatar/property/AppTest.java b/property/src/test/java/com/iluwatar/property/AppTest.java
index dc05049f8..1e8078352 100644
--- a/property/src/test/java/com/iluwatar/property/AppTest.java
+++ b/property/src/test/java/com/iluwatar/property/AppTest.java
@@ -4,6 +4,11 @@ import org.junit.Test;
import com.iluwatar.property.App;
+/**
+ *
+ * Application test
+ *
+ */
public class AppTest {
@Test
diff --git a/prototype/src/main/java/com/iluwatar/prototype/App.java b/prototype/src/main/java/com/iluwatar/prototype/App.java
index b10de963b..4003862cb 100644
--- a/prototype/src/main/java/com/iluwatar/prototype/App.java
+++ b/prototype/src/main/java/com/iluwatar/prototype/App.java
@@ -1,36 +1,40 @@
-package com.iluwatar.prototype;
-
-/**
- *
- * In Prototype we have a factory class (HeroFactoryImpl) producing objects by
- * cloning existing ones. In this example the factory's prototype objects are
- * given as constructor parameters.
- *
- */
-public class App {
-
- public static void main(String[] args) {
- HeroFactory factory;
- Mage mage;
- Warlord warlord;
- Beast beast;
-
- factory = new HeroFactoryImpl(new ElfMage(), new ElfWarlord(),
- new ElfBeast());
- mage = factory.createMage();
- warlord = factory.createWarlord();
- beast = factory.createBeast();
- System.out.println(mage);
- System.out.println(warlord);
- System.out.println(beast);
-
- factory = new HeroFactoryImpl(new OrcMage(), new OrcWarlord(),
- new OrcBeast());
- mage = factory.createMage();
- warlord = factory.createWarlord();
- beast = factory.createBeast();
- System.out.println(mage);
- System.out.println(warlord);
- System.out.println(beast);
- }
-}
+package com.iluwatar.prototype;
+
+/**
+ *
+ * In Prototype we have a factory class ({@link HeroFactoryImpl}) producing objects by
+ * cloning the existing ones. In this example the factory's prototype objects are
+ * given as constructor parameters.
+ *
+ */
+public class App {
+
+ /**
+ * Program entry point
+ * @param args command line args
+ */
+ public static void main(String[] args) {
+ HeroFactory factory;
+ Mage mage;
+ Warlord warlord;
+ Beast beast;
+
+ factory = new HeroFactoryImpl(new ElfMage(), new ElfWarlord(),
+ new ElfBeast());
+ mage = factory.createMage();
+ warlord = factory.createWarlord();
+ beast = factory.createBeast();
+ System.out.println(mage);
+ System.out.println(warlord);
+ System.out.println(beast);
+
+ factory = new HeroFactoryImpl(new OrcMage(), new OrcWarlord(),
+ new OrcBeast());
+ mage = factory.createMage();
+ warlord = factory.createWarlord();
+ beast = factory.createBeast();
+ System.out.println(mage);
+ System.out.println(warlord);
+ System.out.println(beast);
+ }
+}
diff --git a/prototype/src/main/java/com/iluwatar/prototype/Beast.java b/prototype/src/main/java/com/iluwatar/prototype/Beast.java
index 96cbfb2c8..028fa11b8 100644
--- a/prototype/src/main/java/com/iluwatar/prototype/Beast.java
+++ b/prototype/src/main/java/com/iluwatar/prototype/Beast.java
@@ -1,8 +1,13 @@
-package com.iluwatar.prototype;
-
-public abstract class Beast extends Prototype {
-
- @Override
- public abstract Beast clone() throws CloneNotSupportedException;
-
-}
+package com.iluwatar.prototype;
+
+/**
+ *
+ * Beast
+ *
+ */
+public abstract class Beast extends Prototype {
+
+ @Override
+ public abstract Beast clone() throws CloneNotSupportedException;
+
+}
diff --git a/prototype/src/main/java/com/iluwatar/prototype/ElfBeast.java b/prototype/src/main/java/com/iluwatar/prototype/ElfBeast.java
index 17ac87511..b2b517207 100644
--- a/prototype/src/main/java/com/iluwatar/prototype/ElfBeast.java
+++ b/prototype/src/main/java/com/iluwatar/prototype/ElfBeast.java
@@ -1,21 +1,26 @@
-package com.iluwatar.prototype;
-
-public class ElfBeast extends Beast {
-
- public ElfBeast() {
- }
-
- public ElfBeast(ElfBeast beast) {
- }
-
- @Override
- public Beast clone() throws CloneNotSupportedException {
- return new ElfBeast(this);
- }
-
- @Override
- public String toString() {
- return "Elven eagle";
- }
-
-}
+package com.iluwatar.prototype;
+
+/**
+ *
+ * ElfBeast
+ *
+ */
+public class ElfBeast extends Beast {
+
+ public ElfBeast() {
+ }
+
+ public ElfBeast(ElfBeast beast) {
+ }
+
+ @Override
+ public Beast clone() throws CloneNotSupportedException {
+ return new ElfBeast(this);
+ }
+
+ @Override
+ public String toString() {
+ return "Elven eagle";
+ }
+
+}
diff --git a/prototype/src/main/java/com/iluwatar/prototype/ElfMage.java b/prototype/src/main/java/com/iluwatar/prototype/ElfMage.java
index c41ce2dd6..b502350c3 100644
--- a/prototype/src/main/java/com/iluwatar/prototype/ElfMage.java
+++ b/prototype/src/main/java/com/iluwatar/prototype/ElfMage.java
@@ -1,21 +1,26 @@
-package com.iluwatar.prototype;
-
-public class ElfMage extends Mage {
-
- public ElfMage() {
- }
-
- public ElfMage(ElfMage mage) {
- }
-
- @Override
- public Mage clone() throws CloneNotSupportedException {
- return new ElfMage(this);
- }
-
- @Override
- public String toString() {
- return "Elven mage";
- }
-
-}
+package com.iluwatar.prototype;
+
+/**
+ *
+ * ElfMage
+ *
+ */
+public class ElfMage extends Mage {
+
+ public ElfMage() {
+ }
+
+ public ElfMage(ElfMage mage) {
+ }
+
+ @Override
+ public Mage clone() throws CloneNotSupportedException {
+ return new ElfMage(this);
+ }
+
+ @Override
+ public String toString() {
+ return "Elven mage";
+ }
+
+}
diff --git a/prototype/src/main/java/com/iluwatar/prototype/ElfWarlord.java b/prototype/src/main/java/com/iluwatar/prototype/ElfWarlord.java
index 465c1d046..7f5829797 100644
--- a/prototype/src/main/java/com/iluwatar/prototype/ElfWarlord.java
+++ b/prototype/src/main/java/com/iluwatar/prototype/ElfWarlord.java
@@ -1,21 +1,26 @@
-package com.iluwatar.prototype;
-
-public class ElfWarlord extends Warlord {
-
- public ElfWarlord() {
- }
-
- public ElfWarlord(ElfWarlord warlord) {
- }
-
- @Override
- public Warlord clone() throws CloneNotSupportedException {
- return new ElfWarlord(this);
- }
-
- @Override
- public String toString() {
- return "Elven warlord";
- }
-
-}
+package com.iluwatar.prototype;
+
+/**
+ *
+ * ElfWarlord
+ *
+ */
+public class ElfWarlord extends Warlord {
+
+ public ElfWarlord() {
+ }
+
+ public ElfWarlord(ElfWarlord warlord) {
+ }
+
+ @Override
+ public Warlord clone() throws CloneNotSupportedException {
+ return new ElfWarlord(this);
+ }
+
+ @Override
+ public String toString() {
+ return "Elven warlord";
+ }
+
+}
diff --git a/prototype/src/main/java/com/iluwatar/prototype/Mage.java b/prototype/src/main/java/com/iluwatar/prototype/Mage.java
index 99cee8893..7ba192487 100644
--- a/prototype/src/main/java/com/iluwatar/prototype/Mage.java
+++ b/prototype/src/main/java/com/iluwatar/prototype/Mage.java
@@ -1,8 +1,13 @@
-package com.iluwatar.prototype;
-
-public abstract class Mage extends Prototype {
-
- @Override
- public abstract Mage clone() throws CloneNotSupportedException;
-
-}
+package com.iluwatar.prototype;
+
+/**
+ *
+ * Mage
+ *
+ */
+public abstract class Mage extends Prototype {
+
+ @Override
+ public abstract Mage clone() throws CloneNotSupportedException;
+
+}
diff --git a/prototype/src/main/java/com/iluwatar/prototype/OrcBeast.java b/prototype/src/main/java/com/iluwatar/prototype/OrcBeast.java
index bae7d360e..2af2fefa9 100644
--- a/prototype/src/main/java/com/iluwatar/prototype/OrcBeast.java
+++ b/prototype/src/main/java/com/iluwatar/prototype/OrcBeast.java
@@ -1,21 +1,26 @@
-package com.iluwatar.prototype;
-
-public class OrcBeast extends Beast {
-
- public OrcBeast() {
- }
-
- public OrcBeast(OrcBeast beast) {
- }
-
- @Override
- public Beast clone() throws CloneNotSupportedException {
- return new OrcBeast(this);
- }
-
- @Override
- public String toString() {
- return "Orcish wolf";
- }
-
-}
+package com.iluwatar.prototype;
+
+/**
+ *
+ * OrcBeast
+ *
+ */
+public class OrcBeast extends Beast {
+
+ public OrcBeast() {
+ }
+
+ public OrcBeast(OrcBeast beast) {
+ }
+
+ @Override
+ public Beast clone() throws CloneNotSupportedException {
+ return new OrcBeast(this);
+ }
+
+ @Override
+ public String toString() {
+ return "Orcish wolf";
+ }
+
+}
diff --git a/prototype/src/main/java/com/iluwatar/prototype/OrcMage.java b/prototype/src/main/java/com/iluwatar/prototype/OrcMage.java
index a329ca61b..1f52a25d9 100644
--- a/prototype/src/main/java/com/iluwatar/prototype/OrcMage.java
+++ b/prototype/src/main/java/com/iluwatar/prototype/OrcMage.java
@@ -1,21 +1,26 @@
-package com.iluwatar.prototype;
-
-public class OrcMage extends Mage {
-
- public OrcMage() {
- }
-
- public OrcMage(OrcMage mage) {
- }
-
- @Override
- public Mage clone() throws CloneNotSupportedException {
- return new OrcMage(this);
- }
-
- @Override
- public String toString() {
- return "Orcish mage";
- }
-
-}
+package com.iluwatar.prototype;
+
+/**
+ *
+ * OrcMage
+ *
+ */
+public class OrcMage extends Mage {
+
+ public OrcMage() {
+ }
+
+ public OrcMage(OrcMage mage) {
+ }
+
+ @Override
+ public Mage clone() throws CloneNotSupportedException {
+ return new OrcMage(this);
+ }
+
+ @Override
+ public String toString() {
+ return "Orcish mage";
+ }
+
+}
diff --git a/prototype/src/main/java/com/iluwatar/prototype/OrcWarlord.java b/prototype/src/main/java/com/iluwatar/prototype/OrcWarlord.java
index 2832c3835..53814d1c2 100644
--- a/prototype/src/main/java/com/iluwatar/prototype/OrcWarlord.java
+++ b/prototype/src/main/java/com/iluwatar/prototype/OrcWarlord.java
@@ -1,21 +1,26 @@
-package com.iluwatar.prototype;
-
-public class OrcWarlord extends Warlord {
-
- public OrcWarlord() {
- }
-
- public OrcWarlord(OrcWarlord warlord) {
- }
-
- @Override
- public Warlord clone() throws CloneNotSupportedException {
- return new OrcWarlord(this);
- }
-
- @Override
- public String toString() {
- return "Orcish warlord";
- }
-
-}
+package com.iluwatar.prototype;
+
+/**
+ *
+ * OrcWarlord
+ *
+ */
+public class OrcWarlord extends Warlord {
+
+ public OrcWarlord() {
+ }
+
+ public OrcWarlord(OrcWarlord warlord) {
+ }
+
+ @Override
+ public Warlord clone() throws CloneNotSupportedException {
+ return new OrcWarlord(this);
+ }
+
+ @Override
+ public String toString() {
+ return "Orcish warlord";
+ }
+
+}
diff --git a/prototype/src/main/java/com/iluwatar/prototype/Prototype.java b/prototype/src/main/java/com/iluwatar/prototype/Prototype.java
index 2329f1e6d..eb2520c35 100644
--- a/prototype/src/main/java/com/iluwatar/prototype/Prototype.java
+++ b/prototype/src/main/java/com/iluwatar/prototype/Prototype.java
@@ -1,8 +1,13 @@
-package com.iluwatar.prototype;
-
-public abstract class Prototype implements Cloneable {
-
- @Override
- public abstract Object clone() throws CloneNotSupportedException;
-
-}
+package com.iluwatar.prototype;
+
+/**
+ *
+ * Prototype
+ *
+ */
+public abstract class Prototype implements Cloneable {
+
+ @Override
+ public abstract Object clone() throws CloneNotSupportedException;
+
+}
diff --git a/prototype/src/main/java/com/iluwatar/prototype/Warlord.java b/prototype/src/main/java/com/iluwatar/prototype/Warlord.java
index 930320d97..bfd5c594a 100644
--- a/prototype/src/main/java/com/iluwatar/prototype/Warlord.java
+++ b/prototype/src/main/java/com/iluwatar/prototype/Warlord.java
@@ -1,8 +1,13 @@
-package com.iluwatar.prototype;
-
-public abstract class Warlord extends Prototype {
-
- @Override
- public abstract Warlord clone() throws CloneNotSupportedException;
-
-}
+package com.iluwatar.prototype;
+
+/**
+ *
+ * Warlord
+ *
+ */
+public abstract class Warlord extends Prototype {
+
+ @Override
+ public abstract Warlord clone() throws CloneNotSupportedException;
+
+}
diff --git a/prototype/src/test/java/com/iluwatar/prototype/AppTest.java b/prototype/src/test/java/com/iluwatar/prototype/AppTest.java
index ecb576038..030f5472c 100644
--- a/prototype/src/test/java/com/iluwatar/prototype/AppTest.java
+++ b/prototype/src/test/java/com/iluwatar/prototype/AppTest.java
@@ -1,14 +1,19 @@
-package com.iluwatar.prototype;
-
-import org.junit.Test;
-
-import com.iluwatar.prototype.App;
-
-public class AppTest {
-
- @Test
- public void test() {
- String[] args = {};
- App.main(args);
- }
-}
+package com.iluwatar.prototype;
+
+import org.junit.Test;
+
+import com.iluwatar.prototype.App;
+
+/**
+ *
+ * Application test
+ *
+ */
+public class AppTest {
+
+ @Test
+ public void test() {
+ String[] args = {};
+ App.main(args);
+ }
+}
diff --git a/proxy/src/main/java/com/iluwatar/proxy/App.java b/proxy/src/main/java/com/iluwatar/proxy/App.java
index 86c96466b..fb401ac9f 100644
--- a/proxy/src/main/java/com/iluwatar/proxy/App.java
+++ b/proxy/src/main/java/com/iluwatar/proxy/App.java
@@ -1,20 +1,20 @@
-package com.iluwatar.proxy;
-
-/**
- *
- * Proxy (WizardTowerProxy) controls access to the actual object (WizardTower).
- *
- */
-public class App {
-
- public static void main(String[] args) {
-
- WizardTowerProxy tower = new WizardTowerProxy();
- tower.enter(new Wizard("Red wizard"));
- tower.enter(new Wizard("White wizard"));
- tower.enter(new Wizard("Black wizard"));
- tower.enter(new Wizard("Green wizard"));
- tower.enter(new Wizard("Brown wizard"));
-
- }
-}
+package com.iluwatar.proxy;
+
+/**
+ *
+ * Proxy ({@link WizardTowerProxy}) controls access to the actual object ({@link WizardTower}).
+ *
+ */
+public class App {
+
+ public static void main(String[] args) {
+
+ WizardTowerProxy tower = new WizardTowerProxy();
+ tower.enter(new Wizard("Red wizard"));
+ tower.enter(new Wizard("White wizard"));
+ tower.enter(new Wizard("Black wizard"));
+ tower.enter(new Wizard("Green wizard"));
+ tower.enter(new Wizard("Brown wizard"));
+
+ }
+}
diff --git a/proxy/src/main/java/com/iluwatar/proxy/Wizard.java b/proxy/src/main/java/com/iluwatar/proxy/Wizard.java
index 2060a5803..b6d5691f4 100644
--- a/proxy/src/main/java/com/iluwatar/proxy/Wizard.java
+++ b/proxy/src/main/java/com/iluwatar/proxy/Wizard.java
@@ -1,16 +1,21 @@
-package com.iluwatar.proxy;
-
-public class Wizard {
-
- private String name;
-
- public Wizard(String name) {
- this.name = name;
- }
-
- @Override
- public String toString() {
- return name;
- }
-
-}
+package com.iluwatar.proxy;
+
+/**
+ *
+ * Wizard
+ *
+ */
+public class Wizard {
+
+ private String name;
+
+ public Wizard(String name) {
+ this.name = name;
+ }
+
+ @Override
+ public String toString() {
+ return name;
+ }
+
+}
diff --git a/proxy/src/main/java/com/iluwatar/proxy/WizardTowerProxy.java b/proxy/src/main/java/com/iluwatar/proxy/WizardTowerProxy.java
index 3563aef1d..567a998d1 100644
--- a/proxy/src/main/java/com/iluwatar/proxy/WizardTowerProxy.java
+++ b/proxy/src/main/java/com/iluwatar/proxy/WizardTowerProxy.java
@@ -1,23 +1,23 @@
-package com.iluwatar.proxy;
-
-/**
- *
- * The proxy controlling access to WizardTower.
- *
- */
-public class WizardTowerProxy extends WizardTower {
-
- private static final int NUM_WIZARDS_ALLOWED = 3;
-
- private int numWizards;
-
- @Override
- public void enter(Wizard wizard) {
- if (numWizards < NUM_WIZARDS_ALLOWED) {
- super.enter(wizard);
- numWizards++;
- } else {
- System.out.println(wizard + " is not allowed to enter!");
- }
- }
-}
+package com.iluwatar.proxy;
+
+/**
+ *
+ * The proxy controlling access to the {@link WizardTower}.
+ *
+ */
+public class WizardTowerProxy extends WizardTower {
+
+ private static final int NUM_WIZARDS_ALLOWED = 3;
+
+ private int numWizards;
+
+ @Override
+ public void enter(Wizard wizard) {
+ if (numWizards < NUM_WIZARDS_ALLOWED) {
+ super.enter(wizard);
+ numWizards++;
+ } else {
+ System.out.println(wizard + " is not allowed to enter!");
+ }
+ }
+}
diff --git a/proxy/src/test/java/com/iluwatar/proxy/AppTest.java b/proxy/src/test/java/com/iluwatar/proxy/AppTest.java
index 0cd9641df..4d21b3d9a 100644
--- a/proxy/src/test/java/com/iluwatar/proxy/AppTest.java
+++ b/proxy/src/test/java/com/iluwatar/proxy/AppTest.java
@@ -1,14 +1,19 @@
-package com.iluwatar.proxy;
-
-import org.junit.Test;
-
-import com.iluwatar.proxy.App;
-
-public class AppTest {
-
- @Test
- public void test() {
- String[] args = {};
- App.main(args);
- }
-}
+package com.iluwatar.proxy;
+
+import org.junit.Test;
+
+import com.iluwatar.proxy.App;
+
+/**
+ *
+ * Application test
+ *
+ */
+public class AppTest {
+
+ @Test
+ public void test() {
+ String[] args = {};
+ App.main(args);
+ }
+}
diff --git a/repository/src/main/java/com/iluwatar/repository/App.java b/repository/src/main/java/com/iluwatar/repository/App.java
index 3e4d46d00..37a5f7962 100644
--- a/repository/src/main/java/com/iluwatar/repository/App.java
+++ b/repository/src/main/java/com/iluwatar/repository/App.java
@@ -13,14 +13,18 @@ import org.springframework.context.support.ClassPathXmlApplicationContext;
* query construction code is concentrated. This becomes more important when there are a large
* number of domain classes or heavy querying. In these cases particularly, adding this layer helps
* minimize duplicate query logic.
- *
- * In this example we utilize Spring Data to automatically generate a repository for us from the Person
- * domain object. Using the PersonDao we perform CRUD operations on the entity. Underneath we have
+ *
+ * In this example we utilize Spring Data to automatically generate a repository for us from the {@link Person}
+ * domain object. Using the {@link PersonRepository} we perform CRUD operations on the entity. Underneath we have
* configured in-memory H2 database for which schema is created and dropped on each run.
*
*/
public class App {
+ /**
+ * Program entry point
+ * @param args command line args
+ */
public static void main(String[] args) {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
"applicationContext.xml");
diff --git a/repository/src/test/java/com/iluwatar/repository/AppTest.java b/repository/src/test/java/com/iluwatar/repository/AppTest.java
index 2e638ba6b..14f597045 100644
--- a/repository/src/test/java/com/iluwatar/repository/AppTest.java
+++ b/repository/src/test/java/com/iluwatar/repository/AppTest.java
@@ -4,6 +4,11 @@ import org.junit.Test;
import com.iluwatar.repository.App;
+/**
+ *
+ * Application test
+ *
+ */
public class AppTest {
@Test
diff --git a/resource-acquisition-is-initialization/src/main/java/com/iluwatar/resource/acquisition/is/initialization/App.java b/resource-acquisition-is-initialization/src/main/java/com/iluwatar/resource/acquisition/is/initialization/App.java
index b947d31d0..141aea4ec 100644
--- a/resource-acquisition-is-initialization/src/main/java/com/iluwatar/resource/acquisition/is/initialization/App.java
+++ b/resource-acquisition-is-initialization/src/main/java/com/iluwatar/resource/acquisition/is/initialization/App.java
@@ -5,27 +5,32 @@ package com.iluwatar.resource.acquisition.is.initialization;
* Resource Acquisition Is Initialization pattern was developed
* for exception safe resource management by C++ creator Bjarne
* Stroustrup.
- *
+ *
* In RAII resource is tied to object lifetime: resource allocation
* is done during object creation while resource deallocation is
* done during object destruction.
- *
+ *
* In Java RAII is achieved with try-with-resources statement and
- * interfaces Closeable and AutoCloseable. The try-with-resources
+ * interfaces {@link Closeable} and {@link AutoCloseable}. The try-with-resources
* statement ensures that each resource is closed at the end of the
- * statement. Any object that implements java.lang.AutoCloseable, which
- * includes all objects which implement java.io.Closeable, can be used
+ * statement. Any object that implements {@link java.lang.AutoCloseable}, which
+ * includes all objects which implement {@link java.io.Closeable}, can be used
* as a resource.
*
- * In this example, SlidingDoor implements AutoCloseable and
- * TreasureChest implements Closeable. Running the example, we can
+ * In this example, {@link SlidingDoor} implements {@link AutoCloseable} and
+ * {@link TreasureChest} implements {@link Closeable}. Running the example, we can
* observe that both resources are automatically closed.
- *
+ *
* http://docs.oracle.com/javase/7/docs/technotes/guides/language/try-with-resources.html
*
*/
public class App {
+ /**
+ * Program entry point
+ * @param args command line args
+ * @throws Exception
+ */
public static void main( String[] args ) throws Exception {
try (SlidingDoor slidingDoor = new SlidingDoor()) {
diff --git a/resource-acquisition-is-initialization/src/test/java/com/iluwatar/resource/acquisition/is/initialization/AppTest.java b/resource-acquisition-is-initialization/src/test/java/com/iluwatar/resource/acquisition/is/initialization/AppTest.java
index 097ea4711..e20815c3f 100644
--- a/resource-acquisition-is-initialization/src/test/java/com/iluwatar/resource/acquisition/is/initialization/AppTest.java
+++ b/resource-acquisition-is-initialization/src/test/java/com/iluwatar/resource/acquisition/is/initialization/AppTest.java
@@ -4,6 +4,11 @@ import org.junit.Test;
import com.iluwatar.resource.acquisition.is.initialization.App;
+/**
+ *
+ * Application test
+ *
+ */
public class AppTest {
@Test
diff --git a/servant/src/main/java/com/iluwatar/servant/App.java b/servant/src/main/java/com/iluwatar/servant/App.java
index 4951c7270..6a0ba6ca4 100644
--- a/servant/src/main/java/com/iluwatar/servant/App.java
+++ b/servant/src/main/java/com/iluwatar/servant/App.java
@@ -10,9 +10,14 @@ import java.util.ArrayList;
*
*/
public class App {
+
static Servant jenkins = new Servant("Jenkins");
static Servant travis = new Servant("Travis");
+ /**
+ * Program entry point
+ * @param args
+ */
public static void main(String[] args) {
scenario(jenkins, 1);
scenario(travis, 0);
diff --git a/servant/src/main/java/com/iluwatar/servant/King.java b/servant/src/main/java/com/iluwatar/servant/King.java
index 24aa1b870..29ec88192 100644
--- a/servant/src/main/java/com/iluwatar/servant/King.java
+++ b/servant/src/main/java/com/iluwatar/servant/King.java
@@ -1,6 +1,12 @@
package com.iluwatar.servant;
+/**
+ *
+ * King
+ *
+ */
public class King implements Royalty {
+
private boolean isDrunk;
private boolean isHungry = true;
private boolean isHappy;
diff --git a/servant/src/main/java/com/iluwatar/servant/Queen.java b/servant/src/main/java/com/iluwatar/servant/Queen.java
index c581132de..815106725 100644
--- a/servant/src/main/java/com/iluwatar/servant/Queen.java
+++ b/servant/src/main/java/com/iluwatar/servant/Queen.java
@@ -1,6 +1,12 @@
package com.iluwatar.servant;
+/**
+ *
+ * Queen
+ *
+ */
public class Queen implements Royalty {
+
private boolean isDrunk = true;
private boolean isHungry;
private boolean isHappy;
diff --git a/servant/src/main/java/com/iluwatar/servant/Royalty.java b/servant/src/main/java/com/iluwatar/servant/Royalty.java
index 02ebe3cce..543ffd8d5 100644
--- a/servant/src/main/java/com/iluwatar/servant/Royalty.java
+++ b/servant/src/main/java/com/iluwatar/servant/Royalty.java
@@ -1,5 +1,10 @@
package com.iluwatar.servant;
+/**
+ *
+ * Royalty
+ *
+ */
interface Royalty {
void getFed();
diff --git a/servant/src/main/java/com/iluwatar/servant/Servant.java b/servant/src/main/java/com/iluwatar/servant/Servant.java
index b29e7fe20..8e61333d8 100644
--- a/servant/src/main/java/com/iluwatar/servant/Servant.java
+++ b/servant/src/main/java/com/iluwatar/servant/Servant.java
@@ -2,7 +2,13 @@ package com.iluwatar.servant;
import java.util.ArrayList;
+/**
+ *
+ * Servant
+ *
+ */
public class Servant {
+
public String name;
public Servant(String name){
diff --git a/servant/src/test/java/com/iluwatar/servant/AppTest.java b/servant/src/test/java/com/iluwatar/servant/AppTest.java
index bf6655f2a..94a12b207 100644
--- a/servant/src/test/java/com/iluwatar/servant/AppTest.java
+++ b/servant/src/test/java/com/iluwatar/servant/AppTest.java
@@ -1,14 +1,19 @@
-package com.iluwatar.servant;
-
-import org.junit.Test;
-
-import com.iluwatar.servant.App;
-
-public class AppTest {
-
- @Test
- public void test() {
- String[] args = {};
- App.main(args);
- }
-}
+package com.iluwatar.servant;
+
+import org.junit.Test;
+
+import com.iluwatar.servant.App;
+
+/**
+ *
+ * Application test
+ *
+ */
+public class AppTest {
+
+ @Test
+ public void test() {
+ String[] args = {};
+ App.main(args);
+ }
+}
diff --git a/service-layer/src/main/java/com/iluwatar/servicelayer/app/App.java b/service-layer/src/main/java/com/iluwatar/servicelayer/app/App.java
index ea0419606..2d91b43d9 100644
--- a/service-layer/src/main/java/com/iluwatar/servicelayer/app/App.java
+++ b/service-layer/src/main/java/com/iluwatar/servicelayer/app/App.java
@@ -18,7 +18,7 @@ import com.iluwatar.servicelayer.wizard.WizardDaoImpl;
/**
* Service layer defines an application's boundary with a layer of services that establishes
* a set of available operations and coordinates the application's response in each operation.
- *
+ *
* Enterprise applications typically require different kinds of interfaces to the data
* they store and the logic they implement: data loaders, user interfaces, integration gateways,
* and others. Despite their different purposes, these interfaces often need common interactions
@@ -26,15 +26,19 @@ import com.iluwatar.servicelayer.wizard.WizardDaoImpl;
* interactions may be complex, involving transactions across multiple resources and the
* coordination of several responses to an action. Encoding the logic of the interactions
* separately in each interface causes a lot of duplication.
- *
- * The example application demonstrates interactions between a client (App) and a service
- * (MagicService). The service is implemented with 3-layer architecture (entity, dao, service).
+ *
+ * The example application demonstrates interactions between a client ({@link App}) and a service
+ * ({@link MagicService}). The service is implemented with 3-layer architecture (entity, dao, service).
* For persistence the example uses in-memory H2 database which is populated on each application
* startup.
*
*/
public class App {
+ /**
+ * Program entry point
+ * @param args command line args
+ */
public static void main( String[] args ) {
// populate the in-memory database
initData();
diff --git a/service-layer/src/main/java/com/iluwatar/servicelayer/hibernate/HibernateUtil.java b/service-layer/src/main/java/com/iluwatar/servicelayer/hibernate/HibernateUtil.java
index 922fe9f21..70d586c08 100644
--- a/service-layer/src/main/java/com/iluwatar/servicelayer/hibernate/HibernateUtil.java
+++ b/service-layer/src/main/java/com/iluwatar/servicelayer/hibernate/HibernateUtil.java
@@ -9,7 +9,7 @@ import com.iluwatar.servicelayer.wizard.Wizard;
/**
*
- * Produces the Hibernate SessionFactory.
+ * Produces the Hibernate {@link SessionFactory}.
*
*/
public class HibernateUtil {
diff --git a/service-layer/src/test/java/com/iluwatar/servicelayer/app/AppTest.java b/service-layer/src/test/java/com/iluwatar/servicelayer/app/AppTest.java
index aabeb1a6c..bbf476c0b 100644
--- a/service-layer/src/test/java/com/iluwatar/servicelayer/app/AppTest.java
+++ b/service-layer/src/test/java/com/iluwatar/servicelayer/app/AppTest.java
@@ -4,6 +4,11 @@ import org.junit.Test;
import com.iluwatar.servicelayer.app.App;
+/**
+ *
+ * Application test
+ *
+ */
public class AppTest {
@Test
diff --git a/service-locator/src/main/java/com/iluwatar/servicelocator/App.java b/service-locator/src/main/java/com/iluwatar/servicelocator/App.java
index 57f188731..f86e1cc32 100644
--- a/service-locator/src/main/java/com/iluwatar/servicelocator/App.java
+++ b/service-locator/src/main/java/com/iluwatar/servicelocator/App.java
@@ -1,12 +1,18 @@
package com.iluwatar.servicelocator;
/**
- * Service locator pattern, used to lookup jndi services
+ * Service locator pattern, used to lookup JNDI-services
* and cache them for subsequent requests.
*
* @author saifasif
+ *
*/
public class App {
+
+ /**
+ * Program entry point
+ * @param args command line args
+ */
public static void main(String[] args) {
Service service = ServiceLocator.getService("jndi/serviceA");
service.execute();
diff --git a/service-locator/src/main/java/com/iluwatar/servicelocator/Service.java b/service-locator/src/main/java/com/iluwatar/servicelocator/Service.java
index dbb268159..4831add95 100644
--- a/service-locator/src/main/java/com/iluwatar/servicelocator/Service.java
+++ b/service-locator/src/main/java/com/iluwatar/servicelocator/Service.java
@@ -6,6 +6,7 @@ package com.iluwatar.servicelocator;
*
+ * http://stackoverflow.com/questions/70689/what-is-an-efficient-way-to-implement-a-singleton-pattern-in-java
+ *
+ * The risk of this pattern is that bugs resulting from setting a singleton up in a distributed environment can
+ * be tricky to debug, since it will work fine if you debug with a single classloader. Additionally, these
+ * problems can crop up a while after the implementation of a singleton, since they may start out synchronous and
+ * only become async with time, so you it may not be clear why you are seeing certain changes in behaviour.
+ *
+ * http://stackoverflow.com/questions/17721263/singleton-across-jvm-or-application-instance-or-tomcat-instance
+ */
+public class App {
+
+ /**
+ * Program entry point
+ * @param args command line args
+ */
+ public static void main(String[] args) {
+
+ // eagerly initialized singleton
+ IvoryTower ivoryTower1 = IvoryTower.getInstance();
+ IvoryTower ivoryTower2 = IvoryTower.getInstance();
+ System.out.println("ivoryTower1=" + ivoryTower1);
+ System.out.println("ivoryTower2=" + ivoryTower2);
+
+ // lazily initialized singleton
+ ThreadSafeLazyLoadedIvoryTower threadSafeIvoryTower1 = ThreadSafeLazyLoadedIvoryTower
+ .getInstance();
+ ThreadSafeLazyLoadedIvoryTower threadSafeIvoryTower2 = ThreadSafeLazyLoadedIvoryTower
+ .getInstance();
+ System.out.println("threadSafeIvoryTower1=" + threadSafeIvoryTower1);
+ System.out.println("threadSafeIvoryTower2=" + threadSafeIvoryTower2);
+
+ // enum singleton
+ EnumIvoryTower enumIvoryTower1 = EnumIvoryTower.INSTANCE;
+ EnumIvoryTower enumIvoryTower2 = EnumIvoryTower.INSTANCE;
+ System.out.println("enumIvoryTower1=" + enumIvoryTower1);
+ System.out.println("enumIvoryTower2=" + enumIvoryTower2);
+
+ InitializingOnDemandHolderIdiom demandHolderIdiom = InitializingOnDemandHolderIdiom.getInstance();
+ System.out.println(demandHolderIdiom);
+ InitializingOnDemandHolderIdiom demandHolderIdiom2 = InitializingOnDemandHolderIdiom.getInstance();
+ System.out.println(demandHolderIdiom2);
+
+ ThreadSafeDoubleCheckLocking dcl1 = ThreadSafeDoubleCheckLocking.getInstance();
+ System.out.println(dcl1);
+ ThreadSafeDoubleCheckLocking dcl2 = ThreadSafeDoubleCheckLocking.getInstance();
+ System.out.println(dcl2);
+ }
+}
diff --git a/singleton/src/main/java/com/iluwatar/singleton/InitializingOnDemandHolderIdiom.java b/singleton/src/main/java/com/iluwatar/singleton/InitializingOnDemandHolderIdiom.java
index 329cd6a7e..4fd4c8163 100644
--- a/singleton/src/main/java/com/iluwatar/singleton/InitializingOnDemandHolderIdiom.java
+++ b/singleton/src/main/java/com/iluwatar/singleton/InitializingOnDemandHolderIdiom.java
@@ -4,12 +4,12 @@ import java.io.Serializable;
/**
* The Initialize-on-demand-holder idiom is a secure way of
- * creating lazy initialize singleton Object in Java.
+ * creating lazy initialized singleton object in Java.
* refer to "The CERT Oracle Secure Coding Standard for Java"
* By Dhruv Mohindra, Robert C. Seacord p.378
- *
+ *
* Singleton objects usually are heavy to create and sometimes need to serialize them.
- * This class also shows how to preserve singleton in Serialized version of singleton.
+ * This class also shows how to preserve singleton in serialized version of singleton.
*
* @author mortezaadi@gmail.com
*
diff --git a/singleton/src/main/java/com/iluwatar/singleton/ThreadSafeDoubleCheckLocking.java b/singleton/src/main/java/com/iluwatar/singleton/ThreadSafeDoubleCheckLocking.java
index 352cac2e9..d15509236 100644
--- a/singleton/src/main/java/com/iluwatar/singleton/ThreadSafeDoubleCheckLocking.java
+++ b/singleton/src/main/java/com/iluwatar/singleton/ThreadSafeDoubleCheckLocking.java
@@ -2,10 +2,11 @@ package com.iluwatar.singleton;
/**
* Double check locking
- *
+ *
* http://www.cs.umd.edu/~pugh/java/memoryModel/DoubleCheckedLocking.html
- *
+ *
* Broken under Java 1.4.
+ *
* @author mortezaadi@gmail.com
*
*/
diff --git a/singleton/src/test/java/com/iluwatar/singleton/AppTest.java b/singleton/src/test/java/com/iluwatar/singleton/AppTest.java
index abe0440fd..c83232037 100644
--- a/singleton/src/test/java/com/iluwatar/singleton/AppTest.java
+++ b/singleton/src/test/java/com/iluwatar/singleton/AppTest.java
@@ -1,14 +1,19 @@
-package com.iluwatar.singleton;
-
-import org.junit.Test;
-
-import com.iluwatar.singleton.App;
-
-public class AppTest {
-
- @Test
- public void test() {
- String[] args = {};
- App.main(args);
- }
-}
+package com.iluwatar.singleton;
+
+import org.junit.Test;
+
+import com.iluwatar.singleton.App;
+
+/**
+ *
+ * Application test
+ *
+ */
+public class AppTest {
+
+ @Test
+ public void test() {
+ String[] args = {};
+ App.main(args);
+ }
+}
diff --git a/singleton/src/test/java/com/iluwatar/singleton/LazyLoadedSingletonThreadSafetyTest.java b/singleton/src/test/java/com/iluwatar/singleton/LazyLoadedSingletonThreadSafetyTest.java
index f40d8a319..ca88f4169 100644
--- a/singleton/src/test/java/com/iluwatar/singleton/LazyLoadedSingletonThreadSafetyTest.java
+++ b/singleton/src/test/java/com/iluwatar/singleton/LazyLoadedSingletonThreadSafetyTest.java
@@ -5,9 +5,9 @@ import org.junit.Test;
/**
*
* This test case demonstrates thread safety issues of lazy loaded Singleton implementation.
- *
+ *
* Out of the box you should see the test output something like the following:
- *
+ *
* Thread=Thread-4 got instance=com.iluwatar.singleton.LazyLoadedSingletonThreadSafetyTest$LazyLoadedIvoryTower@6fde356e
* Thread=Thread-2 creating instance=com.iluwatar.singleton.LazyLoadedSingletonThreadSafetyTest$LazyLoadedIvoryTower@6fde356e
* Thread=Thread-0 creating instance=com.iluwatar.singleton.LazyLoadedSingletonThreadSafetyTest$LazyLoadedIvoryTower@6fde356e
@@ -15,13 +15,17 @@ import org.junit.Test;
* Thread=Thread-3 got instance=com.iluwatar.singleton.LazyLoadedSingletonThreadSafetyTest$LazyLoadedIvoryTower@6fde356e
* Thread=Thread-1 got instance=com.iluwatar.singleton.LazyLoadedSingletonThreadSafetyTest$LazyLoadedIvoryTower@60f330b0
* Thread=Thread-2 got instance=com.iluwatar.singleton.LazyLoadedSingletonThreadSafetyTest$LazyLoadedIvoryTower@6fde356e
- *
+ *
* By changing the method signature of LazyLoadedIvoryTower#getInstance from
+ *
* into
+ *
* you should see the test output change to something like the following:
- *
+ *
* Thread=Thread-4 creating instance=com.iluwatar.singleton.LazyLoadedSingletonThreadSafetyTest$LazyLoadedIvoryTower@3c688490
* Thread=Thread-4 got instance=com.iluwatar.singleton.LazyLoadedSingletonThreadSafetyTest$LazyLoadedIvoryTower@3c688490
* Thread=Thread-0 got instance=com.iluwatar.singleton.LazyLoadedSingletonThreadSafetyTest$LazyLoadedIvoryTower@3c688490
diff --git a/specification/src/main/java/com/iluwatar/specification/app/App.java b/specification/src/main/java/com/iluwatar/specification/app/App.java
index 7a5f00a5c..642278f16 100644
--- a/specification/src/main/java/com/iluwatar/specification/app/App.java
+++ b/specification/src/main/java/com/iluwatar/specification/app/App.java
@@ -18,14 +18,14 @@ import com.iluwatar.specification.selector.MovementSelector;
/**
*
- * The central idea of Specification pattern is to separate the statement of how to match a candidate, from the
+ * The central idea of the Specification pattern is to separate the statement of how to match a candidate, from the
* candidate object that it is matched against. As well as its usefulness in selection, it is also valuable for
* validation and for building to order.
- *
+ *
* In this example we have a pool of creatures with different properties. We then have defined separate selection
* rules (Specifications) that we apply to the collection and as output receive only the creatures that match
* the selection criteria.
- *
+ *
* http://martinfowler.com/apsupp/spec.pdf
*
*/
diff --git a/specification/src/test/java/com/iluwatar/specification/app/AppTest.java b/specification/src/test/java/com/iluwatar/specification/app/AppTest.java
index 8e27167dc..31965336c 100644
--- a/specification/src/test/java/com/iluwatar/specification/app/AppTest.java
+++ b/specification/src/test/java/com/iluwatar/specification/app/AppTest.java
@@ -4,6 +4,11 @@ import org.junit.Test;
import com.iluwatar.specification.app.App;
+/**
+ *
+ * Application test
+ *
+ */
public class AppTest {
@Test
diff --git a/state/src/main/java/com/iluwatar/state/App.java b/state/src/main/java/com/iluwatar/state/App.java
index eefa8f766..5b39d02f7 100644
--- a/state/src/main/java/com/iluwatar/state/App.java
+++ b/state/src/main/java/com/iluwatar/state/App.java
@@ -1,24 +1,24 @@
-package com.iluwatar.state;
-
-/**
- *
- * In State pattern the container object (Mammoth) has an internal state object (State) that
- * defines the current behavior. The state object can be changed to alter the
- * behavior.
- *
- * In this example the mammoth changes its behavior as time passes by.
- *
- */
-public class App {
-
- public static void main(String[] args) {
-
- Mammoth mammoth = new Mammoth();
- mammoth.observe();
- mammoth.timePasses();
- mammoth.observe();
- mammoth.timePasses();
- mammoth.observe();
-
- }
-}
+package com.iluwatar.state;
+
+/**
+ *
+ * In State pattern the container object ({@link Mammoth}) has an internal state object ({@link State}) that
+ * defines the current behavior. The state object can be changed to alter the
+ * behavior.
+ *
+ * In this example the {@link Mammoth} changes its behavior as time passes by.
+ *
+ */
+public class App {
+
+ public static void main(String[] args) {
+
+ Mammoth mammoth = new Mammoth();
+ mammoth.observe();
+ mammoth.timePasses();
+ mammoth.observe();
+ mammoth.timePasses();
+ mammoth.observe();
+
+ }
+}
diff --git a/state/src/test/java/com/iluwatar/state/AppTest.java b/state/src/test/java/com/iluwatar/state/AppTest.java
index fae8412fc..556cbc01c 100644
--- a/state/src/test/java/com/iluwatar/state/AppTest.java
+++ b/state/src/test/java/com/iluwatar/state/AppTest.java
@@ -1,14 +1,19 @@
-package com.iluwatar.state;
-
-import org.junit.Test;
-
-import com.iluwatar.state.App;
-
-public class AppTest {
-
- @Test
- public void test() {
- String[] args = {};
- App.main(args);
- }
-}
+package com.iluwatar.state;
+
+import org.junit.Test;
+
+import com.iluwatar.state.App;
+
+/**
+ *
+ * Application test
+ *
+ */
+public class AppTest {
+
+ @Test
+ public void test() {
+ String[] args = {};
+ App.main(args);
+ }
+}
diff --git a/step-builder/src/main/java/com/iluwatar/stepbuilder/App.java b/step-builder/src/main/java/com/iluwatar/stepbuilder/App.java
index 439c5bd11..533394acb 100644
--- a/step-builder/src/main/java/com/iluwatar/stepbuilder/App.java
+++ b/step-builder/src/main/java/com/iluwatar/stepbuilder/App.java
@@ -32,10 +32,15 @@ package com.iluwatar.stepbuilder;
* the object and how they're assembled the construction process must
* allow different representations for the object that's constructed
* when in the process of constructing the order is important.
- *
+ *
* http://rdafbn.blogspot.co.uk/2012/07/step-builder-pattern_28.html
*/
public class App {
+
+ /**
+ * Program entry point
+ * @param args command line args
+ */
public static void main(String[] args) {
Character warrior = CharacterStepBuilder.newBuilder()
diff --git a/step-builder/src/main/java/com/iluwatar/stepbuilder/CharacterStepBuilder.java b/step-builder/src/main/java/com/iluwatar/stepbuilder/CharacterStepBuilder.java
index e042758d9..b1ef3b5af 100644
--- a/step-builder/src/main/java/com/iluwatar/stepbuilder/CharacterStepBuilder.java
+++ b/step-builder/src/main/java/com/iluwatar/stepbuilder/CharacterStepBuilder.java
@@ -6,7 +6,6 @@ import java.util.List;
/**
* The Step Builder class.
*/
-
public class CharacterStepBuilder {
private CharacterStepBuilder() {
diff --git a/step-builder/src/test/java/com/iluwatar/stepbuilder/AppTest.java b/step-builder/src/test/java/com/iluwatar/stepbuilder/AppTest.java
index 61fe82aaf..fbed6798e 100644
--- a/step-builder/src/test/java/com/iluwatar/stepbuilder/AppTest.java
+++ b/step-builder/src/test/java/com/iluwatar/stepbuilder/AppTest.java
@@ -2,6 +2,11 @@ package com.iluwatar.stepbuilder;
import org.junit.Test;
+/**
+ *
+ * Application test
+ *
+ */
public class AppTest {
@Test
diff --git a/strategy/src/main/java/com/iluwatar/strategy/App.java b/strategy/src/main/java/com/iluwatar/strategy/App.java
index fc9a31327..992514801 100644
--- a/strategy/src/main/java/com/iluwatar/strategy/App.java
+++ b/strategy/src/main/java/com/iluwatar/strategy/App.java
@@ -1,22 +1,26 @@
-package com.iluwatar.strategy;
-
-/**
- *
- * Strategy (DragonSlayingStrategy) encapsulates an algorithm. The containing
- * object (DragonSlayer) can alter its behavior by changing its strategy.
- *
- */
-public class App {
-
- public static void main(String[] args) {
- System.out.println("Green dragon spotted ahead!");
- DragonSlayer dragonSlayer = new DragonSlayer(new MeleeStrategy());
- dragonSlayer.goToBattle();
- System.out.println("Red dragon emerges.");
- dragonSlayer.changeStrategy(new ProjectileStrategy());
- dragonSlayer.goToBattle();
- System.out.println("Black dragon lands before you.");
- dragonSlayer.changeStrategy(new SpellStrategy());
- dragonSlayer.goToBattle();
- }
-}
+package com.iluwatar.strategy;
+
+/**
+ *
+ * Strategy ({@link DragonSlayingStrategy}) encapsulates an algorithm. The containing
+ * object ({@link DragonSlayer}) can alter its behavior by changing its strategy.
+ *
+ */
+public class App {
+
+ /**
+ * Program entry point
+ * @param args command line args
+ */
+ public static void main(String[] args) {
+ System.out.println("Green dragon spotted ahead!");
+ DragonSlayer dragonSlayer = new DragonSlayer(new MeleeStrategy());
+ dragonSlayer.goToBattle();
+ System.out.println("Red dragon emerges.");
+ dragonSlayer.changeStrategy(new ProjectileStrategy());
+ dragonSlayer.goToBattle();
+ System.out.println("Black dragon lands before you.");
+ dragonSlayer.changeStrategy(new SpellStrategy());
+ dragonSlayer.goToBattle();
+ }
+}
diff --git a/strategy/src/test/java/com/iluwatar/strategy/AppTest.java b/strategy/src/test/java/com/iluwatar/strategy/AppTest.java
index e46708c0a..e6748d30d 100644
--- a/strategy/src/test/java/com/iluwatar/strategy/AppTest.java
+++ b/strategy/src/test/java/com/iluwatar/strategy/AppTest.java
@@ -1,14 +1,19 @@
-package com.iluwatar.strategy;
-
-import org.junit.Test;
-
-import com.iluwatar.strategy.App;
-
-public class AppTest {
-
- @Test
- public void test() {
- String[] args = {};
- App.main(args);
- }
-}
+package com.iluwatar.strategy;
+
+import org.junit.Test;
+
+import com.iluwatar.strategy.App;
+
+/**
+ *
+ * Application test
+ *
+ */
+public class AppTest {
+
+ @Test
+ public void test() {
+ String[] args = {};
+ App.main(args);
+ }
+}
diff --git a/template-method/src/main/java/com/iluwatar/templatemethod/App.java b/template-method/src/main/java/com/iluwatar/templatemethod/App.java
index 9797474cf..c9927e91b 100644
--- a/template-method/src/main/java/com/iluwatar/templatemethod/App.java
+++ b/template-method/src/main/java/com/iluwatar/templatemethod/App.java
@@ -1,20 +1,24 @@
-package com.iluwatar.templatemethod;
-
-/**
- *
- * Template Method defines a skeleton for an algorithm. The algorithm subclasses
- * provide implementation for the blank parts.
- *
- * In this example HalflingThief contains StealingMethod that can be changed.
- * First the thief hits with HitAndRunMethod and then with SubtleMethod.
- *
- */
-public class App {
-
- public static void main(String[] args) {
- HalflingThief thief = new HalflingThief(new HitAndRunMethod());
- thief.steal();
- thief.changeMethod(new SubtleMethod());
- thief.steal();
- }
-}
+package com.iluwatar.templatemethod;
+
+/**
+ *
+ * Template Method defines a skeleton for an algorithm. The algorithm subclasses
+ * provide implementation for the blank parts.
+ *
+ * In this example {@link HalflingThief} contains {@link StealingMethod} that can be changed.
+ * First the thief hits with {@link HitAndRunMethod} and then with {@link SubtleMethod}.
+ *
+ */
+public class App {
+
+ /**
+ * Program entry point
+ * @param args command line args
+ */
+ public static void main(String[] args) {
+ HalflingThief thief = new HalflingThief(new HitAndRunMethod());
+ thief.steal();
+ thief.changeMethod(new SubtleMethod());
+ thief.steal();
+ }
+}
diff --git a/template-method/src/main/java/com/iluwatar/templatemethod/HalflingThief.java b/template-method/src/main/java/com/iluwatar/templatemethod/HalflingThief.java
index 3cdb2f1b1..4d6cecb9f 100644
--- a/template-method/src/main/java/com/iluwatar/templatemethod/HalflingThief.java
+++ b/template-method/src/main/java/com/iluwatar/templatemethod/HalflingThief.java
@@ -1,23 +1,23 @@
-package com.iluwatar.templatemethod;
-
-/**
- *
- * Halfling thief uses StealingMethod to steal.
- *
- */
-public class HalflingThief {
-
- private StealingMethod method;
-
- public HalflingThief(StealingMethod method) {
- this.method = method;
- }
-
- public void steal() {
- method.steal();
- }
-
- public void changeMethod(StealingMethod method) {
- this.method = method;
- }
-}
+package com.iluwatar.templatemethod;
+
+/**
+ *
+ * Halfling thief uses {@link StealingMethod} to steal.
+ *
+ */
+public class HalflingThief {
+
+ private StealingMethod method;
+
+ public HalflingThief(StealingMethod method) {
+ this.method = method;
+ }
+
+ public void steal() {
+ method.steal();
+ }
+
+ public void changeMethod(StealingMethod method) {
+ this.method = method;
+ }
+}
diff --git a/template-method/src/main/java/com/iluwatar/templatemethod/HitAndRunMethod.java b/template-method/src/main/java/com/iluwatar/templatemethod/HitAndRunMethod.java
index 78ee2031b..633e52895 100644
--- a/template-method/src/main/java/com/iluwatar/templatemethod/HitAndRunMethod.java
+++ b/template-method/src/main/java/com/iluwatar/templatemethod/HitAndRunMethod.java
@@ -1,25 +1,25 @@
-package com.iluwatar.templatemethod;
-
-/**
- *
- * HitAndRunMethod implementation of StealingMethod.
- *
- */
-public class HitAndRunMethod extends StealingMethod {
-
- @Override
- protected String pickTarget() {
- return "old goblin woman";
- }
-
- @Override
- protected void confuseTarget(String target) {
- System.out.println("Approach the " + target + " from behind.");
- }
-
- @Override
- protected void stealTheItem(String target) {
- System.out.println("Grab the handbag and run away fast!");
- }
-
-}
+package com.iluwatar.templatemethod;
+
+/**
+ *
+ * HitAndRunMethod implementation of {@link StealingMethod}.
+ *
+ */
+public class HitAndRunMethod extends StealingMethod {
+
+ @Override
+ protected String pickTarget() {
+ return "old goblin woman";
+ }
+
+ @Override
+ protected void confuseTarget(String target) {
+ System.out.println("Approach the " + target + " from behind.");
+ }
+
+ @Override
+ protected void stealTheItem(String target) {
+ System.out.println("Grab the handbag and run away fast!");
+ }
+
+}
diff --git a/template-method/src/main/java/com/iluwatar/templatemethod/SubtleMethod.java b/template-method/src/main/java/com/iluwatar/templatemethod/SubtleMethod.java
index c5bd1cfaf..f506d682b 100644
--- a/template-method/src/main/java/com/iluwatar/templatemethod/SubtleMethod.java
+++ b/template-method/src/main/java/com/iluwatar/templatemethod/SubtleMethod.java
@@ -1,27 +1,27 @@
-package com.iluwatar.templatemethod;
-
-/**
- *
- * SubtleMethod implementation of StealingMethod.
- *
- */
-public class SubtleMethod extends StealingMethod {
-
- @Override
- protected String pickTarget() {
- return "shop keeper";
- }
-
- @Override
- protected void confuseTarget(String target) {
- System.out.println("Approach the " + target
- + " with tears running and hug him!");
- }
-
- @Override
- protected void stealTheItem(String target) {
- System.out.println("While in close contact grab the " + target
- + "'s wallet.");
- }
-
-}
+package com.iluwatar.templatemethod;
+
+/**
+ *
+ * SubtleMethod implementation of {@link StealingMethod}.
+ *
+ */
+public class SubtleMethod extends StealingMethod {
+
+ @Override
+ protected String pickTarget() {
+ return "shop keeper";
+ }
+
+ @Override
+ protected void confuseTarget(String target) {
+ System.out.println("Approach the " + target
+ + " with tears running and hug him!");
+ }
+
+ @Override
+ protected void stealTheItem(String target) {
+ System.out.println("While in close contact grab the " + target
+ + "'s wallet.");
+ }
+
+}
diff --git a/template-method/src/test/java/com/iluwatar/templatemethod/AppTest.java b/template-method/src/test/java/com/iluwatar/templatemethod/AppTest.java
index fce07bef1..bd4e2d332 100644
--- a/template-method/src/test/java/com/iluwatar/templatemethod/AppTest.java
+++ b/template-method/src/test/java/com/iluwatar/templatemethod/AppTest.java
@@ -1,14 +1,19 @@
-package com.iluwatar.templatemethod;
-
-import org.junit.Test;
-
-import com.iluwatar.templatemethod.App;
-
-public class AppTest {
-
- @Test
- public void test() {
- String[] args = {};
- App.main(args);
- }
-}
+package com.iluwatar.templatemethod;
+
+import org.junit.Test;
+
+import com.iluwatar.templatemethod.App;
+
+/**
+ *
+ * Application test
+ *
+ */
+public class AppTest {
+
+ @Test
+ public void test() {
+ String[] args = {};
+ App.main(args);
+ }
+}
diff --git a/thread-pool/src/main/java/com/iluwatar/threadpool/App.java b/thread-pool/src/main/java/com/iluwatar/threadpool/App.java
index 0a7bed3a0..bfaaead31 100644
--- a/thread-pool/src/main/java/com/iluwatar/threadpool/App.java
+++ b/thread-pool/src/main/java/com/iluwatar/threadpool/App.java
@@ -13,14 +13,19 @@ import java.util.concurrent.Executors;
* more tasks than threads. As soon as a thread completes its task, it will request the next
* task from the queue until all tasks have been completed. The thread can then terminate, or
* sleep until there are new tasks available.
- *
+ *
* In this example we create a list of tasks presenting work to be done. Each task is then
- * wrapped into a Worker object that implements Runnable. We create an ExecutorService with
- * fixed number of threads (Thread Pool) and use them to execute the Workers.
+ * wrapped into a {@link Worker} object that implements {@link Runnable}. We create an
+ * {@link ExecutorService} with fixed number of threads (Thread Pool) and use them to execute
+ * the {@link Worker}s.
*
*/
public class App {
+ /**
+ * Program entry point
+ * @param args command line args
+ */
public static void main( String[] args ) {
System.out.println("Program started");
diff --git a/thread-pool/src/main/java/com/iluwatar/threadpool/Worker.java b/thread-pool/src/main/java/com/iluwatar/threadpool/Worker.java
index b6ee5e665..92da4b5dd 100644
--- a/thread-pool/src/main/java/com/iluwatar/threadpool/Worker.java
+++ b/thread-pool/src/main/java/com/iluwatar/threadpool/Worker.java
@@ -2,7 +2,7 @@ package com.iluwatar.threadpool;
/**
*
- * Worker implements Runnable and thus can be executed by ExecutorService
+ * Worker implements {@link Runnable} and thus can be executed by {@link ExecutorService}
*
*/
public class Worker implements Runnable {
diff --git a/thread-pool/src/test/java/com/iluwatar/threadpool/AppTest.java b/thread-pool/src/test/java/com/iluwatar/threadpool/AppTest.java
index ec5c031ff..71cfea5f7 100644
--- a/thread-pool/src/test/java/com/iluwatar/threadpool/AppTest.java
+++ b/thread-pool/src/test/java/com/iluwatar/threadpool/AppTest.java
@@ -4,6 +4,11 @@ import org.junit.Test;
import com.iluwatar.threadpool.App;
+/**
+ * Application test
+ * @author ilkka
+ *
+ */
public class AppTest {
@Test
diff --git a/tolerant-reader/src/main/java/com/iluwatar/tolerantreader/App.java b/tolerant-reader/src/main/java/com/iluwatar/tolerantreader/App.java
index ab4a8bfad..d4ff933d7 100644
--- a/tolerant-reader/src/main/java/com/iluwatar/tolerantreader/App.java
+++ b/tolerant-reader/src/main/java/com/iluwatar/tolerantreader/App.java
@@ -7,14 +7,14 @@ import java.io.IOException;
* Tolerant Reader is an integration pattern that helps creating robust communication
* systems. The idea is to be as tolerant as possible when reading data from another
* service. This way, when the communication schema changes, the readers must not break.
- *
- * In this example we use Java serialization to write representations of RainbowFish
- * objects to file. RainbowFish is the initial version which we can easily read and
- * write using RainbowFishSerializer methods. RainbowFish then evolves to RainbowFishV2
+ *
+ * In this example we use Java serialization to write representations of {@link RainbowFish}
+ * objects to file. {@link RainbowFish} is the initial version which we can easily read and
+ * write using {@link RainbowFishSerializer} methods. {@link RainbowFish} then evolves to {@link RainbowFishV2}
* and we again write it to file with a method designed to do just that. However, the reader
* client does not know about the new format and still reads with the method designed for
* V1 schema. Fortunately the reading method has been designed with the Tolerant Reader
- * pattern and does not break even though RainbowFishV2 has new fields that are serialized.
+ * pattern and does not break even though {@link RainbowFishV2} has new fields that are serialized.
*
*/
public class App {
diff --git a/tolerant-reader/src/main/java/com/iluwatar/tolerantreader/RainbowFishSerializer.java b/tolerant-reader/src/main/java/com/iluwatar/tolerantreader/RainbowFishSerializer.java
index ec482a34a..e788bcad4 100644
--- a/tolerant-reader/src/main/java/com/iluwatar/tolerantreader/RainbowFishSerializer.java
+++ b/tolerant-reader/src/main/java/com/iluwatar/tolerantreader/RainbowFishSerializer.java
@@ -10,8 +10,8 @@ import java.util.Map;
/**
*
- * RainbowFishSerializer provides methods for reading and writing RainbowFish objects to file.
- * Tolerant Reader pattern is implemented here by serializing maps instead of RainbowFish objects.
+ * RainbowFishSerializer provides methods for reading and writing {@link RainbowFish} objects to file.
+ * Tolerant Reader pattern is implemented here by serializing maps instead of {@link RainbowFish} objects.
* This way the reader does not break even though new properties are added to the schema.
*
*/
diff --git a/tolerant-reader/src/test/java/com/iluwatar/tolerantreader/AppTest.java b/tolerant-reader/src/test/java/com/iluwatar/tolerantreader/AppTest.java
index cba24ada9..bc5066866 100644
--- a/tolerant-reader/src/test/java/com/iluwatar/tolerantreader/AppTest.java
+++ b/tolerant-reader/src/test/java/com/iluwatar/tolerantreader/AppTest.java
@@ -9,7 +9,11 @@ import org.junit.Test;
import com.iluwatar.tolerantreader.App;
-
+/**
+ *
+ * Application test
+ *
+ */
public class AppTest {
@Test
diff --git a/visitor/src/main/java/com/iluwatar/visitor/App.java b/visitor/src/main/java/com/iluwatar/visitor/App.java
index d9338777c..dfdd4fcb6 100644
--- a/visitor/src/main/java/com/iluwatar/visitor/App.java
+++ b/visitor/src/main/java/com/iluwatar/visitor/App.java
@@ -1,27 +1,31 @@
-package com.iluwatar.visitor;
-
-/**
- *
- * Visitor pattern defines mechanism to apply operations on nodes
- * in hierarchy. New operations can be added without altering the node
- * interface.
- *
- * In this example there is a unit hierarchy beginning from Commander.
- * This hierarchy is traversed by visitors. SoldierVisitor applies
- * its operation on Soldiers, SergeantVisitor on Sergeants and so
- * on.
- *
- */
-public class App {
-
- public static void main(String[] args) {
-
- Commander commander = new Commander(new Sergeant(new Soldier(),
- new Soldier(), new Soldier()), new Sergeant(new Soldier(),
- new Soldier(), new Soldier()));
- commander.accept(new SoldierVisitor());
- commander.accept(new SergeantVisitor());
- commander.accept(new CommanderVisitor());
-
- }
-}
+package com.iluwatar.visitor;
+
+/**
+ *
+ * Visitor pattern defines mechanism to apply operations on nodes
+ * in hierarchy. New operations can be added without altering the node
+ * interface.
+ *
+ * In this example there is a unit hierarchy beginning from {@link Commander}.
+ * This hierarchy is traversed by visitors. {@link SoldierVisitor} applies
+ * its operation on {@link Soldier}s, {@link SergeantVisitor} on {@link Sergeant}s and so
+ * on.
+ *
+ */
+public class App {
+
+ /**
+ * Program entry point
+ * @param args command line args
+ */
+ public static void main(String[] args) {
+
+ Commander commander = new Commander(new Sergeant(new Soldier(),
+ new Soldier(), new Soldier()), new Sergeant(new Soldier(),
+ new Soldier(), new Soldier()));
+ commander.accept(new SoldierVisitor());
+ commander.accept(new SergeantVisitor());
+ commander.accept(new CommanderVisitor());
+
+ }
+}
diff --git a/visitor/src/test/java/com/iluwatar/visitor/AppTest.java b/visitor/src/test/java/com/iluwatar/visitor/AppTest.java
index 5ba48c6c9..66db8c2e3 100644
--- a/visitor/src/test/java/com/iluwatar/visitor/AppTest.java
+++ b/visitor/src/test/java/com/iluwatar/visitor/AppTest.java
@@ -1,14 +1,19 @@
-package com.iluwatar.visitor;
-
-import org.junit.Test;
-
-import com.iluwatar.visitor.App;
-
-public class AppTest {
-
- @Test
- public void test() {
- String[] args = {};
- App.main(args);
- }
-}
+package com.iluwatar.visitor;
+
+import org.junit.Test;
+
+import com.iluwatar.visitor.App;
+
+/**
+ *
+ * Application test
+ *
+ */
+public class AppTest {
+
+ @Test
+ public void test() {
+ String[] args = {};
+ App.main(args);
+ }
+}
CakeDao, CakeToppingDao and
* CakeLayerDao. The repositories can be used for CRUD operations on cakes, cake toppings
* and cake layers respectively.
- * CakeBakingService offers
* methods to retrieve available cake toppings and cake layers and baked cakes. Also the
* service is used to create new cakes out of cake toppings and cake layers.
- * CakeInfo, CakeToppingInfo, CakeLayerInfo)
* and returns them instead. This way the presentation layer does not have any knowledge of
* other layers than the business layer and thus is not affected by changes to them.
- *
+ * @param , O extends Observer, A> {
void update(S subject, A argument);
diff --git a/observer/src/main/java/com/iluwatar/observer/generic/Race.java b/observer/src/main/java/com/iluwatar/observer/generic/Race.java
index 358b27758..ddc3337cb 100644
--- a/observer/src/main/java/com/iluwatar/observer/generic/Race.java
+++ b/observer/src/main/java/com/iluwatar/observer/generic/Race.java
@@ -2,5 +2,10 @@ package com.iluwatar.observer.generic;
import com.iluwatar.observer.WeatherType;
+/**
+ *
+ * Race
+ *
+ */
public interface Race extends Observer
* public static LazyLoadedIvoryTower getInstance()
+ *
* public synchronized static LazyLoadedIvoryTower getInstance()
+ *