1 /*
2  * Copyright 2024 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 /**
20  * Represents a predefined AppFunction schema.
21  *
22  * A schema defines a function's input parameters and output. This class holds identifying
23  * information about a specific, SDK-provided schema.
24  */
25 public class AppFunctionSchemaMetadata(
26     /**
27      * Specifies the category of the schema used by this function. This allows for logical grouping
28      * of schemas. For instance, all schemas related to email functionality would be categorized as
29      * 'email'.
30      */
31     public val category: String,
32     /** The unique name of the schema within its category. */
33     public val name: String,
34     /** The version of the schema. This is used to track the changes to the schema over time. */
35     public val version: Long
36 ) {
equalsnull37     override fun equals(other: Any?): Boolean {
38         if (this === other) return true
39         if (javaClass != other?.javaClass) return false
40 
41         other as AppFunctionSchemaMetadata
42 
43         if (version != other.version) return false
44         if (category != other.category) return false
45         if (name != other.name) return false
46 
47         return true
48     }
49 
hashCodenull50     override fun hashCode(): Int {
51         var result = version.hashCode()
52         result = 31 * result + category.hashCode()
53         result = 31 * result + name.hashCode()
54         return result
55     }
56 
toStringnull57     override fun toString(): String {
58         return "AppFunctionSchemaMetadata(category='$category', name='$name', version=$version)"
59     }
60 }
61