docs: update multiton

This commit is contained in:
Ilkka Seppälä
2024-05-09 13:42:25 +03:00
parent de1dd7f82a
commit 6cc4525bc1
3 changed files with 63 additions and 66 deletions
@@ -32,7 +32,7 @@ import lombok.extern.slf4j.Slf4j;
* the Multiton by passing an enumeration as a parameter.
*
* <p>There is more than one way to implement the multiton design pattern. In the first example
* {@link Nazgul} is the Multiton and we can ask single {@link Nazgul} from it using {@link
* {@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 a concurrent hash map.
*
* <p>In the enum implementation {@link NazgulEnum} is the multiton. It is static and mutable
@@ -26,6 +26,7 @@ package com.iluwatar.multiton;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import lombok.Getter;
/**
* Nazgul is a Multiton class. Nazgul instances can be queried using {@link #getInstance} method.
@@ -34,6 +35,7 @@ public final class Nazgul {
private static final Map<NazgulName, Nazgul> nazguls;
@Getter
private final NazgulName name;
static {
@@ -56,8 +58,4 @@ public final class Nazgul {
public static Nazgul getInstance(NazgulName name) {
return nazguls.get(name);
}
public NazgulName getName() {
return name;
}
}