From 80e41858132635e598b90398b1fd9976d32025dc Mon Sep 17 00:00:00 2001 From: Jeff Lockhart Date: Tue, 14 Nov 2023 23:53:13 -0700 Subject: [PATCH] Prefer explicit constructor declarations without default parameters --- .../api/android/couchbase-lite-ee.api | 14 +++++++---- .../api/jvm/couchbase-lite-ee.api | 14 +++++++---- .../ee/kotbase/DatabaseConfiguration.kt | 2 -- couchbase-lite/api/android/couchbase-lite.api | 6 ++--- couchbase-lite/api/jvm/couchbase-lite.api | 6 ++--- .../kotbase/DatabaseConfiguration.apple.kt | 2 ++ .../kotlin/kotbase/Parameters.apple.kt | 2 ++ .../kotbase/SessionAuthenticator.apple.kt | 2 ++ .../kotlin/kotbase/DatabaseConfiguration.kt | 8 +++--- .../commonMain/kotlin/kotbase/Parameters.kt | 6 ++++- .../kotlin/kotbase/SessionAuthenticator.kt | 25 ++++++++++++------- .../DatabaseConfiguration.jvmCommon.kt | 2 ++ .../kotlin/kotbase/Parameters.jvmCommon.kt | 2 ++ .../kotbase/SessionAuthenticator.jvmCommon.kt | 2 ++ .../kotbase/DatabaseConfiguration.native.kt | 2 ++ .../kotlin/kotbase/Parameters.native.kt | 2 ++ .../kotbase/SessionAuthenticator.native.kt | 2 ++ 17 files changed, 68 insertions(+), 31 deletions(-) diff --git a/couchbase-lite-ee/api/android/couchbase-lite-ee.api b/couchbase-lite-ee/api/android/couchbase-lite-ee.api index 7fa1b7232..22d30fca8 100644 --- a/couchbase-lite-ee/api/android/couchbase-lite-ee.api +++ b/couchbase-lite-ee/api/android/couchbase-lite-ee.api @@ -331,8 +331,8 @@ public final class kotbase/DatabaseChange : kotbase/internal/DelegatedClass { } public final class kotbase/DatabaseConfiguration : kotbase/internal/DelegatedClass { + public fun ()V public fun (Lkotbase/DatabaseConfiguration;)V - public synthetic fun (Lkotbase/DatabaseConfiguration;ILkotlin/jvm/internal/DefaultConstructorMarker;)V public final fun getDirectory ()Ljava/lang/String; public final fun setDirectory (Ljava/lang/String;)Lkotbase/DatabaseConfiguration; public final fun setDirectory (Ljava/lang/String;)V @@ -1052,8 +1052,8 @@ public final class kotbase/Ordering$SortOrder : kotbase/Ordering { } public final class kotbase/Parameters : kotbase/internal/DelegatedClass { + public fun ()V public fun (Lkotbase/Parameters;)V - public synthetic fun (Lkotbase/Parameters;ILkotlin/jvm/internal/DefaultConstructorMarker;)V public final fun getValue (Ljava/lang/String;)Ljava/lang/Object; public final fun setArray (Ljava/lang/String;Lkotbase/Array;)Lkotbase/Parameters; public final fun setBlob (Ljava/lang/String;Lkotbase/Blob;)Lkotbase/Parameters; @@ -1336,8 +1336,8 @@ public final class kotbase/SelectResult$From : kotbase/SelectResult { } public final class kotbase/SessionAuthenticator : kotbase/Authenticator { + public fun (Ljava/lang/String;)V public fun (Ljava/lang/String;Ljava/lang/String;)V - public synthetic fun (Ljava/lang/String;Ljava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V public synthetic fun getActual$couchbase_lite_ee_release ()Ljava/lang/Object; public final fun getCookieName ()Ljava/lang/String; public final fun getSessionID ()Ljava/lang/String; @@ -1392,6 +1392,7 @@ public final class kotbase/URLEndpointListener : kotbase/internal/DelegatedClass } public final class kotbase/URLEndpointListenerConfiguration : kotbase/internal/DelegatedClass { + public static final field Companion Lkotbase/URLEndpointListenerConfiguration$Companion; public fun (Lkotbase/Database;Ljava/lang/String;IZLkotbase/TLSIdentity;Lkotbase/ListenerAuthenticator;ZZ)V public synthetic fun (Lkotbase/Database;Ljava/lang/String;IZLkotbase/TLSIdentity;Lkotbase/ListenerAuthenticator;ZZILkotlin/jvm/internal/DefaultConstructorMarker;)V public fun (Lkotbase/URLEndpointListenerConfiguration;)V @@ -1412,9 +1413,12 @@ public final class kotbase/URLEndpointListenerConfiguration : kotbase/internal/D public final fun setTlsIdentity (Lkotbase/TLSIdentity;)V } +public final class kotbase/URLEndpointListenerConfiguration$Companion { +} + public final class kotbase/URLEndpointListenerConfigurationKt { - public static final fun getMAX_PORT (Lkotbase/URLEndpointListenerConfiguration;)I - public static final fun getMIN_PORT (Lkotbase/URLEndpointListenerConfiguration;)I + public static final fun getMAX_PORT (Lkotbase/URLEndpointListenerConfiguration$Companion;)I + public static final fun getMIN_PORT (Lkotbase/URLEndpointListenerConfiguration$Companion;)I } public final class kotbase/ValueIndex : kotbase/Index { diff --git a/couchbase-lite-ee/api/jvm/couchbase-lite-ee.api b/couchbase-lite-ee/api/jvm/couchbase-lite-ee.api index 1aec890d2..2381f7d6c 100644 --- a/couchbase-lite-ee/api/jvm/couchbase-lite-ee.api +++ b/couchbase-lite-ee/api/jvm/couchbase-lite-ee.api @@ -331,8 +331,8 @@ public final class kotbase/DatabaseChange : kotbase/internal/DelegatedClass { } public final class kotbase/DatabaseConfiguration : kotbase/internal/DelegatedClass { + public fun ()V public fun (Lkotbase/DatabaseConfiguration;)V - public synthetic fun (Lkotbase/DatabaseConfiguration;ILkotlin/jvm/internal/DefaultConstructorMarker;)V public final fun getDirectory ()Ljava/lang/String; public final fun setDirectory (Ljava/lang/String;)Lkotbase/DatabaseConfiguration; public final fun setDirectory (Ljava/lang/String;)V @@ -1047,8 +1047,8 @@ public final class kotbase/Ordering$SortOrder : kotbase/Ordering { } public final class kotbase/Parameters : kotbase/internal/DelegatedClass { + public fun ()V public fun (Lkotbase/Parameters;)V - public synthetic fun (Lkotbase/Parameters;ILkotlin/jvm/internal/DefaultConstructorMarker;)V public final fun getValue (Ljava/lang/String;)Ljava/lang/Object; public final fun setArray (Ljava/lang/String;Lkotbase/Array;)Lkotbase/Parameters; public final fun setBlob (Ljava/lang/String;Lkotbase/Blob;)Lkotbase/Parameters; @@ -1331,8 +1331,8 @@ public final class kotbase/SelectResult$From : kotbase/SelectResult { } public final class kotbase/SessionAuthenticator : kotbase/Authenticator { + public fun (Ljava/lang/String;)V public fun (Ljava/lang/String;Ljava/lang/String;)V - public synthetic fun (Ljava/lang/String;Ljava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V public synthetic fun getActual$couchbase_lite_ee ()Ljava/lang/Object; public final fun getCookieName ()Ljava/lang/String; public final fun getSessionID ()Ljava/lang/String; @@ -1391,6 +1391,7 @@ public final class kotbase/URLEndpointListener : kotbase/internal/DelegatedClass } public final class kotbase/URLEndpointListenerConfiguration : kotbase/internal/DelegatedClass { + public static final field Companion Lkotbase/URLEndpointListenerConfiguration$Companion; public fun (Lkotbase/Database;Ljava/lang/String;IZLkotbase/TLSIdentity;Lkotbase/ListenerAuthenticator;ZZ)V public synthetic fun (Lkotbase/Database;Ljava/lang/String;IZLkotbase/TLSIdentity;Lkotbase/ListenerAuthenticator;ZZILkotlin/jvm/internal/DefaultConstructorMarker;)V public fun (Lkotbase/URLEndpointListenerConfiguration;)V @@ -1411,9 +1412,12 @@ public final class kotbase/URLEndpointListenerConfiguration : kotbase/internal/D public final fun setTlsIdentity (Lkotbase/TLSIdentity;)V } +public final class kotbase/URLEndpointListenerConfiguration$Companion { +} + public final class kotbase/URLEndpointListenerConfigurationKt { - public static final fun getMAX_PORT (Lkotbase/URLEndpointListenerConfiguration;)I - public static final fun getMIN_PORT (Lkotbase/URLEndpointListenerConfiguration;)I + public static final fun getMAX_PORT (Lkotbase/URLEndpointListenerConfiguration$Companion;)I + public static final fun getMIN_PORT (Lkotbase/URLEndpointListenerConfiguration$Companion;)I } public final class kotbase/ValueIndex : kotbase/Index { diff --git a/couchbase-lite-ee/src/commonMain/ee/kotbase/DatabaseConfiguration.kt b/couchbase-lite-ee/src/commonMain/ee/kotbase/DatabaseConfiguration.kt index a1dcffac0..64ab59665 100644 --- a/couchbase-lite-ee/src/commonMain/ee/kotbase/DatabaseConfiguration.kt +++ b/couchbase-lite-ee/src/commonMain/ee/kotbase/DatabaseConfiguration.kt @@ -35,5 +35,3 @@ public fun DatabaseConfiguration.setEncryptionKey(encryptionKey: EncryptionKey?) * A key to encrypt the database with. */ public expect var DatabaseConfiguration.encryptionKey: EncryptionKey? - -// TODO: provide update EE KTX creator function diff --git a/couchbase-lite/api/android/couchbase-lite.api b/couchbase-lite/api/android/couchbase-lite.api index 2c6ca085d..e56088fca 100644 --- a/couchbase-lite/api/android/couchbase-lite.api +++ b/couchbase-lite/api/android/couchbase-lite.api @@ -308,8 +308,8 @@ public final class kotbase/DatabaseChange : kotbase/internal/DelegatedClass { } public final class kotbase/DatabaseConfiguration : kotbase/internal/DelegatedClass { + public fun ()V public fun (Lkotbase/DatabaseConfiguration;)V - public synthetic fun (Lkotbase/DatabaseConfiguration;ILkotlin/jvm/internal/DefaultConstructorMarker;)V public final fun getDirectory ()Ljava/lang/String; public final fun setDirectory (Ljava/lang/String;)Lkotbase/DatabaseConfiguration; public final fun setDirectory (Ljava/lang/String;)V @@ -920,8 +920,8 @@ public final class kotbase/Ordering$SortOrder : kotbase/Ordering { } public final class kotbase/Parameters : kotbase/internal/DelegatedClass { + public fun ()V public fun (Lkotbase/Parameters;)V - public synthetic fun (Lkotbase/Parameters;ILkotlin/jvm/internal/DefaultConstructorMarker;)V public final fun getValue (Ljava/lang/String;)Ljava/lang/Object; public final fun setArray (Ljava/lang/String;Lkotbase/Array;)Lkotbase/Parameters; public final fun setBlob (Ljava/lang/String;Lkotbase/Blob;)Lkotbase/Parameters; @@ -1169,8 +1169,8 @@ public final class kotbase/SelectResult$From : kotbase/SelectResult { } public final class kotbase/SessionAuthenticator : kotbase/Authenticator { + public fun (Ljava/lang/String;)V public fun (Ljava/lang/String;Ljava/lang/String;)V - public synthetic fun (Ljava/lang/String;Ljava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V public synthetic fun getActual$couchbase_lite_release ()Ljava/lang/Object; public final fun getCookieName ()Ljava/lang/String; public final fun getSessionID ()Ljava/lang/String; diff --git a/couchbase-lite/api/jvm/couchbase-lite.api b/couchbase-lite/api/jvm/couchbase-lite.api index 8d3b0f42b..a4a56a68e 100644 --- a/couchbase-lite/api/jvm/couchbase-lite.api +++ b/couchbase-lite/api/jvm/couchbase-lite.api @@ -308,8 +308,8 @@ public final class kotbase/DatabaseChange : kotbase/internal/DelegatedClass { } public final class kotbase/DatabaseConfiguration : kotbase/internal/DelegatedClass { + public fun ()V public fun (Lkotbase/DatabaseConfiguration;)V - public synthetic fun (Lkotbase/DatabaseConfiguration;ILkotlin/jvm/internal/DefaultConstructorMarker;)V public final fun getDirectory ()Ljava/lang/String; public final fun setDirectory (Ljava/lang/String;)Lkotbase/DatabaseConfiguration; public final fun setDirectory (Ljava/lang/String;)V @@ -920,8 +920,8 @@ public final class kotbase/Ordering$SortOrder : kotbase/Ordering { } public final class kotbase/Parameters : kotbase/internal/DelegatedClass { + public fun ()V public fun (Lkotbase/Parameters;)V - public synthetic fun (Lkotbase/Parameters;ILkotlin/jvm/internal/DefaultConstructorMarker;)V public final fun getValue (Ljava/lang/String;)Ljava/lang/Object; public final fun setArray (Ljava/lang/String;Lkotbase/Array;)Lkotbase/Parameters; public final fun setBlob (Ljava/lang/String;Lkotbase/Blob;)Lkotbase/Parameters; @@ -1169,8 +1169,8 @@ public final class kotbase/SelectResult$From : kotbase/SelectResult { } public final class kotbase/SessionAuthenticator : kotbase/Authenticator { + public fun (Ljava/lang/String;)V public fun (Ljava/lang/String;Ljava/lang/String;)V - public synthetic fun (Ljava/lang/String;Ljava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V public synthetic fun getActual$couchbase_lite ()Ljava/lang/Object; public final fun getCookieName ()Ljava/lang/String; public final fun getSessionID ()Ljava/lang/String; diff --git a/couchbase-lite/src/appleMain/kotlin/kotbase/DatabaseConfiguration.apple.kt b/couchbase-lite/src/appleMain/kotlin/kotbase/DatabaseConfiguration.apple.kt index 87a5fc9ca..321c354ad 100644 --- a/couchbase-lite/src/appleMain/kotlin/kotbase/DatabaseConfiguration.apple.kt +++ b/couchbase-lite/src/appleMain/kotlin/kotbase/DatabaseConfiguration.apple.kt @@ -21,6 +21,8 @@ import kotbase.internal.DelegatedClass public actual class DatabaseConfiguration internal constructor(actual: CBLDatabaseConfiguration) : DelegatedClass(actual) { + public actual constructor() : this(CBLDatabaseConfiguration()) + public actual constructor(config: DatabaseConfiguration?) : this( CBLDatabaseConfiguration(config?.actual) ) diff --git a/couchbase-lite/src/appleMain/kotlin/kotbase/Parameters.apple.kt b/couchbase-lite/src/appleMain/kotlin/kotbase/Parameters.apple.kt index 76934ddbe..0328ddacd 100644 --- a/couchbase-lite/src/appleMain/kotlin/kotbase/Parameters.apple.kt +++ b/couchbase-lite/src/appleMain/kotlin/kotbase/Parameters.apple.kt @@ -25,6 +25,8 @@ import platform.Foundation.NSNumber public actual class Parameters internal constructor(actual: CBLQueryParameters) : DelegatedClass(actual) { + public actual constructor() : this(CBLQueryParameters()) + public actual constructor(parameters: Parameters?) : this( CBLQueryParameters(parameters?.actual) ) diff --git a/couchbase-lite/src/appleMain/kotlin/kotbase/SessionAuthenticator.apple.kt b/couchbase-lite/src/appleMain/kotlin/kotbase/SessionAuthenticator.apple.kt index aa66b689f..5bcc2d00b 100644 --- a/couchbase-lite/src/appleMain/kotlin/kotbase/SessionAuthenticator.apple.kt +++ b/couchbase-lite/src/appleMain/kotlin/kotbase/SessionAuthenticator.apple.kt @@ -22,6 +22,8 @@ internal constructor( override val actual: CBLSessionAuthenticator ) : Authenticator(actual) { + public actual constructor(sessionID: String) : this(CBLSessionAuthenticator(sessionID)) + public actual constructor(sessionID: String, cookieName: String?) : this( CBLSessionAuthenticator(sessionID, cookieName) ) diff --git a/couchbase-lite/src/commonMain/kotlin/kotbase/DatabaseConfiguration.kt b/couchbase-lite/src/commonMain/kotlin/kotbase/DatabaseConfiguration.kt index 035ffe24a..18b3f116e 100755 --- a/couchbase-lite/src/commonMain/kotlin/kotbase/DatabaseConfiguration.kt +++ b/couchbase-lite/src/commonMain/kotlin/kotbase/DatabaseConfiguration.kt @@ -18,9 +18,11 @@ package kotbase /** * Configuration for opening a database. */ -public expect class DatabaseConfiguration( - config: DatabaseConfiguration? = null -) { +public expect class DatabaseConfiguration { + + public constructor() + + public constructor(config: DatabaseConfiguration?) /** * Set the canonical path of the directory to store the database in. diff --git a/couchbase-lite/src/commonMain/kotlin/kotbase/Parameters.kt b/couchbase-lite/src/commonMain/kotlin/kotbase/Parameters.kt index 79f9a8ab5..e8d0c43f4 100755 --- a/couchbase-lite/src/commonMain/kotlin/kotbase/Parameters.kt +++ b/couchbase-lite/src/commonMain/kotlin/kotbase/Parameters.kt @@ -20,7 +20,11 @@ import kotlinx.datetime.Instant /** * A Parameters object used for setting values to the query parameters defined in the query. */ -public expect class Parameters(parameters: Parameters? = null) { +public expect class Parameters { + + public constructor() + + public constructor(parameters: Parameters?) /** * Gets a parameter's value. diff --git a/couchbase-lite/src/commonMain/kotlin/kotbase/SessionAuthenticator.kt b/couchbase-lite/src/commonMain/kotlin/kotbase/SessionAuthenticator.kt index 3be700596..c8c6185f3 100755 --- a/couchbase-lite/src/commonMain/kotlin/kotbase/SessionAuthenticator.kt +++ b/couchbase-lite/src/commonMain/kotlin/kotbase/SessionAuthenticator.kt @@ -19,16 +19,23 @@ package kotbase * SessionAuthenticator class is an authenticator that will authenticate by using the session ID of * the session created by a Sync Gateway */ -public expect class SessionAuthenticator +public expect class SessionAuthenticator : Authenticator { -/** - * Initializes with the session ID and the cookie name. If the given cookieName - * is null, the default cookie name will be used. - * - * @param sessionID Sync Gateway session ID - * @param cookieName The cookie name - */ -constructor(sessionID: String, cookieName: String? = null) : Authenticator { + /** + * Initializes with the Sync Gateway session ID and uses the default cookie name. + * + * @param sessionID Sync Gateway session ID + */ + public constructor(sessionID: String) + + /** + * Initializes with the session ID and the cookie name. If the given cookieName + * is null, the default cookie name will be used. + * + * @param sessionID Sync Gateway session ID + * @param cookieName The cookie name + */ + public constructor(sessionID: String, cookieName: String?) /** * Return session ID of the session created by a Sync Gateway. diff --git a/couchbase-lite/src/jvmCommonMain/kotlin/kotbase/DatabaseConfiguration.jvmCommon.kt b/couchbase-lite/src/jvmCommonMain/kotlin/kotbase/DatabaseConfiguration.jvmCommon.kt index 62ee61c45..4674e399b 100644 --- a/couchbase-lite/src/jvmCommonMain/kotlin/kotbase/DatabaseConfiguration.jvmCommon.kt +++ b/couchbase-lite/src/jvmCommonMain/kotlin/kotbase/DatabaseConfiguration.jvmCommon.kt @@ -21,6 +21,8 @@ import com.couchbase.lite.DatabaseConfiguration as CBLDatabaseConfiguration public actual class DatabaseConfiguration internal constructor(actual: CBLDatabaseConfiguration) : DelegatedClass(actual) { + public actual constructor() : this(CBLDatabaseConfiguration()) + public actual constructor(config: DatabaseConfiguration?) : this(CBLDatabaseConfiguration(config?.actual)) public actual fun setDirectory(directory: String): DatabaseConfiguration { diff --git a/couchbase-lite/src/jvmCommonMain/kotlin/kotbase/Parameters.jvmCommon.kt b/couchbase-lite/src/jvmCommonMain/kotlin/kotbase/Parameters.jvmCommon.kt index 50267d18d..5ae871b49 100644 --- a/couchbase-lite/src/jvmCommonMain/kotlin/kotbase/Parameters.jvmCommon.kt +++ b/couchbase-lite/src/jvmCommonMain/kotlin/kotbase/Parameters.jvmCommon.kt @@ -23,6 +23,8 @@ import com.couchbase.lite.Parameters as CBLParameters public actual class Parameters internal constructor(actual: CBLParameters) : DelegatedClass(actual) { + public actual constructor() : this(CBLParameters()) + public actual constructor(parameters: Parameters?) : this(CBLParameters(parameters?.actual)) public actual fun getValue(name: String): Any? = diff --git a/couchbase-lite/src/jvmCommonMain/kotlin/kotbase/SessionAuthenticator.jvmCommon.kt b/couchbase-lite/src/jvmCommonMain/kotlin/kotbase/SessionAuthenticator.jvmCommon.kt index b4877251d..ef0001ac7 100644 --- a/couchbase-lite/src/jvmCommonMain/kotlin/kotbase/SessionAuthenticator.jvmCommon.kt +++ b/couchbase-lite/src/jvmCommonMain/kotlin/kotbase/SessionAuthenticator.jvmCommon.kt @@ -22,6 +22,8 @@ internal constructor( override val actual: CBLSessionAuthenticator ) : Authenticator(actual) { + public actual constructor(sessionID: String) : this(CBLSessionAuthenticator(sessionID)) + public actual constructor(sessionID: String, cookieName: String?) : this( CBLSessionAuthenticator(sessionID, cookieName) ) diff --git a/couchbase-lite/src/nativeMain/kotlin/kotbase/DatabaseConfiguration.native.kt b/couchbase-lite/src/nativeMain/kotlin/kotbase/DatabaseConfiguration.native.kt index 695a607d1..c2355a071 100644 --- a/couchbase-lite/src/nativeMain/kotlin/kotbase/DatabaseConfiguration.native.kt +++ b/couchbase-lite/src/nativeMain/kotlin/kotbase/DatabaseConfiguration.native.kt @@ -30,6 +30,8 @@ import kotlin.native.ref.createCleaner public actual class DatabaseConfiguration public actual constructor(config: DatabaseConfiguration?) { + public actual constructor() : this(null) + private val arena = Arena() internal val actual: CPointer = diff --git a/couchbase-lite/src/nativeMain/kotlin/kotbase/Parameters.native.kt b/couchbase-lite/src/nativeMain/kotlin/kotbase/Parameters.native.kt index 77b7f80ab..f77f55772 100644 --- a/couchbase-lite/src/nativeMain/kotlin/kotbase/Parameters.native.kt +++ b/couchbase-lite/src/nativeMain/kotlin/kotbase/Parameters.native.kt @@ -37,6 +37,8 @@ internal constructor( FLDict_Release(it) } + public actual constructor() : this(null) + public actual constructor(parameters: Parameters?) : this( if (parameters != null) { FLDict_MutableCopy(parameters.actual, kFLDefaultCopy) diff --git a/couchbase-lite/src/nativeMain/kotlin/kotbase/SessionAuthenticator.native.kt b/couchbase-lite/src/nativeMain/kotlin/kotbase/SessionAuthenticator.native.kt index 17c5fd165..90aba42d0 100644 --- a/couchbase-lite/src/nativeMain/kotlin/kotbase/SessionAuthenticator.native.kt +++ b/couchbase-lite/src/nativeMain/kotlin/kotbase/SessionAuthenticator.native.kt @@ -27,6 +27,8 @@ private constructor( actual: CPointer ) : Authenticator(actual) { + public actual constructor(sessionID: String) : this(sessionID, null) + public actual constructor(sessionID: String, cookieName: String?) : this( sessionID, cookieName ?: DEFAULT_SYNC_GATEWAY_SESSION_ID_NAME,