public static class MethodResult.Builder
extends java.lang.Object
MethodResult
. A value should be set only if the creator is able to
provide that information.
setReturnValue(Value)
should not be called if the method
returns void or if no return value can be provided (if the method execution fails MethodResult.invalidResult()
should be used instead of the builder). Similarly setUpdatedInstance(ReferenceValue)
and setUpdatedParameters(List)
being used means that there really were side
effects on respectively instance or parameters during the analyzed method invocation; this
methods should not be used if no side effects happen.
Constructor and Description |
---|
Builder() |
Modifier and Type | Method and Description |
---|---|
MethodResult |
build()
Builds a
MethodResult given the set parameters. |
MethodResult.Builder |
setReturnValue(@Nullable Value returnValue)
Sets the value returned by the analyzed method.
|
MethodResult.Builder |
setUpdatedInstance(@NotNull ReferenceValue updatedInstance)
Set the updated value of the invocation instance after the invocation of the analyzed method.
|
MethodResult.Builder |
setUpdatedParameters(java.util.List<Value> updatedParameters)
Set the updated value of the parameters after the invocation of the analyzed method.
|
public MethodResult.Builder setReturnValue(@Nullable @Nullable Value returnValue)
Should not be invoked for methods returning void.
returnValue
- the return value of an analyzed method.public MethodResult.Builder setUpdatedInstance(@NotNull @NotNull ReferenceValue updatedInstance)
Should not be invoked if there were no side effects on the calling instance during the method execution.
Should always be used for setting the result of a constructor's invocation.
The caller should make sure the updated instance to have the same reference identifier of the old instance.
updatedInstance
- the instance updated during the analyzed method's invocation.public MethodResult.Builder setUpdatedParameters(java.util.List<Value> updatedParameters)
Should not be invoked if there were no side effects on the parameters during the method execution.
The caller should make sure the updated parameters to have the same reference identifier of the old ones.
updatedParameters
- the parameters updated during the analyzed method's invocation. The
size of the list should be the same as the number of parameters of the analyzed method
excluded the calling instance (the first parameter is always in position 0 for both
instance and static methods). Each parameter should be null if it was not updated, the
updated value otherwise.public MethodResult build()
MethodResult
given the set parameters.MethodResult
.