Skip to content

Commit

Permalink
fix: address some deprecation warnings in Java 9+ (#1215)
Browse files Browse the repository at this point in the history
  • Loading branch information
elharo committed Jan 12, 2021
1 parent 6b9b6c5 commit 9f53a67
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
Expand Up @@ -575,10 +575,10 @@ private static Object parseValue(Type valueType, List<Type> context, String valu
valueType = Data.resolveWildcardTypeOrTypeVariable(context, valueType);
if (valueType == Double.class || valueType == double.class) {
if (value.equals("INF")) {
return new Double(Double.POSITIVE_INFINITY);
return Double.valueOf(Double.POSITIVE_INFINITY);
}
if (value.equals("-INF")) {
return new Double(Double.NEGATIVE_INFINITY);
return Double.valueOf(Double.NEGATIVE_INFINITY);
}
}
if (valueType == Float.class || valueType == float.class) {
Expand Down
Expand Up @@ -45,36 +45,47 @@ public class Data {
// NOTE: create new instances to avoid cache, e.g. new String()

/** The single instance of the magic null object for a {@link Boolean}. */
@SuppressWarnings("deprecation")
public static final Boolean NULL_BOOLEAN = new Boolean(true);

/** The single instance of the magic null object for a {@link String}. */
@SuppressWarnings("deprecation")
public static final String NULL_STRING = new String();

/** The single instance of the magic null object for a {@link Character}. */
@SuppressWarnings("deprecation")
public static final Character NULL_CHARACTER = new Character((char) 0);

/** The single instance of the magic null object for a {@link Byte}. */
@SuppressWarnings("deprecation")
public static final Byte NULL_BYTE = new Byte((byte) 0);

/** The single instance of the magic null object for a {@link Short}. */
@SuppressWarnings("deprecation")
public static final Short NULL_SHORT = new Short((short) 0);

/** The single instance of the magic null object for a {@link Integer}. */
@SuppressWarnings("deprecation")
public static final Integer NULL_INTEGER = new Integer(0);

/** The single instance of the magic null object for a {@link Float}. */
@SuppressWarnings("deprecation")
public static final Float NULL_FLOAT = new Float(0);

/** The single instance of the magic null object for a {@link Long}. */
@SuppressWarnings("deprecation")
public static final Long NULL_LONG = new Long(0);

/** The single instance of the magic null object for a {@link Double}. */
@SuppressWarnings("deprecation")
public static final Double NULL_DOUBLE = new Double(0);

/** The single instance of the magic null object for a {@link BigInteger}. */
@SuppressWarnings("deprecation")
public static final BigInteger NULL_BIG_INTEGER = new BigInteger("0");

/** The single instance of the magic null object for a {@link BigDecimal}. */
@SuppressWarnings("deprecation")
public static final BigDecimal NULL_BIG_DECIMAL = new BigDecimal("0");

/** The single instance of the magic null object for a {@link DateTime}. */
Expand Down
Expand Up @@ -34,7 +34,7 @@ public void testConstructor_innerClass() {

public void testToString_oneIntegerField() {
String toTest =
Objects.toStringHelper(new TestClass()).add("field1", new Integer(42)).toString();
Objects.toStringHelper(new TestClass()).add("field1", Integer.valueOf(42)).toString();
assertEquals("TestClass{field1=42}", toTest);
}

Expand Down

0 comments on commit 9f53a67

Please sign in to comment.