1 /* 2 * Copyright 2025 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package androidx.appfunctions.metadata 18 19 import androidx.annotation.RestrictTo 20 import androidx.appsearch.annotation.Document 21 22 /** Represents an AppFunction's response metadata. */ 23 public class AppFunctionResponseMetadata( 24 /** The schema of the return value type. */ 25 public val valueType: AppFunctionDataTypeMetadata 26 ) { equalsnull27 override fun equals(other: Any?): Boolean { 28 if (this === other) return true 29 if (javaClass != other?.javaClass) return false 30 31 other as AppFunctionResponseMetadata 32 33 if (valueType != other.valueType) return false 34 35 return true 36 } 37 hashCodenull38 override fun hashCode(): Int { 39 var result = valueType.hashCode() 40 return result 41 } 42 toStringnull43 override fun toString(): String { 44 return "AppFunctionResponseMetadata(valueType=$valueType)" 45 } 46 47 @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) toAppFunctionResponseMetadataDocumentnull48 public fun toAppFunctionResponseMetadataDocument(): AppFunctionResponseMetadataDocument { 49 return AppFunctionResponseMetadataDocument( 50 valueType = valueType.toAppFunctionDataTypeMetadataDocument() 51 ) 52 } 53 } 54 55 /** Represents the persistent storage format of [AppFunctionResponseMetadata]. */ 56 @Document 57 @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) 58 public data class AppFunctionResponseMetadataDocument( 59 @Document.Namespace public val namespace: String = APP_FUNCTION_NAMESPACE, 60 @Document.Id public val id: String = APP_FUNCTION_ID_EMPTY, 61 /** The schema of the return type. */ 62 @Document.DocumentProperty public val valueType: AppFunctionDataTypeMetadataDocument, 63 ) { toAppFunctionResponseMetadatanull64 public fun toAppFunctionResponseMetadata(): AppFunctionResponseMetadata = 65 AppFunctionResponseMetadata(valueType = valueType.toAppFunctionDataTypeMetadata()) 66 } 67