MatterTraitFactory

class MatterTraitFactory<T : MatterTrait, A : Any> : InternalTraitFactory


Defines the implementation APIs needed for creating traits. Prevents leaking internal implementation of the traits encoding. Example: MatterTraitFactory(Foo.Id, Foo.Adapter, ::Foo)

Summary

Public constructors

<T : MatterTrait, A : Any> MatterTraitFactory(
    clusterId: ClusterId,
    adapter: StructAdapter<A>,
    traitDescriptor: StructDescriptor,
    enumAdapters: Map<StringEnumAdapter<*>>,
    bitmapAdapters: Map<StringBitmapAdapter<*>>,
    creator: (Trait.TraitMetadata, MatterTraitClient, A) -> T,
    supportedEvents: Map<StringEventFactory<*>>,
    commands: Map<StringCommandDescriptor>
)

Public functions

T
createTrait(
    payload: TraitElementPayload,
    metadata: Trait.TraitMetadata,
    client: MatterTraitClient
)

Creates a trait instance attached to the object id specified.

open operator Boolean
equals(other: Any?)
open Int
open String

Public properties

StructAdapter<A>

the struct adapter to read/write attributes

Map<StringBitmapAdapter<*>>
ClusterId

The cluster id that this factory builds.

Map<StringCommandDescriptor>
(Trait.TraitMetadata, MatterTraitClient, A) -> T

a lambda to create an instance of the Semantic Cluster

Map<StringEnumAdapter<*>>
open Map<StringEventFactory<*>>
StructDescriptor
open String

Public constructors

MatterTraitFactory

<T : MatterTrait, A : Any> MatterTraitFactory(
    clusterId: ClusterId,
    adapter: StructAdapter<A>,
    traitDescriptor: StructDescriptor,
    enumAdapters: Map<StringEnumAdapter<*>>,
    bitmapAdapters: Map<StringBitmapAdapter<*>>,
    creator: (Trait.TraitMetadata, MatterTraitClient, A) -> T,
    supportedEvents: Map<StringEventFactory<*>> = emptyMap(),
    commands: Map<StringCommandDescriptor> = emptyMap()
)
Parameters
clusterId: ClusterId

The cluster id that this factory builds.

adapter: StructAdapter<A>

the struct adapter to read/write attributes

creator: (Trait.TraitMetadata, MatterTraitClient, A) -> T

a lambda to create an instance of the Semantic Cluster

Public functions

createTrait

fun createTrait(
    payload: TraitElementPayload,
    metadata: Trait.TraitMetadata,
    client: MatterTraitClient
): T

Creates a trait instance attached to the object id specified. The core object allows calling commands on the trait itself.

Parameters
payload: TraitElementPayload

the object as a json payload

metadata: Trait.TraitMetadata

metadata to be attached to the trait instance

client: MatterTraitClient

the wrapper the trait will use to send commands and write data

equals

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

hashCode

open fun hashCode(): Int

toString

open fun toString(): String

Public properties

adapter

val adapterStructAdapter<A>

the struct adapter to read/write attributes

bitmapAdapters

val bitmapAdaptersMap<StringBitmapAdapter<*>>

clusterId

val clusterIdClusterId

The cluster id that this factory builds.

commands

val commandsMap<StringCommandDescriptor>

creator

val creator: (Trait.TraitMetadata, MatterTraitClient, A) -> T

a lambda to create an instance of the Semantic Cluster

enumAdapters

val enumAdaptersMap<StringEnumAdapter<*>>

supportedEvents

open val supportedEventsMap<StringEventFactory<*>>

traitId

open val traitIdString