Skip to content

Commit 89670ee

Browse files
committed
Merge branch 'main' into feat/pipeline/public-preview
2 parents f2c4bc3 + a41dfcf commit 89670ee

File tree

27 files changed

+621
-1489
lines changed

27 files changed

+621
-1489
lines changed

.github/workflows/semver-check.yml

Lines changed: 0 additions & 22 deletions
This file was deleted.

firebase-ai/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Unreleased
22

3+
- [changed] Added `equals()` function to `GenerativeBackend`.
4+
35
# 17.7.0
46

57
- [changed] Added `LiveAudioConversationConfig` to control different aspects of the conversation

firebase-ai/src/main/kotlin/com/google/firebase/ai/type/GenerativeBackend.kt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
package com.google.firebase.ai.type
1818

19+
import java.util.Objects
20+
1921
/** Represents a reference to a backend for generative AI. */
2022
public class GenerativeBackend
2123
internal constructor(internal val location: String, internal val backend: GenerativeBackendEnum) {
@@ -40,6 +42,22 @@ internal constructor(internal val location: String, internal val backend: Genera
4042
return GenerativeBackend(location, GenerativeBackendEnum.VERTEX_AI)
4143
}
4244
}
45+
46+
override fun equals(other: Any?): Boolean {
47+
if (other is GenerativeBackend) {
48+
return when (other.backend) {
49+
GenerativeBackendEnum.GOOGLE_AI -> {
50+
other.backend == this.backend
51+
}
52+
GenerativeBackendEnum.VERTEX_AI -> {
53+
other.backend == this.backend && other.location == this.location
54+
}
55+
}
56+
}
57+
return false
58+
}
59+
60+
override fun hashCode(): Int = Objects.hash(this.backend, this.location)
4361
}
4462

4563
internal enum class GenerativeBackendEnum {

firebase-dataconnect/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Unreleased
22

3+
- [changed] Internal refactor for reporting "paths" in response data.
4+
[#7613](https://github.com/firebase/firebase-android-sdk/pull/7613))
5+
36
# 17.1.2
47

58
- [changed] Internal refactor for managing Auth and App Check tokens

firebase-dataconnect/src/main/kotlin/com/google/firebase/dataconnect/DataConnectPathSegment.kt

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,75 @@ public sealed interface DataConnectPathSegment {
5454
override fun toString(): String = index.toString()
5555
}
5656
}
57+
58+
internal typealias DataConnectPath = List<DataConnectPathSegment>
59+
60+
internal fun <T : DataConnectPathSegment> List<T>.toPathString(): String = buildString {
61+
appendPathStringTo(this)
62+
}
63+
64+
internal fun <T : DataConnectPathSegment> List<T>.appendPathStringTo(sb: StringBuilder) {
65+
forEachIndexed { segmentIndex, segment ->
66+
when (segment) {
67+
is DataConnectPathSegment.Field -> {
68+
if (segmentIndex != 0) {
69+
sb.append('.')
70+
}
71+
sb.append(segment.field)
72+
}
73+
is DataConnectPathSegment.ListIndex -> {
74+
sb.append('[')
75+
sb.append(segment.index)
76+
sb.append(']')
77+
}
78+
}
79+
}
80+
}
81+
82+
internal fun MutableList<in DataConnectPathSegment.Field>.addField(
83+
field: String
84+
): DataConnectPathSegment.Field = DataConnectPathSegment.Field(field).also { add(it) }
85+
86+
internal fun MutableList<in DataConnectPathSegment.ListIndex>.addListIndex(
87+
index: Int
88+
): DataConnectPathSegment.ListIndex = DataConnectPathSegment.ListIndex(index).also { add(it) }
89+
90+
internal inline fun <T> MutableList<in DataConnectPathSegment.Field>.withAddedField(
91+
field: String,
92+
block: () -> T
93+
): T = withAddedPathSegment(DataConnectPathSegment.Field(field), block)
94+
95+
internal inline fun <T> MutableList<in DataConnectPathSegment.ListIndex>.withAddedListIndex(
96+
index: Int,
97+
block: () -> T
98+
): T = withAddedPathSegment(DataConnectPathSegment.ListIndex(index), block)
99+
100+
internal inline fun <T, S : DataConnectPathSegment> MutableList<in S>.withAddedPathSegment(
101+
pathSegment: S,
102+
block: () -> T
103+
): T {
104+
add(pathSegment)
105+
try {
106+
return block()
107+
} finally {
108+
val removedSegment = removeLastOrNull()
109+
check(removedSegment === pathSegment) {
110+
"internal error x6tzdsszmc: removed $removedSegment, but expected $pathSegment"
111+
}
112+
}
113+
}
114+
115+
internal fun List<DataConnectPathSegment>.withAddedField(
116+
field: String
117+
): List<DataConnectPathSegment> = withAddedPathSegment(DataConnectPathSegment.Field(field))
118+
119+
internal fun List<DataConnectPathSegment>.withAddedListIndex(
120+
index: Int
121+
): List<DataConnectPathSegment> = withAddedPathSegment(DataConnectPathSegment.ListIndex(index))
122+
123+
internal fun List<DataConnectPathSegment>.withAddedPathSegment(
124+
pathSegment: DataConnectPathSegment
125+
): List<DataConnectPathSegment> = buildList {
126+
addAll(this@withAddedPathSegment)
127+
add(pathSegment)
128+
}

firebase-dataconnect/src/main/kotlin/com/google/firebase/dataconnect/core/DataConnectOperationFailureResponseImpl.kt

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package com.google.firebase.dataconnect.core
1919
import com.google.firebase.dataconnect.DataConnectOperationFailureResponse
2020
import com.google.firebase.dataconnect.DataConnectOperationFailureResponse.ErrorInfo
2121
import com.google.firebase.dataconnect.DataConnectPathSegment
22+
import com.google.firebase.dataconnect.appendPathStringTo
2223
import java.util.Objects
2324

2425
internal class DataConnectOperationFailureResponseImpl<Data>(
@@ -41,24 +42,10 @@ internal class DataConnectOperationFailureResponseImpl<Data>(
4142
override fun hashCode(): Int = Objects.hash("ErrorInfoImpl", message, path)
4243

4344
override fun toString(): String = buildString {
44-
path.forEachIndexed { segmentIndex, segment ->
45-
when (segment) {
46-
is DataConnectPathSegment.Field -> {
47-
if (segmentIndex != 0) {
48-
append('.')
49-
}
50-
append(segment.field)
51-
}
52-
is DataConnectPathSegment.ListIndex -> {
53-
append('[').append(segment.index).append(']')
54-
}
55-
}
56-
}
57-
58-
if (path.isNotEmpty()) {
45+
path.appendPathStringTo(this)
46+
if (isNotEmpty()) {
5947
append(": ")
6048
}
61-
6249
append(message)
6350
}
6451
}

0 commit comments

Comments
 (0)