MatterDeviceTypeFactory

abstract class MatterDeviceTypeFactory<T : DeviceType> : InternalDeviceTypeFactory


Defines the implementation APIs needed for creating types. Types are a collection of optional and required traits. Prevents leaking internal implementation of the traits encoding.

Summary

Public constructors

<T : DeviceType> MatterDeviceTypeFactory(
    typeId: Id,
    traits: List<TraitFactory<*>>
)

Public functions

abstract T
createType(
    metadataBuilder: (List<Trait.TraitMetadata>?) -> DeviceType.Metadata,
    traitProvider: TraitProvider,
    eventProvider: HasEvents
)

Creates a type instance attached with the decoded traits

final operator Boolean
equals(other: Any?)

Equals, ignores the traits and uses id as identity

final Int

ignores the traits and uses id as identity

final String

Protected functions

T?
<T : Trait> Map<TraitFactory<*>, Trait?>.getAs(key: TraitFactory<T>)

Helper methods to deal with the map, protected so it's only used in the scope of implementations of InternalTypeDelegate

T

Public properties

open List<TraitFactory<*>>

the list of traits defined as the type.

open Id

The static type id that this factory builds.

Public constructors

MatterDeviceTypeFactory

<T : DeviceType> MatterDeviceTypeFactory(
    typeId: Id,
    traits: List<TraitFactory<*>> = emptyList()
)
Parameters
typeId: Id

The static type id that this factory builds.

traits: List<TraitFactory<*>> = emptyList()

the list of traits defined as the type.

Public functions

createType

abstract fun createType(
    metadataBuilder: (List<Trait.TraitMetadata>?) -> DeviceType.Metadata,
    traitProvider: TraitProvider,
    eventProvider: HasEvents
): T

Creates a type instance attached with the decoded traits

Parameters
metadataBuilder: (List<Trait.TraitMetadata>?) -> DeviceType.Metadata

the metadata for the device

traitProvider: TraitProvider

the decoded traits, indexed by Factory

equals

final operator fun equals(other: Any?): Boolean

Equals, ignores the traits and uses id as identity

hashCode

final fun hashCode(): Int

ignores the traits and uses id as identity

toString

final fun toString(): String

Protected functions

getAs

protected fun <T : Trait> Map<TraitFactory<*>, Trait?>.getAs(key: TraitFactory<T>): T?

Helper methods to deal with the map, protected so it's only used in the scope of implementations of InternalTypeDelegate

getRequired

protected fun <T : Trait> Map<TraitFactory<*>, Trait?>.getRequired(key: TraitFactory<T>): T

Public properties

traits

open val traitsList<TraitFactory<*>>

the list of traits defined as the type.

typeId

open val typeIdId

The static type id that this factory builds.