java.lang.Object
tech.guilhermekaua.spigotboot.core.context.dependency.injector.InjectionResult

public final class InjectionResult extends Object
Represents the result of a custom injector's resolution attempt.

This class provides a tri-state result to distinguish between:

  • notHandled() - The injector did not handle this injection point
  • handled(Object) - The injector handled the injection and provided a value (which may be null)
This distinction is important because returning null from a custom injector might be intentional, and the injection should not fall back to the default resolution in that case.
  • Method Details

    • notHandled

      @NotNull public static @NotNull InjectionResult notHandled()
      Creates a result indicating that the injector did not handle this injection point.

      When returned, the framework will continue to the next injector or fall back to default resolution.

      Returns:
      a result indicating the injection point was not handled
    • handled

      @NotNull public static @NotNull InjectionResult handled(@Nullable @Nullable Object value)
      Creates a result indicating that the injector handled this injection point.

      The provided value will be used for injection. Note that null is a valid value here; returning handled(null) is different from returning notHandled().

      Parameters:
      value - the resolved value to inject, may be null
      Returns:
      a result indicating the injection point was handled with the given value
    • isHandled

      public boolean isHandled()
      Returns whether this injection point was handled by the custom injector.
      Returns:
      true if handled, false if the framework should try other injectors or default resolution
    • getValue

      @Nullable public @Nullable Object getValue()
      Returns the resolved value if this result was handled.

      This method should only be called after verifying isHandled() returns true.

      Returns:
      the resolved value, may be null even when handled
      Throws:
      IllegalStateException - if called on a not-handled result