Class InjectionResult
java.lang.Object
tech.guilhermekaua.spigotboot.core.context.dependency.injector.InjectionResult
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 pointhandled(Object)- The injector handled the injection and provided a value (which may be null)
-
Method Summary
Modifier and TypeMethodDescription@Nullable ObjectgetValue()Returns the resolved value if this result was handled.static @NotNull InjectionResultCreates a result indicating that the injector handled this injection point.booleanReturns whether this injection point was handled by the custom injector.static @NotNull InjectionResultCreates a result indicating that the injector did not handle this injection point.
-
Method Details
-
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
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 returningnotHandled().- 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
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
-