Use valueOf for number type instantiation

The constructors for Character, Integer, and Long are deprecated as of
Java 9, the static valueOf methods should be used instead.
This commit is contained in:
Brett Henderson
2023-05-14 22:20:41 +10:00
parent 9346307a1c
commit 05468d6ede
4 changed files with 23 additions and 23 deletions

View File

@ -24,8 +24,8 @@ public class TransactionSnapshotTest {
Assert.assertEquals("xMax is incorrect.", 5678, snapshot.getXMax());
Assert.assertEquals("xIpList is incorrect.",
Arrays.asList(new Long[] {
new Long(101112), new Long(131415),
new Long(161718) }),
Long.valueOf(101112), Long.valueOf(131415),
Long.valueOf(161718) }),
snapshot.getXIpList());
}
}

View File

@ -122,7 +122,7 @@ public abstract class TaskManager {
if (pipeArgName.indexOf(pipeArgumentPrefix) == 0) {
Integer pipeIndex;
pipeIndex = new Integer(
pipeIndex = Integer.valueOf(
getPipeIndex(pipeArgName.substring(pipeArgumentPrefix.length()))
);
@ -155,7 +155,7 @@ public abstract class TaskManager {
*/
protected Task getInputTask(PipeTasks pipeTasks, int pipeIndex, Class<? extends Task> requiredTaskType) {
Task inputTask;
Integer pipeIndexO = new Integer(pipeIndex);
Integer pipeIndexO = Integer.valueOf(pipeIndex);
// We use the specified pipe name if it exists, otherwise we get the
// next available default pipe.
@ -180,7 +180,7 @@ public abstract class TaskManager {
* The index of the pipe on the current task.
*/
protected void setOutputTask(PipeTasks pipeTasks, Task outputTask, int pipeIndex) {
Integer pipeIndexO = new Integer(pipeIndex);
Integer pipeIndexO = Integer.valueOf(pipeIndex);
// We use the specified pipe name if it exists, otherwise we register
// using the next available default pipe name.

View File

@ -89,8 +89,8 @@ public class ReplicationLagReader implements RunnableTask {
// more than a day
Object[] args = {
new Long(lag / 86400),
new Long((lag % 86400) / 3600)
Long.valueOf(lag / 86400),
Long.valueOf((lag % 86400) / 3600)
};
System.out.println(
new MessageFormat("{0} day(s) and {1} hour(s)").format(args)
@ -100,8 +100,8 @@ public class ReplicationLagReader implements RunnableTask {
// morte than an hour
Object[] args = {
new Long(lag / 3600),
new Long((lag % 3600) / 60)
Long.valueOf(lag / 3600),
Long.valueOf((lag % 3600) / 60)
};
System.out.println(
new MessageFormat("{0} hour(s) and {1} minute(s)").format(args)
@ -111,8 +111,8 @@ public class ReplicationLagReader implements RunnableTask {
// more than a minute
Object[] args = {
new Long(lag / 60),
new Long(lag % 60)
Long.valueOf(lag / 60),
Long.valueOf(lag % 60)
};
System.out.println(
new MessageFormat("{0} minute(s) and {1} second(s)").format(args)
@ -120,7 +120,7 @@ public class ReplicationLagReader implements RunnableTask {
} else {
Object[] args = {
new Long(lag)
Long.valueOf(lag)
};
// just some seconds

View File

@ -35,19 +35,19 @@ public class ElementWriter {
// with the exception of tab, carriage return and line feed.
for (int i = 0; i <= 0x1F; i++) {
if (i != 0x9 && i != 0xA && i != 0xD) {
XML_ENCODING.put(new Character((char) i), "");
XML_ENCODING.put(Character.valueOf((char) i), "");
}
}
XML_ENCODING.put(new Character((char) 0x7F), "");
XML_ENCODING.put(Character.valueOf((char) 0x7F), "");
XML_ENCODING.put(new Character('<'), "&lt;");
XML_ENCODING.put(new Character('>'), "&gt;");
XML_ENCODING.put(new Character('"'), "&quot;");
XML_ENCODING.put(new Character('\''), "&apos;");
XML_ENCODING.put(new Character('&'), "&amp;");
XML_ENCODING.put(new Character('\n'), "&#xA;");
XML_ENCODING.put(new Character('\r'), "&#xD;");
XML_ENCODING.put(new Character('\t'), "&#x9;");
XML_ENCODING.put(Character.valueOf('<'), "&lt;");
XML_ENCODING.put(Character.valueOf('>'), "&gt;");
XML_ENCODING.put(Character.valueOf('"'), "&quot;");
XML_ENCODING.put(Character.valueOf('\''), "&apos;");
XML_ENCODING.put(Character.valueOf('&'), "&amp;");
XML_ENCODING.put(Character.valueOf('\n'), "&#xA;");
XML_ENCODING.put(Character.valueOf('\r'), "&#xD;");
XML_ENCODING.put(Character.valueOf('\t'), "&#x9;");
}
/**
@ -128,7 +128,7 @@ public class ElementWriter {
for (int i = 0; i < data.length(); ++i) {
char currentChar = data.charAt(i);
String replacement = XML_ENCODING.get(new Character(currentChar));
String replacement = XML_ENCODING.get(Character.valueOf(currentChar));
if (replacement != null) {
if (buffer == null) {