Class EffectResponse

Object
EffectResponse
Direct Known Subclasses:
EffectResponse.Empty, EffectResponse.Error, EffectResponse.Valid

@PublicApi public class EffectResponse extends Object
The result of resolving an effect description. This could be a piece of runnable code, an error message, or an "empty" response, indicating that no change is needed.
  • Method Details

    • getEffect

      @Nullable public Effect getEffect()
      Returns the actual effect, or null if error or empty.
    • getAffectedItems

      @NotNull public List<ItemIdentity> getAffectedItems()
      Returns the list of item IDs affected by the change. Could be empty.
    • getDescription

      @NotNull public I18nText getDescription()

      Returns a human-readable description of the change, phrased as a possibility, e.g. "Assign FOO-123 to John Doe".

      This description cannot be null even for error and empty responses. The effect provider is required to produce the best possible description, even for error responses (see error(I18nText, I18nText, List)).

    • getSuccessMessage

      @Nullable public I18nText getSuccessMessage()

      Returns a human-readable description of the change, as if it already happened, e.g. "Assigned FOO-123 to John Doe."

      This description is null for error and empty responses.

    • getError

      @Nullable public I18nText getError()
      Describes why this effect cannot be applied, e.g. "Issue does not exist or you have no permission to see it." Returns null for valid and empty responses.
    • isError

      public boolean isError()
      Returns whether this response is an error, which means this change cannot be applied.
      See Also:
    • isEmpty

      public boolean isEmpty()
      Returns whether this response is empty, which means that there are no errors, but no change is needed, for example, because the item is already in the required state.
    • valid

      @NotNull public static EffectResponse valid(@NotNull Effect effect, @NotNull I18nText successMessage, @NotNull I18nText description, @NotNull List<ItemIdentity> affectedItems)
      Constructs a valid response, which means that the requested change is both needed and possible.
      Parameters:
      effect - The actual runnable code that effects the change.
      successMessage - A human-readable description of the change as if it already happened, see getSuccessMessage().
      description - A human-readable description of the change as a possibility, see getDescription().
      affectedItems - The list of affected item IDs, see getAffectedItems().
      Returns:
      a valid response
    • error

      @NotNull public static EffectResponse error(@NotNull I18nText error, @NotNull I18nText description, @NotNull List<ItemIdentity> affectedItems)
      Constructs an error response, which means that the requested change is impossible.
      Parameters:
      error - The error message describing why this change cannot be applied, see getError().
      description - A human-readable description of the change as a possibility, see getDescription(). Note that this description cannot be null even for error responses. If an item mentioned in the effect description does not exist, the provider is supposed to use its internal identifier (e.g. issue ID) instead of the user-friendly identifier (issue key), but it still must produce a description.
      affectedItems - The list of affected item IDs, see getAffectedItems().
      Returns:
      an error response
    • empty

      @NotNull public static EffectResponse empty(@NotNull I18nText description, @NotNull List<ItemIdentity> affectedItems)
      Constructs an empty response, which means that the requested change is possible, but not required.
      Parameters:
      description - A human-readable description of the change as a possibility, see getDescription().
      affectedItems - The list of affected item IDs, see getAffectedItems().
      Returns:
      an empty response.