Top Description Inners Fields Constructors Methods
org.apache.commons.lang3.concurrent

public abstract Class AbstractConcurrentInitializer<T, E extends Exception>

extends Object
implements ConcurrentInitializer<T>
Class Inheritance
All Implemented Interfaces
org.apache.commons.lang3.concurrent.ConcurrentInitializer, org.apache.commons.lang3.function.FailableSupplier
Known Direct Subclasses
org.apache.commons.lang3.concurrent.AtomicInitializer, org.apache.commons.lang3.concurrent.AtomicSafeInitializer, org.apache.commons.lang3.concurrent.BackgroundInitializer, org.apache.commons.lang3.concurrent.LazyInitializer
Type Parameters
<T>
the type of the object managed by this initializer class.
<E>
The exception type thrown by initialize().
Imports
java.util.Objects, org.apache.commons.lang3.builder.AbstractSupplier, org.apache.commons.lang3.exception.ExceptionUtils, org.apache.commons.lang3.function.FailableConsumer, .FailableSupplier

Abstracts and defines operations for ConcurrentInitializer implementations.
Since
3.14.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
public abstract static class
AbstractConcurrentInitializer.AbstractBuilder<
The type of results supplied by this builder.
I extends AbstractConcurrentInitializer<T, E>
,
The type of the object managed by the initializer class.
T
,
The type of builder.
B extends AbstractConcurrentInitializer.AbstractBuilder<I, T, B, E>
,
The exception type thrown by initialize().
E extends Exception
>

Builds a new instance for subclasses.

Field Summary

Modifier and TypeField and Description
private final FailableConsumer<? super T, ? extends Exception>
closer

Closer consumer called by close().

private final FailableSupplier<? extends T, ? extends Exception>
initializer

Initializer supplier called by initialize().

Constructor Summary

AccessConstructor and Description
public
AbstractConcurrentInitializer()

Constructs a new instance.

pack-priv
AbstractConcurrentInitializer(final FailableSupplier<? extends T, ? extends Exception>
the initializer supplier called by initialize().
initializer
,
final FailableConsumer<? super T, ? extends Exception>
the closer consumer called by close().
closer
)

Constructs a new instance.

Method Summary

Modifier and TypeMethod and Description
public void
close()

Calls the closer with the manager object.

protected abstract E

Returns:

a new exception with the actual type of E, that wraps e.
getTypedException
(Exception
The actual exception that was thrown.
e
)

Gets an Exception with a type of E as defined by a concrete subclass of this class.

protected T

Returns:

the managed data object.
initialize
()

Creates and initializes the object managed by this ConcurrentInitializer.

protected abstract boolean

Returns:

true if all initialization is complete, otherwise false.
isInitialized
()

Tests whether initialization has been completed.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

closerback to summary
private final FailableConsumer<? super T, ? extends Exception> closer

Closer consumer called by close().

initializerback to summary
private final FailableSupplier<? extends T, ? extends Exception> initializer

Initializer supplier called by initialize().

Constructor Detail

AbstractConcurrentInitializerback to summary
public AbstractConcurrentInitializer()

Constructs a new instance.

AbstractConcurrentInitializerback to summary
pack-priv AbstractConcurrentInitializer(final FailableSupplier<? extends T, ? extends Exception> initializer, final FailableConsumer<? super T, ? extends Exception> closer)

Constructs a new instance.

Parameters
initializer:FailableSupplier<? extends T, ? extends Exception>

the initializer supplier called by initialize().

closer:FailableConsumer<? super T, ? extends Exception>

the closer consumer called by close().

Method Detail

closeback to summary
public void close() throws ConcurrentException

Calls the closer with the manager object.

Exceptions
ConcurrentException:
Thrown by the closer.
Since
3.14.0
getTypedExceptionback to summary
protected abstract E getTypedException(Exception e)

Gets an Exception with a type of E as defined by a concrete subclass of this class.

Parameters
e:Exception

The actual exception that was thrown.

Returns:E

a new exception with the actual type of E, that wraps e.

initializeback to summary
protected T initialize() throws E

