From 98072ead23a031b20effe609aad6b4663363d1d8 Mon Sep 17 00:00:00 2001 From: Volker Milbrandt Date: Tue, 29 Nov 2022 15:00:10 +0100 Subject: [PATCH] 'toLowerCase(Locale): String' is deprecated. Use lowercase() instead --- .gitignore | 2 ++ .../schema2proto/generateproto/NamespaceHelper.java | 4 ++-- .../schema2proto/generateproto/ProtoSerializer.java | 6 +++--- .../compatibility/AbstractBackwardsCompatTest.java | 11 ++++++----- .../wire/schema/internal/parser/FieldElement.kt | 2 +- .../wire/schema/internal/parser/GroupElement.kt | 2 +- 6 files changed, 15 insertions(+), 12 deletions(-) diff --git a/.gitignore b/.gitignore index 62da5da1..9273a717 100644 --- a/.gitignore +++ b/.gitignore @@ -26,3 +26,5 @@ dependency-reduced-pom.xml .idea/ local_config/ +*/target/ +*/bin/ \ No newline at end of file diff --git a/schema2proto-lib/src/main/java/no/entur/schema2proto/generateproto/NamespaceHelper.java b/schema2proto-lib/src/main/java/no/entur/schema2proto/generateproto/NamespaceHelper.java index 3b33a04d..33387b8c 100644 --- a/schema2proto-lib/src/main/java/no/entur/schema2proto/generateproto/NamespaceHelper.java +++ b/schema2proto-lib/src/main/java/no/entur/schema2proto/generateproto/NamespaceHelper.java @@ -52,7 +52,7 @@ public static String xmlNamespaceToProtoPackage(String namespace, String forcePr String packageName; if (forceProtoPackage != null) { - packageName = forceProtoPackage.toLowerCase(); + packageName = forceProtoPackage.lowercase(); } else if (StringUtils.trimToNull(namespace) == null) { packageName = null; } else { @@ -71,7 +71,7 @@ public static String xmlNamespaceToProtoPackage(String namespace, String forcePr LOGGER.warn("Unable to create decent package name from XML namespace {}, falling back to {} ", namespace, packageName, urnSyntaxError); } } - packageName = StringUtils.trimToNull(packageName).toLowerCase(); + packageName = StringUtils.trimToNull(packageName).lowercase(); NAMESPACE_TO_PACKAGENAME.put(namespace, packageName); } diff --git a/schema2proto-lib/src/main/java/no/entur/schema2proto/generateproto/ProtoSerializer.java b/schema2proto-lib/src/main/java/no/entur/schema2proto/generateproto/ProtoSerializer.java index 1463479b..8787edb4 100644 --- a/schema2proto-lib/src/main/java/no/entur/schema2proto/generateproto/ProtoSerializer.java +++ b/schema2proto-lib/src/main/java/no/entur/schema2proto/generateproto/ProtoSerializer.java @@ -215,7 +215,7 @@ public void serialize(Map packageToProtoFileMap, List packageToProtoFileMap, List entry : packageToProtoFileMap.entrySet()) { ProtoFile protoFile = entry.getValue(); File destFolder = createPackageFolderStructure(configuration.outputDirectory, protoFile.packageName()); - File outputFile = new File(destFolder, protoFile.location().getPath().toLowerCase()); + File outputFile = new File(destFolder, protoFile.location().getPath().lowercase()); try (Writer writer = new FileWriter(outputFile)) { writer.write(protoFile.toSchema()); @@ -560,7 +560,7 @@ private CaseFormat getCaseFormatName(String s) throws IllegalFormatException { return CaseFormat.UPPER_UNDERSCORE; } } else if (s.contains("-")) { - if (s.toLowerCase().equals(s)) { + if (s.lowercase().equals(s)) { return CaseFormat.LOWER_HYPHEN; } } else { diff --git a/schema2proto-lib/src/test/java/no/entur/schema2proto/compatibility/AbstractBackwardsCompatTest.java b/schema2proto-lib/src/test/java/no/entur/schema2proto/compatibility/AbstractBackwardsCompatTest.java index db61355a..52d4ef98 100644 --- a/schema2proto-lib/src/test/java/no/entur/schema2proto/compatibility/AbstractBackwardsCompatTest.java +++ b/schema2proto-lib/src/test/java/no/entur/schema2proto/compatibility/AbstractBackwardsCompatTest.java @@ -9,12 +9,12 @@ * Licensed under the EUPL, Version 1.1 or – as soon they will be * approved by the European Commission - subsequent versions of the * EUPL (the "Licence"); - * + * * You may not use this work except in compliance with the Licence. * You may obtain a copy of the Licence at: - * + * * http://ec.europa.eu/idabc/eupl5 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the Licence is distributed on an "AS IS" basis, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -51,7 +51,8 @@ public abstract class AbstractBackwardsCompatTest { protected void verify(String testname, boolean failOnRemovedFields, String protoFile) throws IOException { ProtolockBackwardsCompatibilityChecker checker = new ProtolockBackwardsCompatibilityChecker(); - checker.init(new File(testdataBaseDirectory + "/" + testname + "/" + sourceFolder + "/" + lockFile)); + //checker.init(new File(testdataBaseDirectory + "/" + testname + "/" + sourceFolder + "/" + lockFile)); + checker.init(new File(String.join(File.pathSeparator, new[] { testdataBaseDirectory, testname, source, lockFile }))); Schema sourceSchema = loadSchema(new File(testdataBaseDirectory + "/" + testname + "/" + sourceFolder)); link(sourceSchema, false, testname); @@ -99,7 +100,7 @@ private boolean link(Schema schema, boolean dumpIfNotLinkable, String testname) System.out.println("Dumpfolder: " + dumpFolder.getAbsolutePath()); for (ProtoFile protoFile : schema.protoFiles()) { File destFolder = createPackageFolderStructure(new File(dumpFolder, testname), protoFile.packageName()); - File outputFile = new File(destFolder, protoFile.name().toLowerCase(Locale.ROOT)); + File outputFile = new File(destFolder, protoFile.name().lowercase(Locale.ROOT)); try (Writer writer = new FileWriter(outputFile)) { writer.write(protoFile.toSchema()); } diff --git a/schema2proto-wire/src/main/java/com/squareup/wire/schema/internal/parser/FieldElement.kt b/schema2proto-wire/src/main/java/com/squareup/wire/schema/internal/parser/FieldElement.kt index 89754463..2e8b55fb 100644 --- a/schema2proto-wire/src/main/java/com/squareup/wire/schema/internal/parser/FieldElement.kt +++ b/schema2proto-wire/src/main/java/com/squareup/wire/schema/internal/parser/FieldElement.kt @@ -35,7 +35,7 @@ data class FieldElement( appendDocumentation(this, documentation) if (label != null) { - append("${label.name.toLowerCase(Locale.US)} ") + append("${label.name.lowercase(Locale.US)} ") } append("$type $name = $tag") diff --git a/schema2proto-wire/src/main/java/com/squareup/wire/schema/internal/parser/GroupElement.kt b/schema2proto-wire/src/main/java/com/squareup/wire/schema/internal/parser/GroupElement.kt index 1a0c45fa..c5996b7a 100644 --- a/schema2proto-wire/src/main/java/com/squareup/wire/schema/internal/parser/GroupElement.kt +++ b/schema2proto-wire/src/main/java/com/squareup/wire/schema/internal/parser/GroupElement.kt @@ -32,7 +32,7 @@ data class GroupElement( fun toSchema() = buildString { appendDocumentation(this, documentation) if (label != null) { - append("${label.name.toLowerCase(Locale.US)} ") + append("${label.name.lowercase(Locale.US)} ") } append("group $name = $tag {") if (fields.isNotEmpty()) {