Class MultiBackgroundInitializer.MultiBackgroundInitializerResults
- java.lang.Object
-
- org.apache.commons.lang3.concurrent.MultiBackgroundInitializer.MultiBackgroundInitializerResults
-
- Enclosing class:
- MultiBackgroundInitializer
public static class MultiBackgroundInitializer.MultiBackgroundInitializerResults extends java.lang.ObjectA data class for storing the results of the background initialization performed byMultiBackgroundInitializer. Objects of this inner class are returned byMultiBackgroundInitializer.initialize(). They allow access to all result objects produced by theBackgroundInitializerobjects managed by the owning instance. It is also possible to retrieve status information about singleBackgroundInitializers, i.e. whether they completed normally or caused an exception.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Map<java.lang.String,ConcurrentException>exceptionsA map with the exceptions.private java.util.Map<java.lang.String,BackgroundInitializer<?>>initializersA map with the child initializers.private java.util.Map<java.lang.String,java.lang.Object>resultObjectsA map with the result objects.
-
Constructor Summary
Constructors Modifier Constructor Description privateMultiBackgroundInitializerResults(java.util.Map<java.lang.String,BackgroundInitializer<?>> inits, java.util.Map<java.lang.String,java.lang.Object> results, java.util.Map<java.lang.String,ConcurrentException> excepts)Creates a new instance ofMultiBackgroundInitializerResultsand initializes it with maps for theBackgroundInitializerobjects, their result objects and the exceptions thrown by them.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private BackgroundInitializer<?>checkName(java.lang.String name)Checks whether an initializer with the given name exists.ConcurrentExceptiongetException(java.lang.String name)Returns theConcurrentExceptionobject that was thrown by theBackgroundInitializerwith the given name.BackgroundInitializer<?>getInitializer(java.lang.String name)Returns theBackgroundInitializerwith the given name.java.lang.ObjectgetResultObject(java.lang.String name)Returns the result object produced by theBackgroundInitializerwith the given name.java.util.Set<java.lang.String>initializerNames()Returns a set with the names of allBackgroundInitializerobjects managed by theMultiBackgroundInitializer.booleanisException(java.lang.String name)Returns a flag whether theBackgroundInitializerwith the given name caused an exception.booleanisSuccessful()Returns a flag whether the whole initialization was successful.
-
-
-
Field Detail
-
initializers
private final java.util.Map<java.lang.String,BackgroundInitializer<?>> initializers
A map with the child initializers.
-
resultObjects
private final java.util.Map<java.lang.String,java.lang.Object> resultObjects
A map with the result objects.
-
exceptions
private final java.util.Map<java.lang.String,ConcurrentException> exceptions
A map with the exceptions.
-
-
Constructor Detail
-
MultiBackgroundInitializerResults
private MultiBackgroundInitializerResults(java.util.Map<java.lang.String,BackgroundInitializer<?>> inits, java.util.Map<java.lang.String,java.lang.Object> results, java.util.Map<java.lang.String,ConcurrentException> excepts)
Creates a new instance ofMultiBackgroundInitializerResultsand initializes it with maps for theBackgroundInitializerobjects, their result objects and the exceptions thrown by them.- Parameters:
inits- theBackgroundInitializerobjectsresults- the result objectsexcepts- the exceptions
-
-
Method Detail
-
getInitializer
public BackgroundInitializer<?> getInitializer(java.lang.String name)
Returns theBackgroundInitializerwith the given name. If the name cannot be resolved, an exception is thrown.- Parameters:
name- the name of theBackgroundInitializer- Returns:
- the
BackgroundInitializerwith this name - Throws:
java.util.NoSuchElementException- if the name cannot be resolved
-
getResultObject
public java.lang.Object getResultObject(java.lang.String name)
Returns the result object produced by theBackgroundInitializerwith the given name. This is the object returned by the initializer'sinitialize()method. If thisBackgroundInitializercaused an exception, null is returned. If the name cannot be resolved, an exception is thrown.- Parameters:
name- the name of theBackgroundInitializer- Returns:
- the result object produced by this
BackgroundInitializer - Throws:
java.util.NoSuchElementException- if the name cannot be resolved
-
isException
public boolean isException(java.lang.String name)
Returns a flag whether theBackgroundInitializerwith the given name caused an exception.- Parameters:
name- the name of theBackgroundInitializer- Returns:
- a flag whether this initializer caused an exception
- Throws:
java.util.NoSuchElementException- if the name cannot be resolved
-
getException
public ConcurrentException getException(java.lang.String name)
Returns theConcurrentExceptionobject that was thrown by theBackgroundInitializerwith the given name. If this initializer did not throw an exception, the return value is null. If the name cannot be resolved, an exception is thrown.- Parameters:
name- the name of theBackgroundInitializer- Returns:
- the exception thrown by this initializer
- Throws:
java.util.NoSuchElementException- if the name cannot be resolved
-
initializerNames
public java.util.Set<java.lang.String> initializerNames()
Returns a set with the names of allBackgroundInitializerobjects managed by theMultiBackgroundInitializer.- Returns:
- an (unmodifiable) set with the names of the managed
BackgroundInitializerobjects
-
isSuccessful
public boolean isSuccessful()
Returns a flag whether the whole initialization was successful. This is the case if no child initializer has thrown an exception.- Returns:
- a flag whether the initialization was successful
-
checkName
private BackgroundInitializer<?> checkName(java.lang.String name)
Checks whether an initializer with the given name exists. If not, throws an exception. If it exists, the associated child initializer is returned.- Parameters:
name- the name to check- Returns:
- the initializer with this name
- Throws:
java.util.NoSuchElementException- if the name is unknown
-
-