Creates and initializes the object managed by this ConcurrentInitializer. This method is called by get() when the object is accessed for the first time. An implementation can focus on the creation of the object. No synchronization is needed, as this is already handled by get().

Subclasses and clients that do not provide an initializer are expected to implement this method.

Returns:T

the managed data object.

Annotations
@SuppressWarnings:unchecked
Exceptions
E:
if an error occurs during object creation.
isInitializedback to summary
protected abstract boolean isInitialized()

Tests whether initialization has been completed. If initialization threw an exception this will return false, but it will return true if a subsequent call to initialize completes successfully. If the implementation of ConcurrentInitializer can initialize multiple objects, this will only return true if all objects have been initialized.

Returns:boolean

true if all initialization is complete, otherwise false.

org.apache.commons.lang3.concurrent back to summary

public abstract Class AbstractConcurrentInitializer.AbstractBuilder<I extends AbstractConcurrentInitializer<T, E>, T, B extends AbstractConcurrentInitializer.AbstractBuilder<I, T, B, E>, E extends Exception>

extends AbstractSupplier<I extends AbstractConcurrentInitializer<T, E>, B extends AbstractConcurrentInitializer.AbstractBuilder<I, T, B, E>, E extends Exception>
Class Inheritance
Known Direct Subclasses
org.apache.commons.lang3.concurrent.AtomicInitializer.Builder, org.apache.commons.lang3.concurrent.AtomicSafeInitializer.Builder, org.apache.commons.lang3.concurrent.BackgroundInitializer.Builder, org.apache.commons.lang3.concurrent.LazyInitializer.Builder
Type Parameters
<I>
The type of results supplied by this builder.
<T>
The type of the object managed by the initializer class.
<B>
The type of builder.
<E>
The exception type thrown by initialize().

Builds a new instance for subclasses.

Field Summary

Modifier and TypeField and Description
private FailableConsumer<T, ? extends Exception>
closer

Closer consumer called by close().

private FailableSupplier<T, ? extends Exception>
initializer

Initializer supplier called by initialize().

Constructor Summary

AccessConstructor and Description
public
AbstractBuilder()

Constructs a new instance.

Method Summary

Modifier and TypeMethod and Description
public FailableConsumer<T, ? extends Exception>

Returns:

the closer consumer called by close().
getCloser
()

Gets the closer consumer called by close().

public FailableSupplier<T, ? extends Exception>

Returns:

the initializer supplier called by initialize().
getInitializer
()

Gets the initializer supplier called by initialize().

public B

Returns:

this instance.
setCloser
(final FailableConsumer<T, ? extends Exception>
the consumer called by close().
closer
)

Sets the closer consumer called by close().

public B

Returns:

this instance.
setInitializer
(final FailableSupplier<T, ? extends Exception>
the supplier called by initialize().
initializer
)

Sets the initializer supplier called by initialize().

Inherited from org.apache.commons.lang3.builder.AbstractSupplier:
asThis

Field Detail

closerback to summary
private FailableConsumer<T, ? extends Exception> closer

Closer consumer called by close().

initializerback to summary
private FailableSupplier<T, ? extends Exception> initializer

Initializer supplier called by initialize().

Constructor Detail

AbstractBuilderback to summary
public AbstractBuilder()

Constructs a new instance.

Method Detail

getCloserback to summary
public FailableConsumer<T, ? extends Exception> getCloser()

Gets the closer consumer called by close().

Returns:FailableConsumer<T, ? extends Exception>

the closer consumer called by close().

getInitializerback to summary
public FailableSupplier<T, ? extends Exception> getInitializer()

Gets the initializer supplier called by initialize().

Returns:FailableSupplier<T, ? extends Exception>

the initializer supplier called by initialize().

setCloserback to summary
public B setCloser(final FailableConsumer<T, ? extends Exception> closer)

Sets the closer consumer called by close().

Parameters
closer:FailableConsumer<T, ? extends Exception>

the consumer called by close().

Returns:B

this instance.

setInitializerback to summary
public B setInitializer(final FailableSupplier<T, ? extends Exception> initializer)

Sets the initializer supplier called by initialize().

Parameters
initializer:FailableSupplier<T, ? extends Exception>

the supplier called by initialize().

Returns:B

this instance.