diff --git a/firebase-firestore/api/android/firebase-firestore.api b/firebase-firestore/api/android/firebase-firestore.api index 21a2909de..9cf847e6b 100644 --- a/firebase-firestore/api/android/firebase-firestore.api +++ b/firebase-firestore/api/android/firebase-firestore.api @@ -160,8 +160,8 @@ public final class dev/gitlive/firebase/firestore/FieldValue$Companion { public final fun serializer ()Lkotlinx/serialization/KSerializer; } -public abstract class dev/gitlive/firebase/firestore/FieldValueBuilder { - public abstract fun addEncoded (Ljava/lang/Object;)V +public final class dev/gitlive/firebase/firestore/FieldValueBuilder { + public final fun addEncoded (Ljava/lang/Object;)V public final fun addWithStrategy (Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;)V public final fun getBuildSettings ()Lkotlin/jvm/functions/Function1; public final fun setBuildSettings (Lkotlin/jvm/functions/Function1;)V @@ -176,14 +176,13 @@ public final class dev/gitlive/firebase/firestore/FieldValueSerializer : kotlinx public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V } -public abstract class dev/gitlive/firebase/firestore/FieldsAndValuesBuilder { - public fun ()V +public final class dev/gitlive/firebase/firestore/FieldsAndValuesBuilder { public final fun getBuildSettings ()Lkotlin/jvm/functions/Function1; public final fun setBuildSettings (Lkotlin/jvm/functions/Function1;)V public final fun to (Ldev/gitlive/firebase/firestore/FieldPath;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;)V public final fun to (Ljava/lang/String;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;)V - public abstract fun toEncoded (Ldev/gitlive/firebase/firestore/FieldPath;Ljava/lang/Object;)V - public abstract fun toEncoded (Ljava/lang/String;Ljava/lang/Object;)V + public final fun toEncoded (Ldev/gitlive/firebase/firestore/FieldPath;Ljava/lang/Object;)V + public final fun toEncoded (Ljava/lang/String;Ljava/lang/Object;)V } public abstract class dev/gitlive/firebase/firestore/Filter { diff --git a/firebase-firestore/api/jvm/firebase-firestore.api b/firebase-firestore/api/jvm/firebase-firestore.api index 5c628e0aa..6b5abda69 100644 --- a/firebase-firestore/api/jvm/firebase-firestore.api +++ b/firebase-firestore/api/jvm/firebase-firestore.api @@ -160,8 +160,8 @@ public final class dev/gitlive/firebase/firestore/FieldValue$Companion { public final fun serializer ()Lkotlinx/serialization/KSerializer; } -public abstract class dev/gitlive/firebase/firestore/FieldValueBuilder { - public abstract fun addEncoded (Ljava/lang/Object;)V +public final class dev/gitlive/firebase/firestore/FieldValueBuilder { + public final fun addEncoded (Ljava/lang/Object;)V public final fun addWithStrategy (Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;)V public final fun getBuildSettings ()Lkotlin/jvm/functions/Function1; public final fun setBuildSettings (Lkotlin/jvm/functions/Function1;)V @@ -176,14 +176,13 @@ public final class dev/gitlive/firebase/firestore/FieldValueSerializer : kotlinx public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V } -public abstract class dev/gitlive/firebase/firestore/FieldsAndValuesBuilder { - public fun ()V +public final class dev/gitlive/firebase/firestore/FieldsAndValuesBuilder { public final fun getBuildSettings ()Lkotlin/jvm/functions/Function1; public final fun setBuildSettings (Lkotlin/jvm/functions/Function1;)V public final fun to (Ldev/gitlive/firebase/firestore/FieldPath;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;)V public final fun to (Ljava/lang/String;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;)V - public abstract fun toEncoded (Ldev/gitlive/firebase/firestore/FieldPath;Ljava/lang/Object;)V - public abstract fun toEncoded (Ljava/lang/String;Ljava/lang/Object;)V + public final fun toEncoded (Ldev/gitlive/firebase/firestore/FieldPath;Ljava/lang/Object;)V + public final fun toEncoded (Ljava/lang/String;Ljava/lang/Object;)V } public abstract class dev/gitlive/firebase/firestore/Filter { diff --git a/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/FieldValueBuilder.kt b/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/FieldValueBuilder.kt index 626ab89f2..53d5a0d13 100644 --- a/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/FieldValueBuilder.kt +++ b/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/FieldValueBuilder.kt @@ -3,8 +3,9 @@ package dev.gitlive.firebase.firestore import dev.gitlive.firebase.EncodeSettings import kotlinx.serialization.SerializationStrategy -public abstract class FieldValueBuilder internal constructor() { +public class FieldValueBuilder internal constructor() { + internal val fieldValues: MutableList = mutableListOf() public var buildSettings: EncodeSettings.Builder.() -> Unit = { encodeDefaults = true } @@ -18,5 +19,7 @@ public abstract class FieldValueBuilder internal constructor() { } @PublishedApi - internal abstract fun addEncoded(encodedValue: Any) + internal fun addEncoded(encodedValue: Any) { + fieldValues += encodedValue + } } diff --git a/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/FieldsAndValuesBuilder.kt b/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/FieldsAndValuesBuilder.kt index b3886f4f8..aba64b228 100644 --- a/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/FieldsAndValuesBuilder.kt +++ b/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/FieldsAndValuesBuilder.kt @@ -1,10 +1,12 @@ package dev.gitlive.firebase.firestore import dev.gitlive.firebase.EncodeSettings +import dev.gitlive.firebase.firestore.internal.FieldAndValue import kotlinx.serialization.SerializationStrategy -public abstract class FieldsAndValuesBuilder { +public class FieldsAndValuesBuilder internal constructor() { + internal val fieldAndValues: MutableList = mutableListOf() public var buildSettings: EncodeSettings.Builder.() -> Unit = { encodeDefaults = true } @@ -26,8 +28,12 @@ public abstract class FieldsAndValuesBuilder { } @PublishedApi - internal abstract fun String.toEncoded(encodedValue: Any?) + internal fun String.toEncoded(encodedValue: Any?) { + fieldAndValues += FieldAndValue.WithStringField(this, encodedValue) + } @PublishedApi - internal abstract fun FieldPath.toEncoded(encodedValue: Any?) + internal fun FieldPath.toEncoded(encodedValue: Any?) { + fieldAndValues += FieldAndValue.WithFieldPath(this, encodedValue) + } } diff --git a/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/firestore.kt b/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/firestore.kt index 2a5f9ad73..c87f4194c 100644 --- a/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/firestore.kt +++ b/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/firestore.kt @@ -224,7 +224,7 @@ public data class Transaction internal constructor(internal val nativeWrapper: N public fun update( documentRef: DocumentReference, fieldsAndValuesBuilder: FieldsAndValuesBuilder.() -> Unit, - ): Transaction = Transaction(nativeWrapper.updateEncoded(documentRef, dev.gitlive.firebase.firestore.internal.FieldsAndValuesBuilder().apply(fieldsAndValuesBuilder).fieldAndValues)) + ): Transaction = Transaction(nativeWrapper.updateEncoded(documentRef, FieldsAndValuesBuilder().apply(fieldsAndValuesBuilder).fieldAndValues)) @PublishedApi internal fun updateEncoded(documentRef: DocumentReference, encodedData: EncodedObject): Transaction = Transaction(nativeWrapper.updateEncoded(documentRef, encodedData)) @@ -263,7 +263,7 @@ public open class Query internal constructor(internal val nativeQuery: NativeQue } } - public fun startAfter(builder: FieldValueBuilder.() -> Unit): Query = Query(nativeQuery.startAfter(*dev.gitlive.firebase.firestore.internal.FieldValueBuilder().apply(builder).fieldValues.toTypedArray())) + public fun startAfter(builder: FieldValueBuilder.() -> Unit): Query = Query(nativeQuery.startAfter(*FieldValueBuilder().apply(builder).fieldValues.toTypedArray())) public fun startAt(document: DocumentSnapshot): Query = Query(nativeQuery.startAt(document.native)) public fun startAt(vararg fieldValues: Any?): Query = startAt({}, *fieldValues) @@ -275,7 +275,7 @@ public open class Query internal constructor(internal val nativeQuery: NativeQue } } - public fun startAt(builder: FieldValueBuilder.() -> Unit): Query = Query(nativeQuery.startAt(*dev.gitlive.firebase.firestore.internal.FieldValueBuilder().apply(builder).fieldValues.toTypedArray())) + public fun startAt(builder: FieldValueBuilder.() -> Unit): Query = Query(nativeQuery.startAt(*FieldValueBuilder().apply(builder).fieldValues.toTypedArray())) public fun endBefore(document: DocumentSnapshot): Query = Query(nativeQuery.endBefore(document.native)) public fun endBefore(vararg fieldValues: Any?): Query = endBefore({}, *fieldValues) @@ -287,7 +287,7 @@ public open class Query internal constructor(internal val nativeQuery: NativeQue } } - public fun endBefore(builder: FieldValueBuilder.() -> Unit): Query = Query(nativeQuery.endBefore(*dev.gitlive.firebase.firestore.internal.FieldValueBuilder().apply(builder).fieldValues.toTypedArray())) + public fun endBefore(builder: FieldValueBuilder.() -> Unit): Query = Query(nativeQuery.endBefore(*FieldValueBuilder().apply(builder).fieldValues.toTypedArray())) public fun endAt(document: DocumentSnapshot): Query = Query(nativeQuery.endAt(document.native)) public fun endAt(vararg fieldValues: Any?): Query = endAt({}, *fieldValues) @@ -299,7 +299,7 @@ public open class Query internal constructor(internal val nativeQuery: NativeQue } } - public fun endAt(builder: FieldValueBuilder.() -> Unit): Query = Query(nativeQuery.endAt(*dev.gitlive.firebase.firestore.internal.FieldValueBuilder().apply(builder).fieldValues.toTypedArray())) + public fun endAt(builder: FieldValueBuilder.() -> Unit): Query = Query(nativeQuery.endAt(*FieldValueBuilder().apply(builder).fieldValues.toTypedArray())) } @Deprecated("Deprecated in favor of using a [FilterBuilder]", replaceWith = ReplaceWith("where { field equalTo equalTo }", "dev.gitlive.firebase.firestore")) @@ -461,7 +461,7 @@ public data class WriteBatch internal constructor(internal val nativeWrapper: Na ): WriteBatch = WriteBatch( nativeWrapper.updateEncoded( documentRef, - dev.gitlive.firebase.firestore.internal.FieldsAndValuesBuilder().apply(fieldAndValuesBuilder).fieldAndValues, + FieldsAndValuesBuilder().apply(fieldAndValuesBuilder).fieldAndValues, ), ) @@ -633,7 +633,7 @@ public data class DocumentReference internal constructor(internal val native: Na public suspend fun update( fieldsAndValuesBuilder: FieldsAndValuesBuilder.() -> Unit, ) { - native.updateEncoded(dev.gitlive.firebase.firestore.internal.FieldsAndValuesBuilder().apply(fieldsAndValuesBuilder).fieldAndValues) + native.updateEncoded(FieldsAndValuesBuilder().apply(fieldsAndValuesBuilder).fieldAndValues) } public suspend fun delete() { diff --git a/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/internal/FieldValueBuilder.kt b/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/internal/FieldValueBuilder.kt deleted file mode 100644 index 16121a389..000000000 --- a/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/internal/FieldValueBuilder.kt +++ /dev/null @@ -1,15 +0,0 @@ -package dev.gitlive.firebase.firestore.internal - -import kotlin.experimental.ExperimentalObjCName -import kotlin.native.ObjCName - -@OptIn(ExperimentalObjCName::class) -@ObjCName("FieldValueBuilderImpl") -internal class FieldValueBuilder : dev.gitlive.firebase.firestore.FieldValueBuilder() { - - internal val fieldValues: MutableList = mutableListOf() - - override fun addEncoded(encodedValue: Any) { - fieldValues += encodedValue - } -} diff --git a/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/internal/FieldsAndValuesBuilder.kt b/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/internal/FieldsAndValuesBuilder.kt deleted file mode 100644 index 08307d13f..000000000 --- a/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/internal/FieldsAndValuesBuilder.kt +++ /dev/null @@ -1,21 +0,0 @@ -package dev.gitlive.firebase.firestore.internal - -import dev.gitlive.firebase.firestore.FieldPath -import dev.gitlive.firebase.firestore.FieldsAndValuesBuilder -import kotlin.experimental.ExperimentalObjCName -import kotlin.native.ObjCName - -@OptIn(ExperimentalObjCName::class) -@ObjCName("FieldsAndValuesBuilderImpl") -internal class FieldsAndValuesBuilder : FieldsAndValuesBuilder() { - - internal val fieldAndValues: MutableList = mutableListOf() - - override fun String.toEncoded(encodedValue: Any?) { - fieldAndValues += FieldAndValue.WithStringField(this, encodedValue) - } - - override fun FieldPath.toEncoded(encodedValue: Any?) { - fieldAndValues += FieldAndValue.WithFieldPath(this, encodedValue) - } -}