2626/**
2727 * Thread-safe lazy reference.
2828 */
29- public class LazyReference <T > {
29+ public final class LazyReference <T > {
3030
3131 public static <T > LazyReference <T > from (Supplier <T > valueComputation ) {
3232 return new LazyReference <>(valueComputation );
3333 }
3434
35- //FAWE start
36-
3735 /**
3836 * Pre-computed reference, for setting a lazy reference field with a known value.
3937 *
4038 * @param value the value of the reference
41- * @param <T> the type of the value
39+ * @param <T> the type of the value
4240 * @return the new reference
4341 */
4442 public static <T > LazyReference <T > computed (T value ) {
4543 return new LazyReference <>(value );
4644 }
47- //FAWE end
4845
4946 // Memory saving technique: hold the computation info in the same reference field that we'll
5047 // put the value into, so the memory possibly retained by those parts is GC'able as soon as
5148 // it's no longer needed.
5249
5350 private static final class RefInfo <T > {
54-
5551 private final Lock lock = new ReentrantLock ();
5652 private final Supplier <T > valueComputation ;
5753
5854 private RefInfo (Supplier <T > valueComputation ) {
5955 this .valueComputation = valueComputation ;
6056 }
61-
6257 }
6358
6459 private Object value ;
@@ -67,11 +62,9 @@ private LazyReference(Supplier<T> valueComputation) {
6762 this .value = new RefInfo <>(valueComputation );
6863 }
6964
70- //FAWE start
7165 private LazyReference (T value ) {
7266 this .value = value ;
7367 }
74- //FAWE end
7568
7669 // casts are safe, value is either RefInfo or T
7770 @ SuppressWarnings ("unchecked" )
0 commit comments