Interface ActiveObjectDependency


public interface ActiveObjectDependency
Represents a dependency between active objects.
Author:
Sergey Grachev
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static enum 
    Enumerates the types of relationships that can exist between active objects.
  • Method Summary

    Modifier and Type
    Method
    Description
    Ensures that the object is resolved and returns it.
    Returns the last error message that occurred during the resolution process, or an empty string if no errors have occurred.
    Returns the object if it has already been resolved, or null otherwise.
    Returns the type of dependency relationship.
    void
    ifResolved(java.util.function.Consumer<ActiveObject<?>> action)
    Executes the provided action if and when the object is resolved.
    boolean
    Indicates whether this dependency is optional.
    boolean
    Checks whether the object has been resolved and is available for use.
  • Method Details

    • ensureObject

      ActiveObject<?> ensureObject()
      Ensures that the object is resolved and returns it. Otherwise, this method will throw a NullPointerException if the object is not yet resolved.
      Returns:
      The resolved ActiveObject.
      Throws:
      NullPointerException - if the object has not been resolved yet
    • getObject

      @Nullable ActiveObject<?> getObject()
      Returns the object if it has already been resolved, or null otherwise.
      Returns:
      The resolved ActiveObject, or null if not yet resolved.
    • getLastError

      String getLastError()
      Returns the last error message that occurred during the resolution process, or an empty string if no errors have occurred.
      Returns:
      The last error message, or an empty string if no errors have occurred.
    • getType

      Returns the type of dependency relationship.
      Returns:
      The ActiveObjectDependency.Type of this dependency.
    • ifResolved

      void ifResolved(java.util.function.Consumer<ActiveObject<?>> action)
      Executes the provided action if and when the object is resolved. If the object is already resolved, the action will be executed immediately. Otherwise, it will be queued for execution once resolution occurs.
      Parameters:
      action - The Consumer to execute with the resolved ActiveObject.
    • isOptional

      boolean isOptional()
      Indicates whether this dependency is optional. An optional dependency can be unresolved without causing an error.
      Returns:
      True if this dependency is optional, false otherwise.
    • isResolved

      boolean isResolved()
      Checks whether the object has been resolved and is available for use.
      Returns:
      True if the object is resolved, false otherwise.