2626import  java .util .Optional ;
2727import  java .util .function .Consumer ;
2828import  java .util .stream .Collectors ;
29+ import  org .jspecify .annotations .NullMarked ;
30+ import  org .jspecify .annotations .Nullable ;
2931
3032/** 
3133 * Configuration parameters for using proxies in WebDriver. Generally you should pass an object of 
3436 * configuration. That is, it is an error to set an <code>httpProxy</code> manually and then turn on 
3537 * proxy autodetect. 
3638 */ 
39+ @ NullMarked 
3740public  class  Proxy  {
3841
3942  public  enum  ProxyType  {
@@ -77,15 +80,15 @@ public String toString() {
7780
7881  private  ProxyType  proxyType  = ProxyType .UNSPECIFIED ;
7982  private  boolean  autodetect  = false ;
80-   private  String  ftpProxy ;
81-   private  String  httpProxy ;
82-   private  String  noProxy ;
83-   private  String  sslProxy ;
84-   private  String  socksProxy ;
85-   private  Integer  socksVersion ;
86-   private  String  socksUsername ;
87-   private  String  socksPassword ;
88-   private  String  proxyAutoconfigUrl ;
83+   private  @ Nullable   String  ftpProxy ;
84+   private  @ Nullable   String  httpProxy ;
85+   private  @ Nullable   String  noProxy ;
86+   private  @ Nullable   String  sslProxy ;
87+   private  @ Nullable   String  socksProxy ;
88+   private  @ Nullable   Integer  socksVersion ;
89+   private  @ Nullable   String  socksUsername ;
90+   private  @ Nullable   String  socksPassword ;
91+   private  @ Nullable   String  proxyAutoconfigUrl ;
8992
9093  public  Proxy () {
9194    // Empty default constructor 
@@ -120,7 +123,7 @@ public Proxy(Map<String, ?> raw) {
120123    setters .put (AUTODETECT , value  -> setAutodetect ((Boolean ) value ));
121124    raw .forEach (
122125        (key , value ) -> {
123-           if  (key  != null  && value  != null ) {
126+           if  (key  != null  && value  != null  &&  setters . containsKey ( key ) ) {
124127            setters .get (key ).accept (value );
125128          }
126129        });
@@ -223,7 +226,7 @@ public Proxy setAutodetect(boolean autodetect) {
223226   * 
224227   * @return the FTP proxy hostname if present, or null if not set 
225228   */ 
226-   public  String  getFtpProxy () {
229+   public  @ Nullable   String  getFtpProxy () {
227230    return  ftpProxy ;
228231  }
229232
@@ -245,7 +248,7 @@ public Proxy setFtpProxy(String ftpProxy) {
245248   * 
246249   * @return the HTTP proxy hostname if present, or null if not set 
247250   */ 
248-   public  String  getHttpProxy () {
251+   public  @ Nullable   String  getHttpProxy () {
249252    return  httpProxy ;
250253  }
251254
@@ -267,7 +270,7 @@ public Proxy setHttpProxy(String httpProxy) {
267270   * 
268271   * @return The proxy bypass (noproxy) addresses 
269272   */ 
270-   public  String  getNoProxy () {
273+   public  @ Nullable   String  getNoProxy () {
271274    return  noProxy ;
272275  }
273276
@@ -289,7 +292,7 @@ public Proxy setNoProxy(String noProxy) {
289292   * 
290293   * @return the SSL tunnel proxy hostname if present, null otherwise 
291294   */ 
292-   public  String  getSslProxy () {
295+   public  @ Nullable   String  getSslProxy () {
293296    return  sslProxy ;
294297  }
295298
@@ -311,7 +314,7 @@ public Proxy setSslProxy(String sslProxy) {
311314   * 
312315   * @return the SOCKS proxy if present, null otherwise 
313316   */ 
314-   public  String  getSocksProxy () {
317+   public  @ Nullable   String  getSocksProxy () {
315318    return  socksProxy ;
316319  }
317320
@@ -333,7 +336,7 @@ public Proxy setSocksProxy(String socksProxy) {
333336   * 
334337   * @return the SOCKS version if present, null otherwise 
335338   */ 
336-   public  Integer  getSocksVersion () {
339+   public  @ Nullable   Integer  getSocksVersion () {
337340    return  socksVersion ;
338341  }
339342
@@ -355,7 +358,7 @@ public Proxy setSocksVersion(Integer socksVersion) {
355358   * 
356359   * @return the SOCKS proxy's username 
357360   */ 
358-   public  String  getSocksUsername () {
361+   public  @ Nullable   String  getSocksUsername () {
359362    return  socksUsername ;
360363  }
361364
@@ -377,7 +380,7 @@ public Proxy setSocksUsername(String username) {
377380   * 
378381   * @return the SOCKS proxy's password 
379382   */ 
380-   public  String  getSocksPassword () {
383+   public  @ Nullable   String  getSocksPassword () {
381384    return  socksPassword ;
382385  }
383386
@@ -399,7 +402,7 @@ public Proxy setSocksPassword(String password) {
399402   * 
400403   * @return the proxy auto-configuration URL 
401404   */ 
402-   public  String  getProxyAutoconfigUrl () {
405+   public  @ Nullable   String  getProxyAutoconfigUrl () {
403406    return  proxyAutoconfigUrl ;
404407  }
405408
@@ -428,7 +431,7 @@ private void verifyProxyTypeCompatibility(ProxyType compatibleProxy) {
428431  }
429432
430433  @ SuppressWarnings ({"unchecked" })
431-   public  static  Proxy  extractFrom (Capabilities  capabilities ) {
434+   public  static  @ Nullable   Proxy  extractFrom (Capabilities  capabilities ) {
432435    Object  rawProxy  = capabilities .getCapability ("proxy" );
433436    Proxy  proxy  = null ;
434437    if  (rawProxy  != null ) {
@@ -472,7 +475,7 @@ public String toString() {
472475  }
473476
474477  @ Override 
475-   public  boolean  equals (Object  o ) {
478+   public  boolean  equals (@ Nullable   Object  o ) {
476479    if  (this  == o ) {
477480      return  true ;
478481    }
0 commit comments