Class EffectResponse
Object
EffectResponse
- Direct Known Subclasses:
EffectResponse.Empty,EffectResponse.Error,EffectResponse.Valid
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.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classRepresents an empty response, which means that the requested change is possible, but not required.static final classRepresents an error response, which means that the requested change is impossible.static final classRepresents a valid response, which means that the requested change is both needed and possible. -
Method Summary
Modifier and TypeMethodDescriptionstatic EffectResponseempty(I18nText description, List<ItemIdentity> affectedItems) Constructs an empty response, which means that the requested change is possible, but not required.static EffectResponseerror(I18nText error, I18nText description, List<ItemIdentity> affectedItems) Constructs an error response, which means that the requested change is impossible.Returns the list ofitem IDsaffected by the change.Returns a human-readable description of the change, phrased as a possibility, e.g.Returns the actual effect, ornullif error or empty.getError()Describes why this effect cannot be applied, e.g.Returns a human-readable description of the change, as if it already happened, e.g.booleanisEmpty()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.booleanisError()Returns whether this response is an error, which means this change cannot be applied.static EffectResponsevalid(Effect effect, I18nText successMessage, I18nText description, List<ItemIdentity> affectedItems) Constructs a valid response, which means that the requested change is both needed and possible.
-
Method Details
-
getEffect
Returns the actual effect, ornullif error or empty. -
getAffectedItems
Returns the list ofitem IDsaffected by the change. Could be empty. -
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
nulleven for error and empty responses. The effect provider is required to produce the best possible description, even for error responses (seeerror(I18nText, I18nText, List)). -
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
nullfor error and empty responses. -
getError
Describes why this effect cannot be applied, e.g. "Issue does not exist or you have no permission to see it." Returnsnullfor 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, seegetSuccessMessage().description- A human-readable description of the change as a possibility, seegetDescription().affectedItems- The list of affected item IDs, seegetAffectedItems().- 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, seegetError().description- A human-readable description of the change as a possibility, seegetDescription(). Note that this description cannot benulleven 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, seegetAffectedItems().- 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, seegetDescription().affectedItems- The list of affected item IDs, seegetAffectedItems().- Returns:
- an empty response.
-