package xdean.jex.extra;

import java.util.function.Supplier;

public class LazyValue<T> {
  private final Supplier<T> creater;
  private T value = null;
  private boolean calculated = false;

  public LazyValue(Supplier<T> supplier) {
    creater = supplier;
  }

  public synchronized T get() {
    if (calculated == false) {
      value = creater.get();
      calculated = true;
    }
    return value;
  }
}

@@ -93,46 +93,121 @@
  %7B%0D%0A
+%0D%0A
   p
-rivate final Supplier%3CT%3E creat
+ublic static %3CT%3E LazyValue%3CT%3E create(Supplier%3CT%3E supplier) %7B%0D%0A    return new LazyValue%3C%3E(suppli
 er
+)
 ;%0D%0A
+  %7D%0D%0A%0D%0A
   pr
@@ -216,22 +216,27 @@
 ate 
-T value = null
+Supplier%3CT%3E creater
 ;%0D%0A 
@@ -273,26 +273,54 @@
 false;%0D%0A
-%0D%0A  public
+  private T value = null;%0D%0A%0D%0A  private
  LazyVal
@@ -388,16 +388,65 @@
  public 
+T get() %7B%0D%0A    if (calculated == false) %7B%0D%0A      
 synchron
@@ -450,22 +450,21 @@
 ronized 
-T get(
+(this
 ) %7B%0D%0A   
@@ -456,32 +456,36 @@
 d (this) %7B%0D%0A    
+ 
+   
 if (calculated =
@@ -502,16 +502,20 @@
 %0D%0A      
+    
 value = 
@@ -530,16 +530,47 @@
 get();%0D%0A
+          creater = null;%0D%0A    
       ca
@@ -587,16 +587,36 @@
  true;%0D%0A
+        %7D%0D%0A      %7D%0D%0A
     %7D%0D%0A 

update LazyValue