Class MethodResult.Builder
- Enclosing class:
- MethodResult
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()Builds aMethodResultgiven the set parameters.setReturnValue(@Nullable Value returnValue) Sets the value returned by the analyzed method.setUpdatedInstance(@NotNull ReferenceValue updatedInstance) Set the updated value of the invocation instance after the invocation of the analyzed method.setUpdatedParameters(List<Value> updatedParameters) Set the updated value of the parameters after the invocation of the analyzed method.
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
setReturnValue
Sets the value returned by the analyzed method.Should not be invoked for methods returning void.
- Parameters:
returnValue- the return value of an analyzed method.- Returns:
- the builder.
-
setUpdatedInstance
Set the updated value of the invocation instance after the invocation of the analyzed method.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.
- Parameters:
updatedInstance- the instance updated during the analyzed method's invocation.- Returns:
- the builder.
-
setUpdatedParameters
Set the updated value of the parameters after the invocation of the analyzed method.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.
- Parameters:
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.- Returns:
- the builder.
-
build
Builds aMethodResultgiven the set parameters.- Returns:
- the new
MethodResult.
-