Class MultiBackgroundInitializer.MultiBackgroundInitializerResults

java.lang.Object
org.apache.commons.lang3.concurrent.MultiBackgroundInitializer.MultiBackgroundInitializerResults
Enclosing class:
MultiBackgroundInitializer

public static class MultiBackgroundInitializer.MultiBackgroundInitializerResults extends Object
A data class for storing the results of the background initialization performed by MultiBackgroundInitializer. Objects of this inner class are returned by MultiBackgroundInitializer.initialize(). They allow access to all result objects produced by the BackgroundInitializer objects managed by the owning instance. It is also possible to retrieve status information about single BackgroundInitializers, i.e. whether they completed normally or caused an exception.
  • Field Details

  • Constructor Details

    • MultiBackgroundInitializerResults

      private MultiBackgroundInitializerResults(Map<String,BackgroundInitializer<?>> inits, Map<String,Object> results, Map<String,ConcurrentException> excepts)
      Creates a new instance of MultiBackgroundInitializerResults and initializes it with maps for the BackgroundInitializer objects, their result objects and the exceptions thrown by them.
      Parameters:
      inits - the BackgroundInitializer objects
      results - the result objects
      excepts - the exceptions
  • Method Details

    • getInitializer

      public BackgroundInitializer<?> getInitializer(String name)
      Returns the BackgroundInitializer with the given name. If the name cannot be resolved, an exception is thrown.
      Parameters:
      name - the name of the BackgroundInitializer
      Returns:
      the BackgroundInitializer with this name
      Throws:
      NoSuchElementException - if the name cannot be resolved
    • getResultObject

      public Object getResultObject(String name)
      Returns the result object produced by the BackgroundInitializer with the given name. This is the object returned by the initializer's initialize() method. If this BackgroundInitializer caused an exception, null is returned. If the name cannot be resolved, an exception is thrown.
      Parameters:
      name - the name of the BackgroundInitializer
      Returns:
      the result object produced by this BackgroundInitializer
      Throws:
      NoSuchElementException - if the name cannot be resolved
    • isException

      public boolean isException(String name)
      Returns a flag whether the BackgroundInitializer with the given name caused an exception.
      Parameters:
      name - the name of the BackgroundInitializer
      Returns:
      a flag whether this initializer caused an exception
      Throws:
      NoSuchElementException - if the name cannot be resolved
    • getException

      public ConcurrentException getException(String name)
      Returns the ConcurrentException object that was thrown by the BackgroundInitializer with 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 the BackgroundInitializer
      Returns:
      the exception thrown by this initializer
      Throws:
      NoSuchElementException - if the name cannot be resolved
    • initializerNames

      public Set<String> initializerNames()
      Returns a set with the names of all BackgroundInitializer objects managed by the MultiBackgroundInitializer.
      Returns:
      an (unmodifiable) set with the names of the managed BackgroundInitializer objects
    • 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(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:
      NoSuchElementException - if the name is unknown