Jackson3Rules
SUGGESTION
Simplification
Suppression
Disable all rules by adding
-XepOpt:Refaster:NamePattern=^(?!Jackson3Rules\$).*as compiler argument.
Table of contents
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=^(?!Jackson3Rules\$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=^(?!Jackson3Rules\$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"));
}ObjectMapperValueToTree
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("ObjectMapperValueToTree")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!Jackson3Rules\$ObjectMapperValueToTree).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
ImmutableSet<JsonNode> testObjectMapperValueToTree() {
return ImmutableSet.of(
- new ObjectMapper().readTree(new ObjectMapper().writeValueAsBytes("foo")),
- JsonMapper.shared().readTree(JsonMapper.shared().writeValueAsString("bar")));
+ new ObjectMapper().valueToTree("foo"), JsonMapper.shared().valueToTree("bar"));
}ObjectMapperConvertValueClass
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("ObjectMapperConvertValueClass")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!Jackson3Rules\$ObjectMapperConvertValueClass).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
ImmutableSet<Number> testObjectMapperConvertValueClass() {
return ImmutableSet.of(
- new ObjectMapper().readValue(new ObjectMapper().writeValueAsBytes("foo"), Integer.class),
- JsonMapper.shared().readValue(JsonMapper.shared().writeValueAsString("bar"), Double.class));
+ new ObjectMapper().convertValue("foo", Integer.class),
+ JsonMapper.shared().convertValue("bar", Double.class));
}ObjectMapperConvertValueJavaType
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("ObjectMapperConvertValueJavaType")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!Jackson3Rules\$ObjectMapperConvertValueJavaType).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
ImmutableSet<Number> testObjectMapperConvertValueJavaType() {
return ImmutableSet.of(
- new ObjectMapper()
- .readValue(
- new ObjectMapper().writeValueAsBytes("foo"),
- SimpleType.constructUnsafe(Integer.class)),
- JsonMapper.shared()
- .readValue(
- JsonMapper.shared().writeValueAsString("bar"),
- SimpleType.constructUnsafe(Double.class)));
+ new ObjectMapper().convertValue("foo", SimpleType.constructUnsafe(Integer.class)),
+ JsonMapper.shared().convertValue("bar", SimpleType.constructUnsafe(Double.class)));
}ObjectMapperConvertValueTypeReference
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("ObjectMapperConvertValueTypeReference")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!Jackson3Rules\$ObjectMapperConvertValueTypeReference).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
ImmutableSet<Number> testObjectMapperConvertValueTypeReference() {
return ImmutableSet.of(
- new ObjectMapper()
- .readValue(
- new ObjectMapper().writeValueAsBytes("foo"), new TypeReference<Integer>() {}),
- JsonMapper.shared()
- .readValue(
- JsonMapper.shared().writeValueAsString("bar"), new TypeReference<Double>() {}));
+ new ObjectMapper().convertValue("foo", new TypeReference<Integer>() {}),
+ JsonMapper.shared().convertValue("bar", new TypeReference<Double>() {}));
}