Bring codebase up to more recent Java standards (#2422)

This includes using the new switch format (though IntelliJ does not yet
understand patterns including default so those aren't used), multiline strings,
replacing some unnecessary type declarations with <>, converting some classes to
records, replacing some Guava predicates with native Java code, and some other
miscellaneous Code Inspection fixes.
This commit is contained in:
Ben McIlwain
2024-05-01 20:48:38 +00:00
committed by GitHub
parent 570618705e
commit 4b6ade0b14
154 changed files with 1454 additions and 1535 deletions
@@ -98,30 +98,15 @@ class GcpJsonFormatter extends Formatter {
* href="https://github.com/googleapis/google-cloud-java/blob/master/google-cloud-clients/google-cloud-logging/src/main/java/com/google/cloud/logging/LoggingHandler.java#L325">{@code LoggingHandler}</a>
*/
private static String severityFor(Level level) {
switch (level.intValue()) {
// FINEST
case 300:
return "DEBUG";
// FINER
case 400:
return "DEBUG";
// FINE
case 500:
return "DEBUG";
// CONFIG
case 700:
return "INFO";
// INFO
case 800:
return "INFO";
// WARNING
case 900:
return "WARNING";
// SEVERE
case 1000:
return "ERROR";
default:
return "DEFAULT";
}
return switch (level.intValue()) {
case 300 -> "DEBUG"; // FINEST
case 400 -> "DEBUG"; // FINER
case 500 -> "DEBUG"; // FINE
case 700 -> "INFO"; // CONFIG
case 800 -> "INFO"; // INFO
case 900 -> "WARNING"; // WARNING
case 1000 -> "ERROR"; // SEVERE
default -> "DEFAULT";
};
}
}
@@ -48,10 +48,12 @@ class EppProtocolModuleTest extends ProtocolModuleTest {
private static final String CLIENT_ADDRESS = "epp.client.tld";
private static final byte[] HELLO_BYTES =
("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n"
+ "<epp xmlns=\"urn:ietf:params:xml:ns:epp-1.0\">\n"
+ " <hello/>\n"
+ "</epp>\n")
"""
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
<hello/>
</epp>
"""
.getBytes(UTF_8);
private X509Certificate certificate;
@@ -53,10 +53,12 @@ import org.junit.jupiter.api.Test;
class EppServiceHandlerTest {
private static final String HELLO =
"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n"
+ "<epp xmlns=\"urn:ietf:params:xml:ns:epp-1.0\">\n"
+ " <hello/>\n"
+ "</epp>\n";
"""
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
<hello/>
</epp>
""";
private static final String RELAY_HOST = "registry.example.tld";
private static final String RELAY_PATH = "/epp";