only initialize DriverPropertyInfo once

This commit is contained in:
Mikaël Francoeur
2025-07-13 11:49:19 -04:00
parent c92e9cf866
commit 434d1c60be
2 changed files with 18 additions and 13 deletions

View File

@@ -7,23 +7,16 @@ import java.util.Properties;
/** Turso Configuration. */
public final class TursoConfig {
private Properties pragma;
private static final DriverPropertyInfo[] driverPropertyInfo = driverPropertyInfo();
private final Properties pragma;
public TursoConfig(Properties properties) {
this.pragma = properties;
}
public static DriverPropertyInfo[] getDriverPropertyInfo() {
return Arrays.stream(Pragma.values())
.map(
p -> {
DriverPropertyInfo info = new DriverPropertyInfo(p.pragmaName, null);
info.description = p.description;
info.choices = p.choices;
info.required = false;
return info;
})
.toArray(DriverPropertyInfo[]::new);
return driverPropertyInfo;
}
public Properties toProperties() {
@@ -49,4 +42,17 @@ public final class TursoConfig {
return pragmaName;
}
}
private static DriverPropertyInfo[] driverPropertyInfo() {
return Arrays.stream(Pragma.values())
.map(
p -> {
DriverPropertyInfo info = new DriverPropertyInfo(p.pragmaName, null);
info.description = p.description;
info.choices = p.choices;
info.required = false;
return info;
})
.toArray(DriverPropertyInfo[]::new);
}
}

View File

@@ -7,7 +7,6 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.sql.SQLException;
import tech.turso.TursoErrorCode;
import tech.turso.annotations.NativeInvocation;
import tech.turso.annotations.VisibleForTesting;
@@ -38,7 +37,7 @@ public final class TursoDB implements AutoCloseable {
* Enum representing different architectures and their corresponding library paths and file
* extensions.
*/
enum Architecture {
private enum Architecture {
MACOS_ARM64("libs/macos_arm64/lib_turso_java.dylib", ".dylib"),
MACOS_X86("libs/macos_x86/lib_turso_java.dylib", ".dylib"),
LINUX_X86("libs/linux_x86/lib_turso_java.so", ".so"),