All Downloads are FREE. Search and download functionalities are using the official Maven repository.

de.team33.patterns.lazy.e1.XLazy Maven / Gradle / Ivy

There is a newer version: 1.13.0
Show newest version
package de.team33.patterns.lazy.e1;

import de.team33.patterns.exceptional.e1.XSupplier;

/**
 * Implements an {@link XSupplier} that provides a virtually fixed value.
 * This value is only actually determined when it is accessed for the first time.
 * 

* This implementation ensures that the {@linkplain #XLazy(XSupplier) originally defined initialization code} * is called at most once, even if there is concurrent access from multiple threads, unless the * initialization attempt causes an exception. *

* Once the value is established, unnecessary effort to synchronize competing accesses is avoided. * * @deprecated Further development is discontinued and this package/module may be removed in a future release. * Successor edition is the module lazy-narvi. */ @Deprecated public class XLazy extends Mutual implements XSupplier { /** * Initializes a new instance giving a supplier that defines the intended initialization of the * represented value. */ public XLazy(final XSupplier initial) { super(initial); } /** * Executes the {@linkplain #XLazy(XSupplier) originally defined initialization code} on the first call and * returns its result on that and every subsequent call without calling the supplier again. */ @Override public final T get() throws X { return backing.get(); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy