Skip to content

Commit

Permalink
added lazy methods javadoc examples
Browse files Browse the repository at this point in the history
  • Loading branch information
evpl committed Mar 10, 2024
1 parent b4dda2f commit e479d2a
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/main/java/com/plugatar/jkscope/JKScope.java
Original file line number Diff line number Diff line change
Expand Up @@ -818,6 +818,13 @@ static <V> Opt<V> optNonNull(final V value) {
* Returns a new {@link Lazy} instance that uses the specified initialization function and the
* {@link Lazy.ThreadSafetyMode#SYNCHRONIZED} thread-safety mode. The returned instance uses itself to synchronize
* on.
* <pre>{@code
* Lazy<String> lazy = lazy(() -> {
* //...
* return "value";
* });
* String value = lazy.get();
* }</pre>
*
* @param initializer the value initializer
* @param <V> the type of the value
Expand All @@ -832,6 +839,13 @@ static <V> Lazy<V> lazy(final ThSupplier<? extends V, ?> initializer) {
* Returns a new {@link Lazy} instance that uses the specified initialization function and the
* {@link Lazy.ThreadSafetyMode#SYNCHRONIZED} thread-safety mode. The returned instance uses the specified lock object
* to synchronize on.
* <pre>{@code
* Lazy<String> lazy = lazy(new Object(), () -> {
* //...
* return "value";
* });
* String value = lazy.get();
* }</pre>
*
* @param lock the lock object
* @param initializer the value initializer
Expand All @@ -847,6 +861,13 @@ static <V> Lazy<V> lazy(final Object lock,
/**
* Returns a new {@link Lazy} instance that uses the specified initialization function and thread-safety mode. For
* {@link Lazy.ThreadSafetyMode#SYNCHRONIZED} the returned instance uses itself to synchronize on.
* <pre>{@code
* Lazy<String> lazy = lazy(Lazy.ThreadSafetyMode.NONE, () -> {
* //...
* return "value";
* });
* String value = lazy.get();
* }</pre>
*
* @param threadSafetyMode the thread safety mode
* @param initializer the value initializer
Expand All @@ -861,6 +882,10 @@ static <V> Lazy<V> lazy(final Lazy.ThreadSafetyMode threadSafetyMode,

/**
* Returns a new {@link Lazy} instance that is already initialized with the specified value.
* <pre>{@code
* Lazy<String> lazy = lazyOfValue("value");
* String value = lazy.get();
* }</pre>
*
* @param value the value
* @param <V> the type of the value
Expand Down

0 comments on commit e479d2a

Please sign in to comment.