docs: add lazy loading docs + refactor (#2939)

This commit is contained in:
Ilkka Seppälä
2024-05-06 10:16:02 +03:00
committed by GitHub
parent 7460e46f9c
commit cb1872a7a4
5 changed files with 162 additions and 21 deletions
@@ -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();
}