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"));
}ObjectMapperConvertValueWithClass
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("ObjectMapperConvertValueWithClass")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!Jackson3Rules\$ObjectMapperConvertValueWithClass).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
ImmutableSet<Number> testObjectMapperConvertValueWithClass() {
return ImmutableSet.of(
- new ObjectMapper().readValue(new ObjectMapper().writeValueAsBytes("1"), Integer.class),
- JsonMapper.shared().readValue(JsonMapper.shared().writeValueAsString("2.0"), Double.class));
+ new ObjectMapper().convertValue("1", Integer.class),
+ JsonMapper.shared().convertValue("2.0", Double.class));
}ObjectMapperConvertValueWithJavaType
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("ObjectMapperConvertValueWithJavaType")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!Jackson3Rules\$ObjectMapperConvertValueWithJavaType).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
ImmutableSet<Number> testObjectMapperConvertValueWithJavaType() {
return ImmutableSet.of(
- new ObjectMapper()
- .readValue(
- new ObjectMapper().writeValueAsBytes("1"),
- SimpleType.constructUnsafe(Integer.class)),
- JsonMapper.shared()
- .readValue(
- JsonMapper.shared().writeValueAsString("2.0"),
- SimpleType.constructUnsafe(Double.class)));
+ new ObjectMapper().convertValue("1", SimpleType.constructUnsafe(Integer.class)),
+ JsonMapper.shared().convertValue("2.0", SimpleType.constructUnsafe(Double.class)));
}ObjectMapperConvertValueWithTypeReference
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("ObjectMapperConvertValueWithTypeReference")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!Jackson3Rules\$ObjectMapperConvertValueWithTypeReference).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
ImmutableSet<Number> testObjectMapperConvertValueWithTypeReference() {
return ImmutableSet.of(
- new ObjectMapper()
- .readValue(new ObjectMapper().writeValueAsBytes("1"), new TypeReference<Integer>() {}),
- JsonMapper.shared()
- .readValue(
- JsonMapper.shared().writeValueAsString("2.0"), new TypeReference<Double>() {}));
+ new ObjectMapper().convertValue("1", new TypeReference<Integer>() {}),
+ JsonMapper.shared().convertValue("2.0", new TypeReference<Double>() {}));
}