mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-06-07 12:13:01 +00:00
deps: Refactor dependencies (#3224)
* remove spring dep move junit, logging, mockito under dep mgmt * upgrade anti-corruption-layer deps * async method invocation * balking, bloc * bridge to bytecode * caching * callback - cqrs * component - health check * hexagonal - metadata mapping * rest of the patterns * remove checkstyle, take spotless into use
This commit is contained in:
@@ -28,11 +28,11 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* In Registry pattern, objects of a single class are stored and provide a global point of access to them.
|
||||
* Note that there is no restriction on the number of objects.
|
||||
*
|
||||
* <p> The given example {@link CustomerRegistry} represents the registry used to store and
|
||||
* access {@link Customer} objects. </p>
|
||||
* In Registry pattern, objects of a single class are stored and provide a global point of access to
|
||||
* them. Note that there is no restriction on the number of objects.
|
||||
*
|
||||
* <p>The given example {@link CustomerRegistry} represents the registry used to store and access
|
||||
* {@link Customer} objects.
|
||||
*/
|
||||
public class App {
|
||||
|
||||
@@ -54,5 +54,4 @@ public class App {
|
||||
LOGGER.info("John {}", customerRegistry.getCustomer("1"));
|
||||
LOGGER.info("Julia {}", customerRegistry.getCustomer("2"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -24,16 +24,11 @@
|
||||
*/
|
||||
package com.iluwatar.registry;
|
||||
|
||||
/**
|
||||
* Customer entity used in registry pattern example.
|
||||
*/
|
||||
/** Customer entity used in registry pattern example. */
|
||||
public record Customer(String id, String name) {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Customer{"
|
||||
+ "id='" + id + '\''
|
||||
+ ", name='" + name + '\''
|
||||
+ '}';
|
||||
return "Customer{" + "id='" + id + '\'' + ", name='" + name + '\'' + '}';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,13 +28,10 @@ import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* CustomerRegistry class used to store/access {@link Customer} objects.
|
||||
*/
|
||||
/** CustomerRegistry class used to store/access {@link Customer} objects. */
|
||||
public final class CustomerRegistry {
|
||||
|
||||
@Getter
|
||||
private static final CustomerRegistry instance = new CustomerRegistry();
|
||||
@Getter private static final CustomerRegistry instance = new CustomerRegistry();
|
||||
|
||||
private final Map<String, Customer> customerMap;
|
||||
|
||||
@@ -49,5 +46,4 @@ public final class CustomerRegistry {
|
||||
public Customer getCustomer(String id) {
|
||||
return customerMap.get(id);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -24,13 +24,13 @@
|
||||
*/
|
||||
package com.iluwatar.registry;
|
||||
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class CustomerRegistryTest {
|
||||
|
||||
private static CustomerRegistry customerRegistry;
|
||||
|
||||
Reference in New Issue
Block a user