# FactoryRegistry


```
class FactoryRegistry
```

<br />

*** ** * ** ***

A registry of traits and device types to be used by the SDK.

## Summary

| ### Public constructors |
|---|
| `https://developers.home.google.com/reference/kotlin/com/google/home/FactoryRegistry#FactoryRegistry(kotlin.collections.List,kotlin.collections.List)( traits: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-list/index.html<https://developers.home.google.com/reference/kotlin/com/google/home/TraitFactory<https://developers.home.google.com/reference/kotlin/com/google/home/Trait>>, types: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-list/index.html<https://developers.home.google.com/reference/kotlin/com/google/home/DeviceTypeFactory<https://developers.home.google.com/reference/kotlin/com/google/home/DeviceType>> )` |
| `@https://developers.home.google.com/reference/kotlin/com/google/home/annotation/HomeExperimentalApi https://developers.home.google.com/reference/kotlin/com/google/home/FactoryRegistry#FactoryRegistry(kotlin.collections.List,kotlin.collections.List,kotlin.collections.List)( traits: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-list/index.html<https://developers.home.google.com/reference/kotlin/com/google/home/TraitFactory<https://developers.home.google.com/reference/kotlin/com/google/home/Trait>>, types: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-list/index.html<https://developers.home.google.com/reference/kotlin/com/google/home/DeviceTypeFactory<https://developers.home.google.com/reference/kotlin/com/google/home/DeviceType>>, entityTypes: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-list/index.html<https://developers.home.google.com/reference/kotlin/com/google/home/EntityTypeFactory<https://developers.home.google.com/reference/kotlin/com/google/home/HomeEntityType>> )` Creates a registry of `https://developers.home.google.com/reference/kotlin/com/google/home/FactoryRegistry#<init>(kotlin.collections.List,kotlin.collections.List,kotlin.collections.List)`, device `https://developers.home.google.com/reference/kotlin/com/google/home/FactoryRegistry#<init>(kotlin.collections.List,kotlin.collections.List,kotlin.collections.List)` and `https://developers.home.google.com/reference/kotlin/com/google/home/FactoryRegistry#<init>(kotlin.collections.List,kotlin.collections.List,kotlin.collections.List)` to be used by the SDK. |

| ### Public functions |
|---|---|
| `https://developers.home.google.com/reference/kotlin/com/google/home/EventFactory<https://developers.home.google.com/reference/kotlin/com/google/home/Event>?` | `https://developers.home.google.com/reference/kotlin/com/google/home/FactoryRegistry#getEventOrNull(kotlin.String)(eventId: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)` Returns the corresponding EventFactory for the given eventId, or null if FactoryRegistry was not initialized with the event. |
| `https://developers.home.google.com/reference/kotlin/com/google/home/TraitFactory<https://developers.home.google.com/reference/kotlin/com/google/home/Trait>` | `https://developers.home.google.com/reference/kotlin/com/google/home/FactoryRegistry#getTrait(kotlin.String)(traitId: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)` Returns the corresponding TraitFactory for the given traitId, eventId, or commandId. |
| `https://developers.home.google.com/reference/kotlin/com/google/home/TraitFactory<https://developers.home.google.com/reference/kotlin/com/google/home/Trait>?` | `https://developers.home.google.com/reference/kotlin/com/google/home/FactoryRegistry#getTraitOrNull(kotlin.String)(traitId: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)` Returns the corresponding TraitFactory for the given traitId, eventId, or commandId, or null if FactoryRegistry was not initialized with the trait. |
| `https://developers.home.google.com/reference/kotlin/com/google/home/DeviceTypeFactory<https://developers.home.google.com/reference/kotlin/com/google/home/DeviceType>` | `https://developers.home.google.com/reference/kotlin/com/google/home/FactoryRegistry#getType(kotlin.String)(typeId: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)` Returns the corresponding DeviceTypeFactory for the given typeId. |
| `https://developers.home.google.com/reference/kotlin/com/google/home/DeviceTypeFactory<https://developers.home.google.com/reference/kotlin/com/google/home/DeviceType>?` | `https://developers.home.google.com/reference/kotlin/com/google/home/FactoryRegistry#getTypeOrNull(kotlin.String)(typeId: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)` Returns the corresponding DeviceTypeFactory for the given typeId, or null if FactoryRegistry was not initialized with the device type. |

## Public constructors

### FactoryRegistry

```
FactoryRegistry(
    traits: List<TraitFactory<Trait>> = listOf(),
    types: List<DeviceTypeFactory<DeviceType>> = listOf()
)
```

### FactoryRegistry

```
@HomeExperimentalApi
FactoryRegistry(
    traits: List<TraitFactory<Trait>>,
    types: List<DeviceTypeFactory<DeviceType>>,
    entityTypes: List<EntityTypeFactory<HomeEntityType>>
)
```

Creates a registry of `https://developers.home.google.com/reference/kotlin/com/google/home/FactoryRegistry#<init>(kotlin.collections.List,kotlin.collections.List,kotlin.collections.List)`, device `https://developers.home.google.com/reference/kotlin/com/google/home/FactoryRegistry#<init>(kotlin.collections.List,kotlin.collections.List,kotlin.collections.List)` and `https://developers.home.google.com/reference/kotlin/com/google/home/FactoryRegistry#<init>(kotlin.collections.List,kotlin.collections.List,kotlin.collections.List)` to be used by the SDK.

## Public functions

### getEventOrNull

```
fun getEventOrNull(eventId: String): EventFactory<Event>?
```

Returns the corresponding EventFactory for the given eventId, or null if FactoryRegistry was not initialized with the event.

### getTrait

```
fun getTrait(traitId: String): TraitFactory<Trait>
```

Returns the corresponding TraitFactory for the given traitId, eventId, or commandId.

| Throws |
|---|---|
| `https://developers.home.google.com/reference/kotlin/com/google/home/HomeException` | if FactoryRegistry was not initialized with the trait. |

### getTraitOrNull

```
fun getTraitOrNull(traitId: String): TraitFactory<Trait>?
```

Returns the corresponding TraitFactory for the given traitId, eventId, or commandId, or null if FactoryRegistry was not initialized with the trait.

### getType

```
fun getType(typeId: String): DeviceTypeFactory<DeviceType>
```

Returns the corresponding DeviceTypeFactory for the given typeId.

| Throws |
|---|---|
| `https://developers.home.google.com/reference/kotlin/com/google/home/HomeException` | if FactoryRegistry was not initialized with the device type. |

### getTypeOrNull

```
fun getTypeOrNull(typeId: String): DeviceTypeFactory<DeviceType>?
```

Returns the corresponding DeviceTypeFactory for the given typeId, or null if FactoryRegistry was not initialized with the device type.