# AppFunctionOneOfTypeMetadata

Artifact: [androidx.appfunctions:appfunctions](https://developer.android.com/jetpack/androidx/releases/appfunctions) [View Source](https://cs.android.com/search?q=file:androidx/appfunctions/metadata/AppFunctionDataTypeMetadata.kt+class:androidx.appfunctions.metadata.AppFunctionOneOfTypeMetadata) Added in [1.0.0-rc01](https://developer.android.com/jetpack/androidx/releases/appfunctions#1.0.0-rc01)

*** ** * ** ***


```
public final class AppFunctionOneOfTypeMetadata extends AppFunctionDataTypeMetadata
```

<br />

|---|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object.html) |||
| ↳ | [androidx.appfunctions.metadata.AppFunctionDataTypeMetadata](https://developer.android.com/reference/androidx/appfunctions/metadata/AppFunctionDataTypeMetadata) ||
|   | ↳ | [androidx.appfunctions.metadata.AppFunctionOneOfTypeMetadata](https://developer.android.com/reference/androidx/appfunctions/metadata/AppFunctionOneOfTypeMetadata) |

*** ** * ** ***

Defines the schema for a data type that can be one of several possible types, representing a form of polymorphism or a sealed hierarchy.

An object of this type must match exactly one of the schemas defined in the `https://developer.android.com/reference/androidx/appfunctions/metadata/AppFunctionOneOfTypeMetadata#matchOneOf()` list. This is useful for modeling sealed classes or interfaces where an object can be one of a limited set of subtypes. This implies a hierarchical relationship between the parent type (represented by this `OneOfTypeMetadata`) and its possible concrete implementations in `https://developer.android.com/reference/androidx/appfunctions/metadata/AppFunctionOneOfTypeMetadata#matchOneOf()`.

For example, consider the following sealed interface and its implementations:

```
package com.example.myapp

sealed interface Animal {
    val name: String
}

data class Dog(
    override val name: String,
    val breed: String,
) : Animal

data class Cat(
    override val name: String,
    val livesLeft: Int,
) : Animal
```

The following `https://developer.android.com/reference/androidx/appfunctions/metadata/AppFunctionOneOfTypeMetadata` can be used to define a data type that matches any object implementing the `Animal` interface (i.e., either a `Dog` or a `Cat`).

```
val animalType = AppFunctionOneOfTypeMetadata(
    qualifiedName = "com.example.myapp.Animal",
    matchOneOf = listOf(
        AppFunctionObjectTypeMetadata(
            qualifiedName = "com.example.myapp.Dog",
            properties = mapOf(
                "name" to AppFunctionStringTypeMetadata(...),
                "breed" to AppFunctionStringTypeMetadata(...),
            ),
            required = listOf("name", "breed"),
            isNullable = false,
        ),
        AppFunctionObjectTypeMetadata(
            qualifiedName = "com.example.myapp.Cat",
            properties = mapOf(
                "name" to AppFunctionStringTypeMetadata(...),
                "livesLeft" to AppFunctionIntTypeMetadata(...),
            ),
            required = listOf("name", "livesLeft"),
            isNullable = false,
        ),
    ),
    isNullable = false,
)
```

This data type can be used to define the schema of an input or output type.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/appfunctions/metadata/AppFunctionOneOfTypeMetadata#AppFunctionOneOfTypeMetadata(kotlin.collections.List,kotlin.String,kotlin.Boolean,kotlin.String)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/List.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/appfunctions/metadata/AppFunctionDataTypeMetadata> matchOneOf, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html qualifiedName, boolean isNullable, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html description )` |

| ### Public methods |
|---|---|
| `boolean` | `https://developer.android.com/reference/androidx/appfunctions/metadata/AppFunctionOneOfTypeMetadata#equals(kotlin.Any)(https://developer.android.com/reference/java/lang/Object.html other)` |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/List.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/appfunctions/metadata/AppFunctionDataTypeMetadata>` | `https://developer.android.com/reference/androidx/appfunctions/metadata/AppFunctionOneOfTypeMetadata#getMatchOneOf()()` The list of possible data types that an object can match. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/appfunctions/metadata/AppFunctionOneOfTypeMetadata#getQualifiedName()()` The parent object's qualified name if available. |
| `int` | `https://developer.android.com/reference/androidx/appfunctions/metadata/AppFunctionOneOfTypeMetadata#hashCode()()` |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/appfunctions/metadata/AppFunctionOneOfTypeMetadata#toString()()` |

### Inherited methods

From [androidx.appfunctions.metadata.AppFunctionDataTypeMetadata](https://developer.android.com/reference/androidx/appfunctions/metadata/AppFunctionDataTypeMetadata) `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html` `https://developer.android.com/reference/androidx/appfunctions/metadata/AppFunctionDataTypeMetadata#getDescription()()`

A description of the data type and its intended use.
`final boolean` `https://developer.android.com/reference/androidx/appfunctions/metadata/AppFunctionDataTypeMetadata#isNullable()()`

Whether the data type is nullable.

## Public constructors

### AppFunctionOneOfTypeMetadata

```
public AppFunctionOneOfTypeMetadata(
    @NonNull List<@NonNull AppFunctionDataTypeMetadata> matchOneOf,
    @NonNull String qualifiedName,
    boolean isNullable,
    @NonNull String description
)
```

## Public methods

### equals

```
public boolean equals(Object other)
```

### getMatchOneOf

Added in [1.0.0-rc01](https://developer.android.com/jetpack/androidx/releases/appfunctions#1.0.0-rc01)

```
public final @NonNull List<@NonNull AppFunctionDataTypeMetadata> getMatchOneOf()
```

The list of possible data types that an object can match.

### getQualifiedName

Added in [1.0.0-rc01](https://developer.android.com/jetpack/androidx/releases/appfunctions#1.0.0-rc01)

```
public final @NonNull String getQualifiedName()
```

The parent object's qualified name if available. For example, "com.example.myapp.Animal".

Use this value to set `https://developer.android.com/reference/androidx/appfunctions/AppFunctionData#qualifiedName()` when trying to build the parameters for `https://developer.android.com/reference/androidx/appfunctions/ExecuteAppFunctionRequest`.

### hashCode

```
public int hashCode()
```

### toString

```
public @NonNull String toString()
```