Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Javadoc for ArgumentCaptor #3103

Merged
merged 1 commit into from Aug 27, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 4 additions & 7 deletions src/main/java/org/mockito/ArgumentCaptor.java
Expand Up @@ -50,8 +50,7 @@
* Custom argument matchers via {@link ArgumentMatcher} are usually better for stubbing.
*
* <p>
* This utility class <strong>*doesn't do any type checks*</strong>. The generic signatures are only there to avoid casting
* in your code.
* This utility class <strong>will</strong> perform type checking on the generic type (since Mockito 5.0.0).
* <p>
* There is an <strong>annotation</strong> that you might find useful: &#64;{@link Captor}
* <p>
Expand All @@ -68,7 +67,7 @@ public class ArgumentCaptor<T> {

private ArgumentCaptor(Class<? extends T> clazz) {
this.clazz = clazz;
this.capturingMatcher = new CapturingMatcher<T>(clazz);
this.capturingMatcher = new CapturingMatcher<>(clazz);
}

/**
Expand Down Expand Up @@ -138,16 +137,14 @@ public List<T> getAllValues() {
/**
* Build a new <code>ArgumentCaptor</code>.
* <p>
* Note that an <code>ArgumentCaptor</code> <b>*doesn't do any type checks*</b>. It is only there to avoid casting
* in your code. This might however change (type checks could be added) in a
* future major release.
* An <code>ArgumentCaptor</code> will perform type checks (since Mockito 5.0.0).
*
* @param clazz Type matching the parameter to be captured.
* @param <S> Type of clazz
* @param <U> Type of object captured by the newly built ArgumentCaptor
* @return A new ArgumentCaptor
*/
public static <U, S extends U> ArgumentCaptor<U> forClass(Class<S> clazz) {
return new ArgumentCaptor<U>(clazz);
return new ArgumentCaptor<>(clazz);
}
}