Skip to content

Commit

Permalink
Apply OpenRewrite Java17 migration
Browse files Browse the repository at this point in the history
  • Loading branch information
Brutus5000 committed Nov 26, 2024
1 parent a198728 commit 6c2f26a
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public void start(Stage stage) {
scene = new Scene(root, WIDTH, HEIGHT);

stage.setScene(scene);
stage.setTitle(String.format("FAF ICE adapter - Debugger - Build: %s", IceAdapter.VERSION));
stage.setTitle("FAF ICE adapter - Debugger - Build: %s".formatted(IceAdapter.VERSION));
// stage.setOnCloseRequest(Event::consume);
// stage.show();

Expand Down Expand Up @@ -98,11 +98,11 @@ public void startupComplete() {
public void initStaticVariables() {

runOnUIThread(() -> {
controller.versionLabel.setText(String.format("Version: %s", IceAdapter.VERSION));
controller.userLabel.setText(String.format("User: %s(%d)", IceAdapter.login, IceAdapter.id));
controller.rpcPortLabel.setText(String.format("RPC_PORT: %d", IceAdapter.RPC_PORT));
controller.gpgnetPortLabel.setText(String.format("GPGNET_PORT: %d", IceAdapter.GPGNET_PORT));
controller.lobbyPortLabel.setText(String.format("LOBBY_PORT: %d", IceAdapter.LOBBY_PORT));
controller.versionLabel.setText("Version: %s".formatted(IceAdapter.VERSION));
controller.userLabel.setText("User: %s(%d)".formatted(IceAdapter.login, IceAdapter.id));
controller.rpcPortLabel.setText("RPC_PORT: %d".formatted(IceAdapter.RPC_PORT));
controller.gpgnetPortLabel.setText("GPGNET_PORT: %d".formatted(IceAdapter.GPGNET_PORT));
controller.lobbyPortLabel.setText("LOBBY_PORT: %d".formatted(IceAdapter.LOBBY_PORT));
});
}

Expand All @@ -127,7 +127,7 @@ public void rpcStarted(CompletableFuture<JJsonPeer> peerFuture) {
});
peerFuture.thenAccept(peer -> runOnUIThread(() -> {
controller.rpcClientStatus.setText(
String.format("RPCClient: %s", peer.getSocket().getInetAddress()));
"RPCClient: %s".formatted(peer.getSocket().getInetAddress()));
}));
}

Expand All @@ -142,7 +142,7 @@ public void gpgnetStarted() {
public void gpgnetConnectedDisconnected() {
runOnUIThread(() -> {
controller.gpgnetServerStatus.setText(
String.format("GPGNetClient: %s", GPGNetServer.isConnected() ? "connected" : "-"));
"GPGNetClient: %s".formatted(GPGNetServer.isConnected() ? "connected" : "-"));
gameStateChanged();
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ private void appendText(String text) {

public void setTextArea(Object textArea) {
if (!textArea.getClass().getCanonicalName().equals("javafx.scene.control.TextArea")) {
throw new RuntimeException(String.format(
"Object is of class %s, expected javafx.scene.control.TextArea",
throw new RuntimeException("Object is of class %s, expected javafx.scene.control.TextArea".formatted(
textArea.getClass().getCanonicalName()));
}
this.textArea = textArea;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,6 @@ public void close() {
* @return %username%(%id%)
*/
public String getPeerIdentifier() {
return String.format("%s(%d)", this.remoteLogin, this.remoteId);
return "%s(%d)".formatted(this.remoteLogin, this.remoteId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import java.util.concurrent.CancellationException;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionException;
import java.util.concurrent.ThreadLocalRandom;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
import lombok.Getter;
Expand Down Expand Up @@ -121,7 +122,7 @@ a, new LongTermCredential(iceServer.getTurnUsername(), iceServer.getTurnCredenti
CompletableFuture<Void> gatheringFuture = CompletableFuture.runAsync(() -> {
try {
component = agent.createComponent(
mediaStream, MINIMUM_PORT + (int) (Math.random() * 999.0), MINIMUM_PORT, MINIMUM_PORT + 1000);
mediaStream, MINIMUM_PORT + (int) (ThreadLocalRandom.current().nextDouble() * 999.0), MINIMUM_PORT, MINIMUM_PORT + 1000);
} catch (IOException e) {
throw new RuntimeException(e);
}
Expand Down Expand Up @@ -513,6 +514,6 @@ public int getConnectivityAttempsInThePast(final long millis) {
}

public String getLogPrefix() {
return String.format("ICE %s: ", peer.getPeerIdentifier());
return "ICE %s: ".formatted(peer.getPeerIdentifier());
}
}
2 changes: 1 addition & 1 deletion ice-adapter/src/test/java/IceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public static void main(String args[]) throws IOException {
System.out.printf("Username: %s\n", username);

int timestamp = (int) (System.currentTimeMillis() / 1000) + 3600 * 24;
String tokenName = String.format("%s:%s", timestamp, username);
String tokenName = "%s:%s".formatted(timestamp, username);
byte[] secret = null;
try {
Mac mac = Mac.getInstance("HmacSHA1");
Expand Down

0 comments on commit 6c2f26a

Please sign in to comment.