Java 17 features (N-S) (#15565)

- add missing @override
- Java style array syntax
- remove redundant modifiers
- always move String constants to left side in comparisons
- simplify lambda expressions and return statements
- use replace instead of replaceAll w/o regex
- instanceof matching and multiline strings

Signed-off-by: Holger Friedrich <mail@holger-friedrich.de>
This commit is contained in:
Holger Friedrich
2023-09-13 08:03:31 +02:00
committed by GitHub
parent 641b482551
commit ab58f4ffb4
471 changed files with 1624 additions and 1868 deletions

View File

@@ -40,8 +40,8 @@ public class NumberUtils {
public static double convert(Object o) {
// ensure value not null
double value = UNDEF;
if (o instanceof Number) {
value = ((Number) o).doubleValue();
if (o instanceof Number number) {
value = number.doubleValue();
} else if (o instanceof String) {
value = Double.parseDouble(o.toString());
}

View File

@@ -70,7 +70,7 @@ public class DTOTest {
SensorData d = valueArray[0];
// Assure latest data is taken
String dateStr = d.getTimeStamp();
if (dateStr.equals("2020-06-09 06:38:08")) {
if ("2020-06-09 06:38:08".equals(dateStr)) {
// take newer one
d = valueArray[1];
}

View File

@@ -31,7 +31,7 @@ import org.eclipse.jdt.annotation.Nullable;
public class FileReader {
public static @Nullable String readFileInString(String filename) {
try (BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(filename), "CP1252"));) {
try (BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(filename), "CP1252"))) {
StringBuffer buf = new StringBuffer();
String sCurrentLine;