Class Structure
This page explains the class structure of the objects that Thing Interaction Framework and its SDK are based on.
Note that the structure presented on this page is the conceptual model unless stated otherwise, so it may be different from the class relationship in the SDK.
Structure of thing-related classes
The following diagram illustrates the structure of thing-related classes. The structure is hidden under the ThingIFAPI class implementation-wise.

- The
Thing, the subject to be controlled, is represented as a subclass of theTarget. Currently, the thing is the only destination for sending commands. The conceptTargetis introduced to expand the destination in the future (i.e., sending commands to mobile applications and other types of devices). - The thing owner is represented as the
Owner, and theUseris defined as its subclass. The conceptOwneris introduced for expanding this relationship in the future (e.g., adding admin accounts). - The
Targetcan have multipleSchema. In the SDK implementation, multiple instances of theThingIFAPIwill be generated and each of them will have one schema. - The
Targetcan have triggers, commands, and state with the multiplicity shown in the diagram.
Structure of command-related classes
The following diagram illustrates the structure of command-related classes.

- As explained in Action and Command Execution, the
Commandhas multipleActionandActionResultinside. - One
Targetis identified as the destination for sending commands. As already explained, theTargetis an abstraction of theThing. In the actual SDK, this is not implemented as a class reference. The SDK has theTargetas an ID.
Structure of trigger-related classes
The following diagram illustrates the structure of thing-related classes.

The
Triggeris a class used for the trigger execution explained in Auto Execution with Triggers.- It has a
PredicateandCommandwhen you are auto-executing a command. - It has a
PredicateandServerCodewhen you are auto-executing server code.
The multiplicity of the
CommandandServerCodemust not be 0 at the same time. They are exclusive, so only one of them can be 1.- It has a
The
Predicatecorresponds to a "predicate" of the predicate logic, and it represents a function that returns if the trigger execution condition is satisfied or not. It can have theStatePredicatethat covers the state comparison based condition, theScheduleOncePredicatethat covers the one-time schedule, and theSchedulePredicatethat covers the recurring schedule.The
Triggerhas aCommandwhen auto-executing the command, but this is merely the template of the command. The actual command for the execution is created using this template.
The next diagram illustrates how the Trigger and subsequent classes are implemented in the SDK. All class names are from the Android SDK. The iOS SDK also has the same structure, but some of the class names are different.

- The relationship between
Predicate,Command, andServerCodeis the same as that of the conceptual model. You will use a pair ofPredicateandCommandorPredicateandServerCode. - The
Predicatehas aStatePredicate,ScheduleOncePredicateandSchedulePredicateas its subclass. - The
StatePredictefor making the state comparison has aConditionandTriggersWheninside. As explained in State Condition, they correspond to the comparison condition (what to compare) and the execution condition (how to associate the condition to the command execution). TheTriggersWhenis the enum implementation-wise, so you will use it as an attribute of the class. - The
ScheduleOncePredicateto designate a time has thescheduleAtattribute inside. As explained in One-Time Schedule, it is a time condition to execute a trigger once. - The
SchedulePredicateto designate a time has thescheduleattribute inside. As explained in Recurring Schedule, it is a time condition to execute a trigger on the scheduled interval. - The
Conditionhas theClausethat is a root of the tree structure. You can define the condition using its subclasses (e.g.,Equals,NotEquals). You can use the recursion for theAndandOr.
Read the development guides (Android, iOS, JavaScript) for more details about the implementation.