Skip to content

Commit 3ebd6cb

Browse files
authored
Merge pull request #8381 from mbien/long-constructors
Replace Long constructor usage.
2 parents 9fc7bdb + 654b1bb commit 3ebd6cb

File tree

34 files changed

+99
-100
lines changed

34 files changed

+99
-100
lines changed

ide/api.debugger/nbproject/project.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@
1717

1818
is.autoload=true
1919
javac.compilerargs=-Xlint:unchecked
20-
javac.source=1.8
20+
javac.release=17
2121
javadoc.arch=${basedir}/arch.xml
2222
javadoc.apichanges=${basedir}/apichanges.xml

ide/api.debugger/src/org/netbeans/api/debugger/Properties.java

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1454,17 +1454,17 @@ public String[] getSupportedClassNames() {
14541454
@Override
14551455
public Object read(String className, Properties properties) {
14561456
if (classNames[0].equals(className)) {
1457-
return Boolean.valueOf(properties.getBoolean(propertyName, false));
1457+
return properties.getBoolean(propertyName, false);
14581458
} else if (classNames[1].equals(className)) {
14591459
return properties.getByte(propertyName, (byte)0);
14601460
} else if (classNames[2].equals(className)) {
1461-
return new Character(properties.getChar(propertyName, (char) 0));
1461+
return properties.getChar(propertyName, (char)0);
14621462
} else if (classNames[3].equals(className)) {
14631463
return properties.getShort(propertyName, (short)0);
14641464
} else if (classNames[4].equals(className)) {
1465-
return Integer.valueOf(properties.getInt(propertyName, 0));
1465+
return properties.getInt(propertyName, 0);
14661466
} else if (classNames[5].equals(className)) {
1467-
return new Long(properties.getLong(propertyName, 0l));
1467+
return properties.getLong(propertyName, 0l);
14681468
} else if (classNames[6].equals(className)) {
14691469
return properties.getFloat(propertyName, 0f);
14701470
} else if (classNames[7].equals(className)) {
@@ -1475,22 +1475,22 @@ public Object read(String className, Properties properties) {
14751475

14761476
@Override
14771477
public void write(Object object, Properties properties) {
1478-
if (object instanceof Boolean) {
1479-
properties.setBoolean(propertyName, ((Boolean) object).booleanValue());
1480-
} else if (object instanceof Byte) {
1481-
properties.setByte(propertyName, ((Byte) object).byteValue());
1482-
} else if (object instanceof Character) {
1483-
properties.setChar(propertyName, ((Character) object).charValue());
1484-
} else if (object instanceof Short) {
1485-
properties.setShort(propertyName, ((Short) object).shortValue());
1486-
} else if (object instanceof Integer) {
1487-
properties.setInt(propertyName, ((Integer) object).intValue());
1488-
} else if (object instanceof Long) {
1489-
properties.setLong(propertyName, ((Long) object).longValue());
1490-
} else if (object instanceof Float) {
1491-
properties.setFloat(propertyName, ((Float) object).floatValue());
1492-
} else if (object instanceof Double) {
1493-
properties.setDouble(propertyName, ((Double) object).doubleValue());
1478+
if (object instanceof Boolean b) {
1479+
properties.setBoolean(propertyName, b);
1480+
} else if (object instanceof Byte b) {
1481+
properties.setByte(propertyName, b);
1482+
} else if (object instanceof Character c) {
1483+
properties.setChar(propertyName, c);
1484+
} else if (object instanceof Short s) {
1485+
properties.setShort(propertyName, s);
1486+
} else if (object instanceof Integer i) {
1487+
properties.setInt(propertyName, i);
1488+
} else if (object instanceof Long l) {
1489+
properties.setLong(propertyName, l);
1490+
} else if (object instanceof Float f) {
1491+
properties.setFloat(propertyName, f);
1492+
} else if (object instanceof Double d) {
1493+
properties.setDouble(propertyName, d);
14941494
}
14951495
}
14961496

ide/bugzilla/src/org/netbeans/modules/bugzilla/issue/CommentsPanel.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,7 @@ void setIssue(BugzillaIssue issue,
136136
} catch (ParseException pex) {
137137
Bugzilla.LOG.log(Level.INFO, null, pex);
138138
}
139-
sections.add(addSection(layout,
140-
new Long(0),
139+
sections.add(addSection(layout, Long.valueOf(0),
141140
issue.getFieldValue(IssueField.DESCRIPTION),
142141
issue.getFieldValue(IssueField.REPORTER),
143142
issue.getFieldValue(IssueField.REPORTER_NAME),

ide/db.dataview/src/org/netbeans/modules/db/dataview/util/DBReadWriteHelper.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -453,20 +453,20 @@ public static Object validate(Object valueObj, DBColumn col) throws DBException
453453

454454
case Types.INTEGER: {
455455
long ldata = Long.parseLong(valueObj.toString());
456-
if(ldata >= ((long) Integer.MIN_VALUE) && ldata <= ((long) Integer.MAX_VALUE)) {
457-
return Integer.valueOf((int) ldata);
458-
} else if ( ldata < maxUnsignedInt ) {
459-
return new Long(ldata);
456+
if (ldata >= ((long) Integer.MIN_VALUE) && ldata <= ((long) Integer.MAX_VALUE)) {
457+
return (int) ldata;
458+
} else if (ldata < maxUnsignedInt) {
459+
return ldata;
460460
} else {
461461
throw new NumberFormatException("Illegal value for java.sql.Type.Integer");
462462
}
463463
}
464464

465465
case Types.SMALLINT: {
466466
int idata = Integer.parseInt(valueObj.toString());
467-
if(idata >= ((int) Short.MIN_VALUE) && idata <= ((int) Short.MAX_VALUE)) {
467+
if (idata >= ((int) Short.MIN_VALUE) && idata <= ((int) Short.MAX_VALUE)) {
468468
return (short) idata;
469-
} else if ( idata < maxUnsignedShort ) {
469+
} else if ( idata < maxUnsignedShort ) {
470470
return idata;
471471
} else {
472472
throw new NumberFormatException("Illegal value for java.sql.Type.SMALLINT");

ide/schema2beans/src/org/netbeans/modules/schema2beans/Common.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -377,13 +377,13 @@ public static Object defaultScalarValue(int type) {
377377
case Common.TYPE_BYTE:
378378
return (byte)0;
379379
case Common.TYPE_CHAR:
380-
return new Character('\0');
380+
return '\0';
381381
case Common.TYPE_SHORT:
382382
return (short)0;
383383
case Common.TYPE_INT:
384-
return Integer.valueOf(0);
384+
return 0;
385385
case Common.TYPE_LONG:
386-
return new Long(0);
386+
return 0L;
387387
case Common.TYPE_FLOAT:
388388
return 0.0F;
389389
case Common.TYPE_DOUBLE:
@@ -415,7 +415,7 @@ public static String getMessage(String key, Object p1) {
415415
}
416416

417417
public static String getMessage(String key, int p1) {
418-
return Common.getMessage(key, new Object[] {Integer.valueOf(p1)});
418+
return Common.getMessage(key, new Object[] {p1});
419419
}
420420

421421
public static String getMessage(String key, Object p1, Object p2) {

ide/schema2beans/src/org/netbeans/modules/schema2beans/GraphManager.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -890,13 +890,13 @@ public Object defaultScalarValue(int type) {
890890
case Common.TYPE_BYTE:
891891
return (byte)0;
892892
case Common.TYPE_CHAR:
893-
return new Character('\0');
893+
return '\0';
894894
case Common.TYPE_SHORT:
895895
return (short)0;
896896
case Common.TYPE_INT:
897-
return Integer.valueOf(0);
897+
return 0;
898898
case Common.TYPE_LONG:
899-
return new Long(0);
899+
return 0L;
900900
case Common.TYPE_FLOAT:
901901
return 0.0F;
902902
case Common.TYPE_DOUBLE:

ide/schema2beans/src/org/netbeans/modules/schema2beansdev/S2bConfig.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3425,7 +3425,7 @@ public Object fetchPropertyByName(String name) {
34253425
if ("indent".equals(name))
34263426
return getIndent();
34273427
if ("indentAmount".equals(name))
3428-
return new java.lang.Integer(getIndentAmount());
3428+
return getIndentAmount();
34293429
if ("mddFile".equals(name))
34303430
return getMddFile();
34313431
if ("mddIn".equals(name))
@@ -3503,7 +3503,7 @@ public Object fetchPropertyByName(String name) {
35033503
if ("generateHasChanged".equals(name))
35043504
return (isGenerateHasChanged() ? java.lang.Boolean.TRUE : java.lang.Boolean.FALSE);
35053505
if ("newestSourceTime".equals(name))
3506-
return new java.lang.Long(getNewestSourceTime());
3506+
return getNewestSourceTime();
35073507
if ("writeBeanGraphFile".equals(name))
35083508
return getWriteBeanGraphFile();
35093509
if ("readBeanGraphFiles[]".equals(name))

ide/schema2beans/src/org/netbeans/modules/schema2beansdev/gen/JavaUtil.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -741,17 +741,17 @@ else if ("double".equals(type))
741741
else if ("boolean".equals(type))
742742
Boolean.valueOf(value).booleanValue();
743743
else if ("java.lang.Double".equals(type))
744-
new java.lang.Double(value);
744+
Double.valueOf(value);
745745
else if ("java.lang.Integer".equals(type))
746-
new java.lang.Integer(value);
746+
Integer.valueOf(value);
747747
else if ("java.lang.Boolean".equals(type))
748748
Boolean.valueOf(value);
749749
else if ("java.lang.Float".equals(type))
750-
new java.lang.Float(value);
750+
Float.valueOf(value);
751751
else if ("java.lang.Short".equals(type))
752-
new java.lang.Short(value);
752+
Short.valueOf(value);
753753
else if ("java.lang.Long".equals(type))
754-
new java.lang.Long(value);
754+
Long.valueOf(value);
755755
else if ("java.math.BigDecimal".equals(type))
756756
new java.math.BigDecimal(value);
757757
else if ("java.math.BigInteger".equals(type))

ide/subversion/src/org/netbeans/modules/subversion/FileStatusCache.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,8 @@ public void run() {
180180
} while (fileToRefresh != null);
181181
if (logEnabled) {
182182
LOG.log(Level.FINE, "refreshTask lasted {0} ms for {1} files, {2} files refreshed so far", new Object[] { //NOI18N
183-
new Long(System.currentTimeMillis() - startTime), new Long(files), new Long(refreshedFilesCount)});
183+
Long.valueOf(System.currentTimeMillis() - startTime), Long.valueOf(files), Long.valueOf(refreshedFilesCount)}
184+
);
184185
}
185186
}
186187
});

ide/team.commons/src/org/netbeans/modules/bugtracking/commons/AttachmentsPanel.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -773,11 +773,11 @@ public void run() {
773773
if(file.length() > 1024 * 1024) {
774774
long size = file.length();
775775
Object[] arr = {
776-
getFilename(),
777-
new Long (size), // bytes
778-
new Long (size / 1024 + 1), // kilobytes
779-
new Long (size / (1024 * 1024)), // megabytes
780-
new Long (size / (1024 * 1024 * 1024)), // gigabytes
776+
getFilename(),
777+
Long.valueOf(size), // bytes
778+
Long.valueOf(size / 1024 + 1), // kilobytes
779+
Long.valueOf(size / (1024 * 1024)), // megabytes
780+
Long.valueOf(size / (1024 * 1024 * 1024)) // gigabytes
781781
};
782782
DialogDescriptor c = new DialogDescriptor(
783783
NbBundle.getMessage(AttachmentPanel.class, "MSG_ObjectIsTooBig", arr),

0 commit comments

Comments
 (0)