X Tutup
Skip to content

Commit d0c3278

Browse files
committed
Added code comments for Multiton.
1 parent f245769 commit d0c3278

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

multiton/src/main/java/com/iluwatar/App.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
package com.iluwatar;
22

3+
/**
4+
*
5+
* Whereas Singleton design pattern introduces single globally
6+
* accessible object the Multiton pattern defines many globally
7+
* accessible objects. The client asks for the correct instance
8+
* from the Multiton by passing an enumeration as parameter.
9+
*
10+
* In this example Nazgul is the Multiton and we can ask single
11+
* Nazgul from it using NazgulName. The Nazguls are statically
12+
* initialized and stored in concurrent hash map.
13+
*
14+
*/
315
public class App {
416

517
public static void main( String[] args ) {

multiton/src/main/java/com/iluwatar/Nazgul.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
import java.util.Map;
44
import java.util.concurrent.ConcurrentHashMap;
55

6+
/**
7+
*
8+
* Nazgul is a Multiton class. Nazgul instances can be queried
9+
* using getInstance() method.
10+
*
11+
*/
612
public class Nazgul {
713

814
private static Map<NazgulName, Nazgul> nazguls;

multiton/src/main/java/com/iluwatar/NazgulName.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
package com.iluwatar;
22

3+
/**
4+
*
5+
* Each Nazgul has different NazgulName.
6+
*
7+
*/
38
public enum NazgulName {
49

510
KHAMUL, MURAZOR, DWAR, JI_INDUR, AKHORAHIL, HOARMURATH, ADUNAPHEL, REN, UVATHA;

0 commit comments

Comments
 (0)
X Tutup