Skip to main content Link Search Menu Expand Document (external link)

WebClientRules

SUGGESTION

Simplification

View source code on GitHub

Suppression

Disable all rules by adding -XepOpt:Refaster:NamePattern=^(?!(WebClientRules.*)) as compiler argument.

Table of contents
  1. BodyValue
  2. WebClientGet
  3. WebClientHead
  4. WebClientOptions
  5. WebClientPatch
  6. WebClientPost
  7. WebClientPut
  8. RequestHeadersUriSpecUri

BodyValue

SUGGESTION

Simplification

Suppression

Suppress false positives by adding the suppression annotation @SuppressWarnings("BodyValue") to the enclosing element.

Disable this rule by adding -XepOpt:Refaster:NamePattern=^(?!(WebClientRules\.BodyValue)) as compiler argument.

Samples

Shows the difference in example code before and after the Refaster rule is applied.

 ImmutableSet<?> testBodyValue() {
     return ImmutableSet.of(
-        WebClient.create().post().body(fromValue("bar")),
-        WebTestClient.bindToServer().build().post().body(fromValue("bar")));
+        WebClient.create().post().bodyValue("bar"),
+        WebTestClient.bindToServer().build().post().bodyValue("bar"));
   }

WebClientGet

SUGGESTION

Simplification

Suppression

Suppress false positives by adding the suppression annotation @SuppressWarnings("WebClientGet") to the enclosing element.

Disable this rule by adding -XepOpt:Refaster:NamePattern=^(?!(WebClientRules\.WebClientGet)) as compiler argument.

Samples

Shows the difference in example code before and after the Refaster rule is applied.

 ImmutableSet<?> testWebClientGet() {
-    return ImmutableSet.of(
-        WebClient.create().method(GET), WebTestClient.bindToServer().build().method(GET));
+    return ImmutableSet.of(WebClient.create().get(), WebTestClient.bindToServer().build().get());
   }

WebClientHead

SUGGESTION

Simplification

Suppression

Suppress false positives by adding the suppression annotation @SuppressWarnings("WebClientHead") to the enclosing element.

Disable this rule by adding -XepOpt:Refaster:NamePattern=^(?!(WebClientRules\.WebClientHead)) as compiler argument.

Samples

Shows the difference in example code before and after the Refaster rule is applied.

 ImmutableSet<?> testWebClientHead() {
-    return ImmutableSet.of(
-        WebClient.create().method(HEAD), WebTestClient.bindToServer().build().method(HEAD));
+    return ImmutableSet.of(WebClient.create().head(), WebTestClient.bindToServer().build().head());
   }

WebClientOptions

SUGGESTION

Simplification

Suppression

Suppress false positives by adding the suppression annotation @SuppressWarnings("WebClientOptions") to the enclosing element.

Disable this rule by adding -XepOpt:Refaster:NamePattern=^(?!(WebClientRules\.WebClientOptions)) as compiler argument.

Samples

Shows the difference in example code before and after the Refaster rule is applied.

 ImmutableSet<?> testWebClientOptions() {
     return ImmutableSet.of(
-        WebClient.create().method(OPTIONS), WebTestClient.bindToServer().build().method(OPTIONS));
+        WebClient.create().options(), WebTestClient.bindToServer().build().options());
   }

WebClientPatch

SUGGESTION

Simplification

Suppression

Suppress false positives by adding the suppression annotation @SuppressWarnings("WebClientPatch") to the enclosing element.

Disable this rule by adding -XepOpt:Refaster:NamePattern=^(?!(WebClientRules\.WebClientPatch)) as compiler argument.

Samples

Shows the difference in example code before and after the Refaster rule is applied.

 ImmutableSet<?> testWebClientPatch() {
     return ImmutableSet.of(
-        WebClient.create().method(PATCH), WebTestClient.bindToServer().build().method(PATCH));
+        WebClient.create().patch(), WebTestClient.bindToServer().build().patch());
   }

WebClientPost

SUGGESTION

Simplification

Suppression

Suppress false positives by adding the suppression annotation @SuppressWarnings("WebClientPost") to the enclosing element.

Disable this rule by adding -XepOpt:Refaster:NamePattern=^(?!(WebClientRules\.WebClientPost)) as compiler argument.

Samples

Shows the difference in example code before and after the Refaster rule is applied.

 ImmutableSet<?> testWebClientPost() {
-    return ImmutableSet.of(
-        WebClient.create().method(POST), WebTestClient.bindToServer().build().method(POST));
+    return ImmutableSet.of(WebClient.create().post(), WebTestClient.bindToServer().build().post());
   }

WebClientPut

SUGGESTION

Simplification

Suppression

Suppress false positives by adding the suppression annotation @SuppressWarnings("WebClientPut") to the enclosing element.

Disable this rule by adding -XepOpt:Refaster:NamePattern=^(?!(WebClientRules\.WebClientPut)) as compiler argument.

Samples

Shows the difference in example code before and after the Refaster rule is applied.

 ImmutableSet<?> testWebClientPut() {
-    return ImmutableSet.of(
-        WebClient.create().method(PUT), WebTestClient.bindToServer().build().method(PUT));
+    return ImmutableSet.of(WebClient.create().put(), WebTestClient.bindToServer().build().put());
   }

RequestHeadersUriSpecUri

SUGGESTION

Simplification

Suppression

Suppress false positives by adding the suppression annotation @SuppressWarnings("RequestHeadersUriSpecUri") to the enclosing element.

Disable this rule by adding -XepOpt:Refaster:NamePattern=^(?!(WebClientRules\.RequestHeadersUriSpecUri)) as compiler argument.

Samples

Shows the difference in example code before and after the Refaster rule is applied.

 ImmutableSet<?> testRequestHeadersUriSpecUri() {
     return ImmutableSet.of(
-        WebClient.create("foo").get().uri(uriBuilder -> uriBuilder.path("/bar").build()),
-        WebClient.create("bar")
-            .post()
-            .uri(uriBuilder -> uriBuilder.path("/bar/{baz}").build("quux")),
-        WebTestClient.bindToServer()
-            .build()
-            .get()
-            .uri(uriBuilder -> uriBuilder.path("/baz").build()),
-        WebTestClient.bindToServer()
-            .build()
-            .post()
-            .uri(uriBuilder -> uriBuilder.path("/qux/{quux}/{quuz}").build("corge", "grault")));
+        WebClient.create("foo").get().uri("/bar"),
+        WebClient.create("bar").post().uri("/bar/{baz}", "quux"),
+        WebTestClient.bindToServer().build().get().uri("/baz"),
+        WebTestClient.bindToServer().build().post().uri("/qux/{quux}/{quuz}", "corge", "grault"));
   }

Copyright © 2017-2023 Picnic Technologies BV