mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-05-16 20:59:07 +00:00
docs: add lazy loading docs + refactor (#2939)
This commit is contained in:
@@ -51,13 +51,13 @@ public abstract class AbstractHolderTest {
|
||||
*
|
||||
* @return The lazy loaded {@link Heavy} object
|
||||
*/
|
||||
abstract Heavy getHeavy() throws Exception;
|
||||
abstract Heavy getHeavy();
|
||||
|
||||
/**
|
||||
* This test shows that the heavy field is not instantiated until the method getHeavy is called
|
||||
*/
|
||||
@Test
|
||||
void testGetHeavy() throws Exception {
|
||||
void testGetHeavy() {
|
||||
assertTimeout(ofMillis(3000), () -> {
|
||||
assertNull(getInternalHeavyValue());
|
||||
assertNotNull(getHeavy());
|
||||
|
||||
@@ -24,8 +24,6 @@
|
||||
*/
|
||||
package com.iluwatar.lazy.loading;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
/**
|
||||
* Date: 12/19/15 - 12:05 PM
|
||||
*
|
||||
|
||||
@@ -24,8 +24,6 @@
|
||||
*/
|
||||
package com.iluwatar.lazy.loading;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
/**
|
||||
* Date: 12/19/15 - 12:19 PM
|
||||
*
|
||||
@@ -43,7 +41,7 @@ class HolderThreadSafeTest extends AbstractHolderTest {
|
||||
}
|
||||
|
||||
@Override
|
||||
Heavy getHeavy() throws Exception {
|
||||
Heavy getHeavy() {
|
||||
return this.holder.getHeavy();
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
*/
|
||||
package com.iluwatar.lazy.loading;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
@@ -57,7 +56,7 @@ class Java8HolderTest extends AbstractHolderTest {
|
||||
}
|
||||
|
||||
@Override
|
||||
Heavy getHeavy() throws Exception {
|
||||
Heavy getHeavy() {
|
||||
return holder.getHeavy();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user