Compare commits
10 Commits
all-contri
...
all-contri
Author | SHA1 | Date | |
---|---|---|---|
07744e1fa4 | |||
fb1a0c5d7c | |||
57f9c2e968 | |||
42eb7950ae | |||
be72a96cd6 | |||
be25c0b433 | |||
be59e50205 | |||
ec90320eda | |||
3126ad3106 | |||
e2ebb59fe7 |
@ -1568,6 +1568,42 @@
|
||||
"contributions": [
|
||||
"code"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "karthikbhat13",
|
||||
"name": "karthikbhat13",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/22431014?v=4",
|
||||
"profile": "https://github.com/karthikbhat13",
|
||||
"contributions": [
|
||||
"code"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "mortezaadi",
|
||||
"name": "Morteza Adigozalpour",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/1329687?v=4",
|
||||
"profile": "https://github.com/mortezaadi",
|
||||
"contributions": [
|
||||
"code"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "tan31989",
|
||||
"name": "Nagaraj Tantri",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/3784194?v=4",
|
||||
"profile": "https://stackoverflow.com/users/308565/nagaraj-tantri",
|
||||
"contributions": [
|
||||
"code"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "frascu",
|
||||
"name": "Francesco Scuccimarri",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/7107651?v=4",
|
||||
"profile": "http://scuccimarri.it",
|
||||
"contributions": [
|
||||
"code"
|
||||
]
|
||||
}
|
||||
],
|
||||
"contributorsPerLine": 4,
|
||||
|
10
README.md
10
README.md
@ -10,12 +10,12 @@
|
||||
[](https://sonarcloud.io/dashboard?id=iluwatar_java-design-patterns)
|
||||
[](https://gitter.im/iluwatar/java-design-patterns?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
||||
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
|
||||
[](#contributors-)
|
||||
[](#contributors-)
|
||||
<!-- ALL-CONTRIBUTORS-BADGE:END -->
|
||||
|
||||
<br/>
|
||||
|
||||
Read in different language : [**zh**](/localization/zh/README.md), [**ko**](/localization/ko/README.md), [**fr**](/localization/fr/README.md), [**tr**](/localization/tr/README.md), [**ar**](/localization/ar/README.md), [**es**](/localization/es/README.md), [**pt**](/localization/pt/README.md)
|
||||
Read in different language : [**zh**](localization/zh/README.md), [**ko**](localization/ko/README.md), [**fr**](localization/fr/README.md), [**tr**](localization/tr/README.md), [**ar**](localization/ar/README.md), [**es**](localization/es/README.md), [**pt**](localization/pt/README.md)
|
||||
|
||||
<br/>
|
||||
|
||||
@ -333,6 +333,12 @@ This project is licensed under the terms of the MIT license.
|
||||
<td align="center"><a href="https://github.com/marlo2222"><img src="https://avatars.githubusercontent.com/u/40809563?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Marlo Henrique</b></sub></a><br /><a href="#translation-marlo2222" title="Translation">🌍</a></td>
|
||||
<td align="center"><a href="https://github.com/AndriyPyzh"><img src="https://avatars.githubusercontent.com/u/57706635?v=4?s=100" width="100px;" alt=""/><br /><sub><b>AndriyPyzh</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=AndriyPyzh" title="Code">💻</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center"><a href="https://github.com/karthikbhat13"><img src="https://avatars.githubusercontent.com/u/22431014?v=4?s=100" width="100px;" alt=""/><br /><sub><b>karthikbhat13</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=karthikbhat13" title="Code">💻</a></td>
|
||||
<td align="center"><a href="https://github.com/mortezaadi"><img src="https://avatars.githubusercontent.com/u/1329687?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Morteza Adigozalpour</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=mortezaadi" title="Code">💻</a></td>
|
||||
<td align="center"><a href="https://stackoverflow.com/users/308565/nagaraj-tantri"><img src="https://avatars.githubusercontent.com/u/3784194?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Nagaraj Tantri</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=tan31989" title="Code">💻</a></td>
|
||||
<td align="center"><a href="http://scuccimarri.it"><img src="https://avatars.githubusercontent.com/u/7107651?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Francesco Scuccimarri</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=frascu" title="Code">💻</a></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<!-- markdownlint-restore -->
|
||||
|
@ -123,4 +123,4 @@ Now, we can create multiple creatures such as Orcs, tell them to eat and roam an
|
||||
|
||||
## Class diagram
|
||||
|
||||

|
||||

|
||||
|
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 19 KiB |
@ -48,7 +48,7 @@ class AggregatorTest {
|
||||
|
||||
@BeforeEach
|
||||
public void setup() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
MockitoAnnotations.openMocks(this);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -48,7 +48,7 @@ class ApiGatewayTest {
|
||||
|
||||
@BeforeEach
|
||||
public void setup() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
MockitoAnnotations.openMocks(this);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -68,7 +68,7 @@ class ThreadAsyncExecutorTest {
|
||||
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
MockitoAnnotations.openMocks(this);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,4 +1,4 @@
|
||||
---
|
||||
---
|
||||
layout: pattern
|
||||
title: Command
|
||||
folder: command
|
||||
|
@ -25,4 +25,4 @@ We need a mechanism in place which can handle these kinds of situations. We have
|
||||
|
||||
## Credits
|
||||
|
||||
* [https://www.grahamlea.com/2016/08/distributed-transactions-microservices-icebergs/]
|
||||
* [Distributed Transactions: The Icebergs of Microservices](https://www.grahamlea.com/2016/08/distributed-transactions-microservices-icebergs/)
|
||||
|
@ -46,7 +46,7 @@ class DataBusTest {
|
||||
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
MockitoAnnotations.openMocks(this);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -103,4 +103,4 @@ Use the Dependency Injection pattern when:
|
||||
* [Dependency Injection Principles, Practices, and Patterns](https://www.amazon.com/gp/product/161729473X/ref=as_li_qf_asin_il_tl?ie=UTF8&tag=javadesignpat-20&creative=9325&linkCode=as2&creativeASIN=161729473X&linkId=57079257a5c7d33755493802f3b884bd)
|
||||
* [Clean Code: A Handbook of Agile Software Craftsmanship](https://www.amazon.com/gp/product/0132350882/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=0132350882&linkCode=as2&tag=javadesignpat-20&linkId=2c390d89cc9e61c01b9e7005c7842871)
|
||||
* [Java 9 Dependency Injection: Write loosely coupled code with Spring 5 and Guice](https://www.amazon.com/gp/product/1788296257/ref=as_li_tl?ie=UTF8&tag=javadesignpat-20&camp=1789&creative=9325&linkCode=as2&creativeASIN=1788296257&linkId=4e9137a3bf722a8b5b156cce1eec0fc1)
|
||||
* [Google Guice Tutorial: Open source Java based dependency injection framework](https://www.amazon.com/gp/product/B083P7DZ8M/ref=as_li_tl?ie=UTF8&tag=javadesignpat-20&camp=1789&creative=9325&linkCode=as2&creativeASIN=B083P7DZ8M&linkId=04f0f902c877921e45215b624a124bfe)
|
||||
* [Google Guice: Agile Lightweight Dependency Injection Framework](https://www.amazon.com/gp/product/1590599977/ref=as_li_qf_asin_il_tl?ie=UTF8&tag=javadesignpat-20&creative=9325&linkCode=as2&creativeASIN=1590599977&linkId=3b10c90b7ba480a1b7777ff38000f956)
|
||||
|
@ -24,7 +24,6 @@ Use an Event-driven architecture when
|
||||
|
||||
## Real world examples
|
||||
|
||||
* SendGrid, an email API, sends events whenever an email is processed, delivered, opened etc... (https://sendgrid.com/docs/API_Reference/Webhooks/event.html)
|
||||
* Chargify, a billing API, exposes payment activity through various events (https://docs.chargify.com/api-events)
|
||||
* Amazon's AWS Lambda, lets you execute code in response to events such as changes to Amazon S3 buckets, updates to an Amazon DynamoDB table, or custom events generated by your applications or devices. (https://aws.amazon.com/lambda)
|
||||
* MySQL runs triggers based on events such as inserts and update events happening on database tables.
|
||||
@ -32,6 +31,6 @@ Use an Event-driven architecture when
|
||||
## Credits
|
||||
|
||||
* [Event-driven architecture - Wikipedia](https://en.wikipedia.org/wiki/Event-driven_architecture)
|
||||
* [Fundamental Components of an Event-Driven Architecture](http://giocc.com/fundamental-components-of-an-event-driven-architecture.html)
|
||||
* [What is an Event-Driven Architecture](https://aws.amazon.com/event-driven-architecture/)
|
||||
* [Real World Applications/Event Driven Applications](https://wiki.haskell.org/Real_World_Applications/Event_Driven_Applications)
|
||||
* [Event-driven architecture definition](http://searchsoa.techtarget.com/definition/event-driven-architecture)
|
||||
|
@ -30,7 +30,7 @@ Use Half-Sync/Half-Async pattern when
|
||||
|
||||
* [BSD Unix networking subsystem](https://www.dre.vanderbilt.edu/~schmidt/PDF/PLoP-95.pdf)
|
||||
* [Real Time CORBA](http://www.omg.org/news/meetings/workshops/presentations/realtime2001/4-3_Pyarali_thread-pool.pdf)
|
||||
* [Android AsyncTask framework](http://developer.android.com/reference/android/os/AsyncTask.html)
|
||||
* [Android AsyncTask framework](https://developer.android.com/reference/android/os/AsyncTask)
|
||||
|
||||
## Credits
|
||||
|
||||
|
@ -48,7 +48,7 @@ que lorsqu’ils sont nécessaires pour une extensibilité pratique.
|
||||
|
||||
Une fois que vous êtes familiarisé avec ces concepts, vous pouvez commencer à explorer les
|
||||
[modèles de conception disponibles](https://java-design-patterns.com/patterns/)
|
||||
par n’importe laquelle les approches suivantes :
|
||||
par n’importe laquelle des approches suivantes :
|
||||
|
||||
- Recherchez un modèle spécifique par son nom.
|
||||
Vous n’en trouvez pas ? Veuillez signaler un nouveau modèle [ici](https://github.com/iluwatar/java-design-patterns/issues).
|
||||
|
@ -163,7 +163,7 @@ public class LambdaStrategy {
|
||||
|
||||
## 클래스 다이어그램
|
||||
|
||||

|
||||

|
||||
|
||||
## 적용 가능성
|
||||
|
||||
|
@ -122,4 +122,4 @@ public class Orc extends ActiveCreature {
|
||||
|
||||
## 类图
|
||||
|
||||

|
||||

|
||||
|
@ -139,7 +139,7 @@ king.makeRequest(new Request(RequestType.COLLECT_TAX, "collect tax")); // Orc so
|
||||
```
|
||||
|
||||
## 类图
|
||||

|
||||

|
||||
|
||||
## 适用性
|
||||
使用责任链模式当
|
||||
|
@ -28,5 +28,5 @@ In this pattern, parallel processing is performed using a system consisting of a
|
||||
|
||||
## Credits
|
||||
|
||||
* [https://docs.gigaspaces.com/sbp/master-worker-pattern.html]
|
||||
* [http://www.cs.sjsu.edu/~pearce/oom/patterns/behavioral/masterslave.htm]
|
||||
* [Master-Worker Pattern](https://docs.gigaspaces.com/sbp/master-worker-pattern.html)
|
||||
* [The Master-Slave Design Pattern](https://www.cs.sjsu.edu/~pearce/oom/patterns/behavioral/masterslave.htm)
|
||||
|
@ -118,7 +118,7 @@ To deploy the example, go to model-view-viewmodel folder and run:
|
||||
|
||||
* [Zkoss Demo](https://www.zkoss.org/zkdemo/getting_started/mvvm)
|
||||
* [Learn MVVM](https://www.learnmvvm.com/)
|
||||
* [Android Developer CodeLabs](https://codelabs.developers.google.com/codelabs/android-databinding)
|
||||
* [Data Binding in Android](https://developer.android.com/codelabs/android-databinding#0)
|
||||
|
||||
## Typical Use Case
|
||||
|
||||
|
@ -114,7 +114,7 @@ the [Single Responsibility Principle (SRP)](https://java-design-patterns.com/pri
|
||||
|
||||
## Related patterns
|
||||
|
||||
* [Chain of Responsibility](https://java-design-patterns.com/patterns/chain/)
|
||||
* [Chain of Responsibility](https://java-design-patterns.com/patterns/chain-of-responsibility/)
|
||||
|
||||
## Credits
|
||||
|
||||
|
6
pom.xml
6
pom.xml
@ -62,7 +62,7 @@
|
||||
<slf4j.version>1.7.30</slf4j.version>
|
||||
<logback.version>1.2.3</logback.version>
|
||||
<aws-lambda-core.version>1.1.0</aws-lambda-core.version>
|
||||
<aws-java-sdk-dynamodb.version>1.11.289</aws-java-sdk-dynamodb.version>
|
||||
<aws-java-sdk-dynamodb.version>1.12.13</aws-java-sdk-dynamodb.version>
|
||||
<aws-lambda-java-events.version>2.0.1</aws-lambda-java-events.version>
|
||||
<jackson.version>2.12.3</jackson.version>
|
||||
<jaxb-api.version>2.3.1</jaxb-api.version>
|
||||
@ -71,8 +71,8 @@
|
||||
<system-lambda.version>1.1.0</system-lambda.version>
|
||||
<urm.version>2.0.0</urm.version>
|
||||
<mockito-junit-jupiter.version>3.5.0</mockito-junit-jupiter.version>
|
||||
<lombok.version>1.18.14</lombok.version>
|
||||
<byte-buddy.version>1.10.21</byte-buddy.version>
|
||||
<lombok.version>1.18.20</lombok.version>
|
||||
<byte-buddy.version>1.11.5</byte-buddy.version>
|
||||
<javassist.version>3.27.0-GA</javassist.version>
|
||||
<maven-surefire-plugin.version>3.0.0-M5</maven-surefire-plugin.version>
|
||||
<maven-checkstyle-plugin.version>3.1.0</maven-checkstyle-plugin.version>
|
||||
|
@ -44,16 +44,6 @@
|
||||
<groupId>com.amazonaws</groupId>
|
||||
<artifactId>aws-java-sdk-dynamodb</artifactId>
|
||||
<version>${aws-java-sdk-dynamodb.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>com.amazonaws</groupId>
|
||||
<artifactId>aws-java-sdk-s3</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>com.amazonaws</groupId>
|
||||
<artifactId>aws-java-sdk-kms</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.amazonaws</groupId>
|
||||
@ -80,15 +70,15 @@
|
||||
<artifactId>junit-jupiter-engine</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<scope>test</scope>
|
||||
<groupId>org.hamcrest</groupId>
|
||||
<artifactId>hamcrest-core</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
@ -23,6 +23,9 @@
|
||||
|
||||
package com.iluwatar.serverless.baas.api;
|
||||
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
@ -32,31 +35,29 @@ import com.amazonaws.services.lambda.runtime.Context;
|
||||
import com.amazonaws.services.lambda.runtime.events.APIGatewayProxyRequestEvent;
|
||||
import com.iluwatar.serverless.baas.model.Person;
|
||||
import java.util.Map;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.runners.MockitoJUnitRunner;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
|
||||
/**
|
||||
* Unit tests for FindPersonApiHandler Created by dheeraj.mummar on 3/5/18.
|
||||
*/
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class FindPersonApiHandlerTest {
|
||||
class FindPersonApiHandlerTest {
|
||||
|
||||
private FindPersonApiHandler findPersonApiHandler;
|
||||
|
||||
@Mock
|
||||
private DynamoDBMapper dynamoDbMapper;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
MockitoAnnotations.openMocks(this);
|
||||
this.findPersonApiHandler = new FindPersonApiHandler();
|
||||
this.findPersonApiHandler.setDynamoDbMapper(dynamoDbMapper);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void handleRequest() {
|
||||
void handleRequest() {
|
||||
findPersonApiHandler.handleRequest(apiGatewayProxyRequestEvent(), mock(Context.class));
|
||||
verify(dynamoDbMapper, times(1)).load(Person.class, "37e7a1fe-3544-473d-b764-18128f02d72d");
|
||||
}
|
||||
|
@ -34,18 +34,18 @@ import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.iluwatar.serverless.baas.model.Address;
|
||||
import com.iluwatar.serverless.baas.model.Person;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.runners.MockitoJUnitRunner;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
|
||||
/**
|
||||
* Unit tests for SavePersonApiHandler Created by dheeraj.mummar on 3/4/18.
|
||||
*/
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class SavePersonApiHandlerTest {
|
||||
class SavePersonApiHandlerTest {
|
||||
|
||||
private SavePersonApiHandler savePersonApiHandler;
|
||||
|
||||
@ -54,31 +54,32 @@ public class SavePersonApiHandlerTest {
|
||||
|
||||
private final ObjectMapper objectMapper = new ObjectMapper();
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
MockitoAnnotations.openMocks(this);
|
||||
this.savePersonApiHandler = new SavePersonApiHandler();
|
||||
this.savePersonApiHandler.setDynamoDbMapper(dynamoDbMapper);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void handleRequestSavePersonSuccessful() throws JsonProcessingException {
|
||||
void handleRequestSavePersonSuccessful() throws JsonProcessingException {
|
||||
var person = newPerson();
|
||||
var body = objectMapper.writeValueAsString(person);
|
||||
var request = apiGatewayProxyRequestEvent(body);
|
||||
var ctx = mock(Context.class);
|
||||
var apiGatewayProxyResponseEvent = this.savePersonApiHandler.handleRequest(request, ctx);
|
||||
verify(dynamoDbMapper, times(1)).save(person);
|
||||
Assert.assertNotNull(apiGatewayProxyResponseEvent);
|
||||
Assert.assertEquals(Integer.valueOf(201), apiGatewayProxyResponseEvent.getStatusCode());
|
||||
assertNotNull(apiGatewayProxyResponseEvent);
|
||||
assertEquals(Integer.valueOf(201), apiGatewayProxyResponseEvent.getStatusCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void handleRequestSavePersonException() {
|
||||
void handleRequestSavePersonException() {
|
||||
var request = apiGatewayProxyRequestEvent("invalid sample request");
|
||||
var ctx = mock(Context.class);
|
||||
var apiGatewayProxyResponseEvent = this.savePersonApiHandler.handleRequest(request, ctx);
|
||||
Assert.assertNotNull(apiGatewayProxyResponseEvent);
|
||||
Assert.assertEquals(Integer.valueOf(400), apiGatewayProxyResponseEvent.getStatusCode());
|
||||
assertNotNull(apiGatewayProxyResponseEvent);
|
||||
assertEquals(Integer.valueOf(400), apiGatewayProxyResponseEvent.getStatusCode());
|
||||
}
|
||||
|
||||
private APIGatewayProxyRequestEvent apiGatewayProxyRequestEvent(String body) {
|
||||
|
@ -36,16 +36,12 @@ public final class ThreadSafeDoubleCheckLocking {
|
||||
|
||||
private static volatile ThreadSafeDoubleCheckLocking instance;
|
||||
|
||||
private static boolean flag = true;
|
||||
|
||||
/**
|
||||
* private constructor to prevent client from instantiating.
|
||||
*/
|
||||
private ThreadSafeDoubleCheckLocking() {
|
||||
// to prevent instantiating by Reflection call
|
||||
if (flag) {
|
||||
flag = false;
|
||||
} else {
|
||||
if (instance != null) {
|
||||
throw new IllegalStateException("Already initialized.");
|
||||
}
|
||||
}
|
||||
|
@ -34,9 +34,7 @@ public final class ThreadSafeLazyLoadedIvoryTower {
|
||||
|
||||
private ThreadSafeLazyLoadedIvoryTower() {
|
||||
// Protect against instantiation via reflection
|
||||
if (instance == null) {
|
||||
instance = this;
|
||||
} else {
|
||||
if (instance != null) {
|
||||
throw new IllegalStateException("Already initialized.");
|
||||
}
|
||||
}
|
||||
|
@ -25,4 +25,4 @@ The Subclass Sandbox pattern is a very simple, common pattern lurking in lots of
|
||||
|
||||
## Credits
|
||||
|
||||
* [Game Programming Patterns - Subclass Sandbox]([http://gameprogrammingpatterns.com/subclass-sandbox.html](http://gameprogrammingpatterns.com/subclass-sandbox.html))
|
||||
* [Game Programming Patterns - Subclass Sandbox](https://gameprogrammingpatterns.com/subclass-sandbox.html)
|
||||
|
Reference in New Issue
Block a user