Skip to content

Commit 7887e47

Browse files
authored
feat(ai): add equals() to GenerativeBackend (firebase#7597)
1 parent 8e6f17f commit 7887e47

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

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 {

0 commit comments

Comments
 (0)