Skip to content

Commit

Permalink
Remove get from Objective-C throws property functions
Browse files Browse the repository at this point in the history
Align with property names for easier discovery
Add doc comments
  • Loading branch information
jeffdgr8 committed Jan 22, 2024
1 parent 5fa3de6 commit dc7444f
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> = indexes
public fun indexes(): Set<String> = indexes

@Throws(CouchbaseLiteException::class)
public actual fun createIndex(name: String, config: IndexConfiguration) {
Expand Down
33 changes: 26 additions & 7 deletions couchbase-lite/src/appleMain/kotlin/kotbase/Database.apple.kt
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,14 @@ internal constructor(actual: CBLDatabase) : DelegatedClass<CBLDatabase>(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<Scope> = scopes
public fun scopes(): Set<Scope> = scopes

@Throws(CouchbaseLiteException::class)
public actual fun getScope(name: String): Scope? {
Expand All @@ -142,9 +147,12 @@ internal constructor(actual: CBLDatabase) : DelegatedClass<CBLDatabase>(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 {
Expand Down Expand Up @@ -172,9 +180,12 @@ internal constructor(actual: CBLDatabase) : DelegatedClass<CBLDatabase>(actual),
}.asCollections(this)
}

/**
* Get all collections in the default scope.
*/
// For Objective-C/Swift throws
@Throws(CouchbaseLiteException::class)
public fun getCollections(): Set<Collection> = collections
public fun collections(): Set<Collection> = collections

@Throws(CouchbaseLiteException::class)
public actual fun getCollections(scopeName: String?): Set<Collection> {
Expand Down Expand Up @@ -208,9 +219,12 @@ internal constructor(actual: CBLDatabase) : DelegatedClass<CBLDatabase>(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) {
Expand Down Expand Up @@ -547,14 +561,19 @@ internal constructor(actual: CBLDatabase) : DelegatedClass<CBLDatabase>(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<String> = indexes
public fun indexes(): List<String> = indexes

@Deprecated(
"Use defaultCollection.createIndex()",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> = pendingDocumentIds
public fun pendingDocumentIds(): Set<String> = pendingDocumentIds

@Suppress("DEPRECATION")
@Throws(CouchbaseLiteException::class)
Expand Down
5 changes: 4 additions & 1 deletion couchbase-lite/src/appleMain/kotlin/kotbase/Scope.apple.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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<Collection> = collections
public fun collections(): Set<Collection> = collections

@Throws(CouchbaseLiteException::class)
public actual fun getCollection(collectionName: String): Collection? {
Expand Down
1 change: 0 additions & 1 deletion couchbase-lite/src/commonMain/kotlin/kotbase/Collection.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
1 change: 0 additions & 1 deletion couchbase-lite/src/commonMain/kotlin/kotbase/Database.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
4 changes: 1 addition & 3 deletions couchbase-lite/src/commonMain/kotlin/kotbase/Replicator.kt
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,7 @@ constructor(config: ReplicatorConfiguration) : AutoCloseable {
public val serverCertificates: List<ByteArray>?

/**
* 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)",
Expand Down
2 changes: 0 additions & 2 deletions couchbase-lite/src/commonMain/kotlin/kotbase/Scope.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit dc7444f

Please sign in to comment.