From dc7444fc0692d1b30ede8f74a638968e41efdd69 Mon Sep 17 00:00:00 2001 From: Jeff Lockhart Date: Sat, 20 Jan 2024 11:34:49 -0700 Subject: [PATCH] Remove get from Objective-C throws property functions Align with property names for easier discovery Add doc comments --- .../kotlin/kotbase/Collection.apple.kt | 7 +++- .../kotlin/kotbase/Database.apple.kt | 33 +++++++++++++++---- .../kotlin/kotbase/Replicator.apple.kt | 7 ++-- .../appleMain/kotlin/kotbase/Scope.apple.kt | 5 ++- .../commonMain/kotlin/kotbase/Collection.kt | 1 - .../src/commonMain/kotlin/kotbase/Database.kt | 1 - .../commonMain/kotlin/kotbase/Replicator.kt | 4 +-- .../src/commonMain/kotlin/kotbase/Scope.kt | 2 -- 8 files changed, 42 insertions(+), 18 deletions(-) diff --git a/couchbase-lite/src/appleMain/kotlin/kotbase/Collection.apple.kt b/couchbase-lite/src/appleMain/kotlin/kotbase/Collection.apple.kt index 27f2e9cb8..1a97bc89b 100644 --- a/couchbase-lite/src/appleMain/kotlin/kotbase/Collection.apple.kt +++ b/couchbase-lite/src/appleMain/kotlin/kotbase/Collection.apple.kt @@ -225,9 +225,14 @@ internal constructor( }.toSet() } + /** + * Get a list of the names of indices in the collection. + * + * @throws CouchbaseLiteException on failure + */ // For Objective-C/Swift throws @Throws(CouchbaseLiteException::class) - public fun getIndexes(): Set = indexes + public fun indexes(): Set = indexes @Throws(CouchbaseLiteException::class) public actual fun createIndex(name: String, config: IndexConfiguration) { diff --git a/couchbase-lite/src/appleMain/kotlin/kotbase/Database.apple.kt b/couchbase-lite/src/appleMain/kotlin/kotbase/Database.apple.kt index 092b1b1cf..ad18ed6fd 100644 --- a/couchbase-lite/src/appleMain/kotlin/kotbase/Database.apple.kt +++ b/couchbase-lite/src/appleMain/kotlin/kotbase/Database.apple.kt @@ -120,9 +120,14 @@ internal constructor(actual: CBLDatabase) : DelegatedClass(actual), }.asScopes(this) } + /** + * Get scope names that have at least one collection. + * Note: the default scope is exceptional as it will always be listed even though there are no collections + * under it. + */ // For Objective-C/Swift throws @Throws(CouchbaseLiteException::class) - public fun getScopes(): Set = scopes + public fun scopes(): Set = scopes @Throws(CouchbaseLiteException::class) public actual fun getScope(name: String): Scope? { @@ -142,9 +147,12 @@ internal constructor(actual: CBLDatabase) : DelegatedClass(actual), }!!.asScope(this) } + /** + * Get the default scope. + */ // For Objective-C/Swift throws @Throws(CouchbaseLiteException::class) - public fun getDefaultScope(): Scope = defaultScope + public fun defaultScope(): Scope = defaultScope @Throws(CouchbaseLiteException::class) public actual fun createCollection(name: String): Collection { @@ -172,9 +180,12 @@ internal constructor(actual: CBLDatabase) : DelegatedClass(actual), }.asCollections(this) } + /** + * Get all collections in the default scope. + */ // For Objective-C/Swift throws @Throws(CouchbaseLiteException::class) - public fun getCollections(): Set = collections + public fun collections(): Set = collections @Throws(CouchbaseLiteException::class) public actual fun getCollections(scopeName: String?): Set { @@ -208,9 +219,12 @@ internal constructor(actual: CBLDatabase) : DelegatedClass(actual), }!!.asCollection(this) } + /** + * Get the default collection. + */ // For Objective-C/Swift throws @Throws(CouchbaseLiteException::class) - public fun getDefaultCollection(): Collection = defaultCollection + public fun defaultCollection(): Collection = defaultCollection @Throws(CouchbaseLiteException::class) public actual fun deleteCollection(name: String) { @@ -547,14 +561,19 @@ internal constructor(actual: CBLDatabase) : DelegatedClass(actual), } } + /** + * Get a list of the names of indices on the default collection. + * + * @throws CouchbaseLiteException on failure + */ // For Objective-C/Swift throws @Suppress("DEPRECATION") @Deprecated( - "Use defaultCollection.getIndexes()", - ReplaceWith("defaultCollection.getIndexes()") + "Use defaultCollection().indexes()", + ReplaceWith("defaultCollection().indexes()") ) @Throws(CouchbaseLiteException::class) - public fun getIndexes(): List = indexes + public fun indexes(): List = indexes @Deprecated( "Use defaultCollection.createIndex()", diff --git a/couchbase-lite/src/appleMain/kotlin/kotbase/Replicator.apple.kt b/couchbase-lite/src/appleMain/kotlin/kotbase/Replicator.apple.kt index 577d48cc1..80cd7a0bd 100644 --- a/couchbase-lite/src/appleMain/kotlin/kotbase/Replicator.apple.kt +++ b/couchbase-lite/src/appleMain/kotlin/kotbase/Replicator.apple.kt @@ -82,14 +82,17 @@ internal constructor( } } + /** + * Get a best effort set of document IDs in the default collection, that are still pending replication. + */ // For Objective-C/Swift throws @Suppress("DEPRECATION") @Deprecated( "Use getPendingDocumentIds(Collection)", - ReplaceWith("getPendingDocumentIds(config.database.getDefaultCollection())") + ReplaceWith("getPendingDocumentIds(config.database.defaultCollection())") ) @Throws(CouchbaseLiteException::class) - public fun getPendingDocumentIds(): Set = pendingDocumentIds + public fun pendingDocumentIds(): Set = pendingDocumentIds @Suppress("DEPRECATION") @Throws(CouchbaseLiteException::class) diff --git a/couchbase-lite/src/appleMain/kotlin/kotbase/Scope.apple.kt b/couchbase-lite/src/appleMain/kotlin/kotbase/Scope.apple.kt index 46a364a42..86cb9f955 100644 --- a/couchbase-lite/src/appleMain/kotlin/kotbase/Scope.apple.kt +++ b/couchbase-lite/src/appleMain/kotlin/kotbase/Scope.apple.kt @@ -43,9 +43,12 @@ internal constructor( return collections.toSet() } + /** + * Get all collections in the scope. + */ // For Objective-C/Swift throws @Throws(CouchbaseLiteException::class) - public fun getCollections(): Set = collections + public fun collections(): Set = collections @Throws(CouchbaseLiteException::class) public actual fun getCollection(collectionName: String): Collection? { diff --git a/couchbase-lite/src/commonMain/kotlin/kotbase/Collection.kt b/couchbase-lite/src/commonMain/kotlin/kotbase/Collection.kt index ac673352a..e000576c1 100644 --- a/couchbase-lite/src/commonMain/kotlin/kotbase/Collection.kt +++ b/couchbase-lite/src/commonMain/kotlin/kotbase/Collection.kt @@ -255,7 +255,6 @@ public expect class Collection : AutoCloseable { /** * Get a list of the names of indices in the collection. * - * @return the list of index names * @throws CouchbaseLiteException on failure */ @Suppress("WRONG_ANNOTATION_TARGET_WITH_USE_SITE_TARGET") diff --git a/couchbase-lite/src/commonMain/kotlin/kotbase/Database.kt b/couchbase-lite/src/commonMain/kotlin/kotbase/Database.kt index 47fb64b50..6b7b1b475 100755 --- a/couchbase-lite/src/commonMain/kotlin/kotbase/Database.kt +++ b/couchbase-lite/src/commonMain/kotlin/kotbase/Database.kt @@ -534,7 +534,6 @@ public expect class Database : AutoCloseable { /** * Get a list of the names of indices on the default collection. * - * @return the list of index names * @throws CouchbaseLiteException on failure */ @Deprecated( diff --git a/couchbase-lite/src/commonMain/kotlin/kotbase/Replicator.kt b/couchbase-lite/src/commonMain/kotlin/kotbase/Replicator.kt index c5b108ccf..8e1e08967 100755 --- a/couchbase-lite/src/commonMain/kotlin/kotbase/Replicator.kt +++ b/couchbase-lite/src/commonMain/kotlin/kotbase/Replicator.kt @@ -75,9 +75,7 @@ constructor(config: ReplicatorConfiguration) : AutoCloseable { public val serverCertificates: List? /** - * Get a best effort list of documents in the default collection, that are still pending replication. - * - * @return a set of ids for documents in the default collection still awaiting replication. + * Get a best effort set of document IDs in the default collection, that are still pending replication. */ @Deprecated( "Use getPendingDocumentIds(Collection)", diff --git a/couchbase-lite/src/commonMain/kotlin/kotbase/Scope.kt b/couchbase-lite/src/commonMain/kotlin/kotbase/Scope.kt index 2e8b9c46f..3d2d96198 100644 --- a/couchbase-lite/src/commonMain/kotlin/kotbase/Scope.kt +++ b/couchbase-lite/src/commonMain/kotlin/kotbase/Scope.kt @@ -38,8 +38,6 @@ public expect class Scope { /** * Get all collections in the scope. - * - * @return a set of all collections in the scope */ @Suppress("WRONG_ANNOTATION_TARGET_WITH_USE_SITE_TARGET") @get:Throws(CouchbaseLiteException::class)