JacksonRules

SUGGESTION

Simplification

View source code on GitHub

Suppression

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

Table of contents
  1. JsonNodeOptionalInt
  2. JsonNodeOptionalString

JsonNodeOptionalInt

SUGGESTION

Simplification

Suppression

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

Disable this rule by adding -XepOpt:Refaster:NamePattern=^(?!JacksonRules\$JsonNodeOptionalInt).* as compiler argument.

Samples

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

 ImmutableSet<Optional<JsonNode>> testJsonNodeOptionalInt() {
   return ImmutableSet.of(
-      NullNode.getInstance().get(1).asOptional(),
-      NullNode.getInstance().path(2).asOptional(),
-      Optional.of(NullNode.getInstance().get(3)),
-      Optional.ofNullable(NullNode.getInstance().get(4)));
+      NullNode.getInstance().optional(1),
+      NullNode.getInstance().optional(2),
+      NullNode.getInstance().optional(3),
+      NullNode.getInstance().optional(4));
 }

JsonNodeOptionalString

SUGGESTION

Simplification

Suppression

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

Disable this rule by adding -XepOpt:Refaster:NamePattern=^(?!JacksonRules\$JsonNodeOptionalString).* as compiler argument.

Samples

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

 ImmutableSet<Optional<JsonNode>> testJsonNodeOptionalString() {
   return ImmutableSet.of(
-      NullNode.getInstance().get("foo").asOptional(),
-      NullNode.getInstance().path("bar").asOptional(),
-      Optional.of(NullNode.getInstance().get("baz")),
-      Optional.ofNullable(NullNode.getInstance().get("qux")));
+      NullNode.getInstance().optional("foo"),
+      NullNode.getInstance().optional("bar"),
+      NullNode.getInstance().optional("baz"),
+      NullNode.getInstance().optional("qux"));
 }

Copyright © 2017-2024 Picnic Technologies BV