diff --git a/firebase-ai/CHANGELOG.md b/firebase-ai/CHANGELOG.md index 7c4c924ab9f..3a1e67a3b2f 100644 --- a/firebase-ai/CHANGELOG.md +++ b/firebase-ai/CHANGELOG.md @@ -1,5 +1,7 @@ # Unreleased +- [changed] Added `equals()` function to `GenerativeBackend`. + # 17.7.0 - [changed] Added `LiveAudioConversationConfig` to control different aspects of the conversation diff --git a/firebase-ai/src/main/kotlin/com/google/firebase/ai/type/GenerativeBackend.kt b/firebase-ai/src/main/kotlin/com/google/firebase/ai/type/GenerativeBackend.kt index 29af741a21e..ca78b73c590 100644 --- a/firebase-ai/src/main/kotlin/com/google/firebase/ai/type/GenerativeBackend.kt +++ b/firebase-ai/src/main/kotlin/com/google/firebase/ai/type/GenerativeBackend.kt @@ -16,6 +16,8 @@ package com.google.firebase.ai.type +import java.util.Objects + /** Represents a reference to a backend for generative AI. */ public class GenerativeBackend internal constructor(internal val location: String, internal val backend: GenerativeBackendEnum) { @@ -40,6 +42,22 @@ internal constructor(internal val location: String, internal val backend: Genera return GenerativeBackend(location, GenerativeBackendEnum.VERTEX_AI) } } + + override fun equals(other: Any?): Boolean { + if (other is GenerativeBackend) { + return when (other.backend) { + GenerativeBackendEnum.GOOGLE_AI -> { + other.backend == this.backend + } + GenerativeBackendEnum.VERTEX_AI -> { + other.backend == this.backend && other.location == this.location + } + } + } + return false + } + + override fun hashCode(): Int = Objects.hash(this.backend, this.location) } internal enum class GenerativeBackendEnum {