-
Notifications
You must be signed in to change notification settings - Fork 295
feat(api): add JSpecify nullability annotations #1970
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,6 +16,7 @@ | |
|
|
||
| package com.microsoft.playwright; | ||
|
|
||
| import org.jspecify.annotations.Nullable; | ||
| import com.microsoft.playwright.options.*; | ||
| import java.nio.file.Path; | ||
| import java.util.*; | ||
|
|
@@ -40,7 +41,7 @@ | |
| * {@code http://localhost:3000/bar.html}</li> | ||
| * </ul> | ||
| */ | ||
| public String baseURL; | ||
| public @Nullable String baseURL; | ||
| /** | ||
| * TLS Client Authentication allows the server to request a client certificate and verify it. | ||
| * | ||
|
|
@@ -58,37 +59,37 @@ | |
| * <p> <strong>NOTE:</strong> When using WebKit on macOS, accessing {@code localhost} will not pick up client certificates. You can make it work by | ||
| * replacing {@code localhost} with {@code local.playwright}. | ||
| */ | ||
| public List<ClientCertificate> clientCertificates; | ||
| public @Nullable List<ClientCertificate> clientCertificates; | ||
| /** | ||
| * An object containing additional HTTP headers to be sent with every request. Defaults to none. | ||
| */ | ||
| public Map<String, String> extraHTTPHeaders; | ||
| public @Nullable Map<String, String> extraHTTPHeaders; | ||
| /** | ||
| * Whether to throw on response codes other than 2xx and 3xx. By default response object is returned for all status codes. | ||
| */ | ||
| public Boolean failOnStatusCode; | ||
| public @Nullable Boolean failOnStatusCode; | ||
| /** | ||
| * Credentials for <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Authentication">HTTP authentication</a>. If | ||
| * no origin is specified, the username and password are sent to any servers upon unauthorized responses. | ||
| * | ||
| * <p> Pass an array to use different credentials for different origins. The first entry that matches the request origin is | ||
| * used, and entries with no origin match any request. | ||
| */ | ||
| public Object httpCredentials; | ||
| public @Nullable Object httpCredentials; | ||
| /** | ||
| * Whether to ignore HTTPS errors when sending network requests. Defaults to {@code false}. | ||
| */ | ||
| public Boolean ignoreHTTPSErrors; | ||
| public @Nullable Boolean ignoreHTTPSErrors; | ||
| /** | ||
| * Maximum number of request redirects that will be followed automatically. An error will be thrown if the number is | ||
| * exceeded. Defaults to {@code 20}. Pass {@code 0} to not follow redirects. This can be overwritten for each request | ||
| * individually. | ||
| */ | ||
| public Integer maxRedirects; | ||
| public @Nullable Integer maxRedirects; | ||
| /** | ||
| * Network proxy settings. | ||
| */ | ||
| public Proxy proxy; | ||
| public @Nullable Proxy proxy; | ||
| /** | ||
| * Populates context with given storage state. This option can be used to initialize context with logged-in information | ||
| * obtained via {@link com.microsoft.playwright.BrowserContext#storageState BrowserContext.storageState()} or {@link | ||
|
|
@@ -97,22 +98,22 @@ | |
| * BrowserContext.storageState()} or {@link com.microsoft.playwright.APIRequestContext#storageState | ||
| * APIRequestContext.storageState()} methods. | ||
| */ | ||
| public String storageState; | ||
| public @Nullable String storageState; | ||
| /** | ||
| * Populates context with given storage state. This option can be used to initialize context with logged-in information | ||
| * obtained via {@link com.microsoft.playwright.BrowserContext#storageState BrowserContext.storageState()}. Path to the | ||
| * file with saved storage state. | ||
| */ | ||
| public Path storageStatePath; | ||
| public @Nullable Path storageStatePath; | ||
| /** | ||
| * Maximum time in milliseconds to wait for the response. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable | ||
| * timeout. | ||
| */ | ||
| public Double timeout; | ||
| public @Nullable Double timeout; | ||
| /** | ||
| * Specific user agent to use in this context. | ||
| */ | ||
| public String userAgent; | ||
| public @Nullable String userAgent; | ||
|
|
||
| /** | ||
| * Methods like {@link com.microsoft.playwright.APIRequestContext#get APIRequestContext.get()} take the base URL into | ||
|
|
@@ -127,7 +128,7 @@ | |
| * {@code http://localhost:3000/bar.html}</li> | ||
| * </ul> | ||
| */ | ||
| public NewContextOptions setBaseURL(String baseURL) { | ||
|
Check warning on line 131 in playwright/src/main/java/com/microsoft/playwright/APIRequest.java
|
||
| this.baseURL = baseURL; | ||
| return this; | ||
| } | ||
|
|
@@ -148,21 +149,21 @@ | |
| * <p> <strong>NOTE:</strong> When using WebKit on macOS, accessing {@code localhost} will not pick up client certificates. You can make it work by | ||
| * replacing {@code localhost} with {@code local.playwright}. | ||
| */ | ||
| public NewContextOptions setClientCertificates(List<ClientCertificate> clientCertificates) { | ||
|
Check warning on line 152 in playwright/src/main/java/com/microsoft/playwright/APIRequest.java
|
||
| this.clientCertificates = clientCertificates; | ||
| return this; | ||
| } | ||
| /** | ||
| * An object containing additional HTTP headers to be sent with every request. Defaults to none. | ||
| */ | ||
| public NewContextOptions setExtraHTTPHeaders(Map<String, String> extraHTTPHeaders) { | ||
|
Check warning on line 159 in playwright/src/main/java/com/microsoft/playwright/APIRequest.java
|
||
| this.extraHTTPHeaders = extraHTTPHeaders; | ||
| return this; | ||
| } | ||
| /** | ||
| * Whether to throw on response codes other than 2xx and 3xx. By default response object is returned for all status codes. | ||
| */ | ||
| public NewContextOptions setFailOnStatusCode(boolean failOnStatusCode) { | ||
|
Check warning on line 166 in playwright/src/main/java/com/microsoft/playwright/APIRequest.java
|
||
| this.failOnStatusCode = failOnStatusCode; | ||
| return this; | ||
| } | ||
|
|
@@ -269,7 +270,7 @@ | |
| * | ||
| * @since v1.16 | ||
| */ | ||
| default APIRequestContext newContext() { | ||
|
Check warning on line 273 in playwright/src/main/java/com/microsoft/playwright/APIRequest.java
|
||
| return newContext(null); | ||
| } | ||
| /** | ||
|
|
@@ -277,6 +278,6 @@ | |
| * | ||
| * @since v1.16 | ||
| */ | ||
| APIRequestContext newContext(NewContextOptions options); | ||
| APIRequestContext newContext(@Nullable NewContextOptions options); | ||
|
Check warning on line 281 in playwright/src/main/java/com/microsoft/playwright/APIRequest.java
|
||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume this is a test-only null check setup? Otherwise, seems very involved for production pom.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this is for tests only: