public abstract class Capability extends java.lang.Object implements java.lang.Iterable<Attribute>
Modifier and Type | Class and Description |
---|---|
static interface |
Capability.AttributeId
Super interface for all AttributeIds used by capability of a resource.
|
static class |
Capability.CapabilityId
Enum mapping all coco-standard capabilityIds and their corresponding capability IDProviders.
|
static interface |
Capability.CommandId
Super interface for all CommandIds in all child Capabilities.
|
static interface |
Capability.CommandStatusListener<T extends Capability.CommandId>
Listener to assist with status of the
sendResourceCommand(Command, CommandStatusListener) . |
Modifier | Constructor and Description |
---|---|
protected |
Capability(int id,
Resource parent)
Constructor of the current class.
|
Modifier and Type | Method and Description |
---|---|
protected void |
clearAndSetStandardCommandSet(int[] commands) |
boolean |
containsAttribute(Capability.AttributeId attributeId) |
protected boolean |
containsAttribute(int attributeId) |
protected Command<? extends Capability.CommandId> |
createCommand(int commandId,
com.google.gson.JsonElement commandParams)
A function to create the command from the Json params.
|
protected <T extends CommandIdInterface> |
createCommandResponseArgs(T commandId,
com.google.gson.JsonElement jsonResponse)
create response args for the command.
|
protected abstract Command<? extends Capability.CommandId> |
extendedCreateCommand(int commandId,
com.google.gson.JsonElement commandParams)
A function to create the command from the Json params.
|
<T extends Attribute> |
getAttribute(Capability.AttributeId attributeId)
This function is used to get the Attribute with the given Id.
|
<T extends Attribute> |
getAttribute(int attributeId)
This function is used to get the Attribute with the given Id.
|
java.util.Map<java.lang.Integer,Attribute> |
getAttributeMap()
This function is used to return the HashMap that the sdk uses to map
the integer id of the attribute to the Attribute Objects.
|
CapabilityWrapper |
getCapabilityWrapper() |
Capability.CapabilityId |
getId()
This function is used to get the unique id of the capability.
|
java.lang.String |
getName()
This function is used to get the Name of the capability.
|
Resource |
getParent()
This function is used to get the parent resource of the current capability.
|
java.util.List<Capability.CommandId> |
getSupportedCommands()
This function fetches the list of commands supported.
|
int |
hashCode() |
protected <T extends Capability.CommandId> |
interceptCommand(Command<T> command) |
protected void |
internalAddAttribute(Attribute attribute) |
protected void |
internalMarkAsReady() |
protected void |
internalRemoveAttribute(int attributeId) |
protected void |
internalSetName(java.lang.String name) |
protected void |
internalSetParent(Resource parent) |
boolean |
isReady()
A function to state if the current capability is updated from
NativeCallbacks.resourceCapabilityCallback(boolean, java.lang.String, long, java.lang.String, int, java.lang.String, int[], java.lang.Object) or by any other way. |
java.util.Iterator<Attribute> |
iterator() |
<T extends Capability.CommandId> |
sendResourceCommand(Command<T> command,
Capability.CommandStatusListener<T> listener)
sendCommands to the current capability.
|
void |
setCapabilityWrapper(CapabilityWrapper capabilityWrapper)
This function sets provided
CapabilityWrapper object. |
boolean |
supports(Capability.CommandId commandId)
This function checks if a command is supported or not, pass
null to check if capability supports any commands at all.
|
java.lang.String |
toString() |
protected Capability(int id, Resource parent)
id
- The unique id Of the capabilityparent
- The parent Resource of the capability.protected <T extends Capability.CommandId> void interceptCommand(Command<T> command)
public final <T extends Capability.CommandId> void sendResourceCommand(Command<T> command, Capability.CommandStatusListener<T> listener)
command
- The command which is to be executed.listener
- Callback of this interface will be triggered.implements a different approach
public boolean supports(Capability.CommandId commandId)
commandId
- The Id denoting the command to be sent.public final Capability.CapabilityId getId()
public final java.lang.String getName()
public final Resource getParent()
public java.util.Map<java.lang.Integer,Attribute> getAttributeMap()
public <T extends Attribute> T getAttribute(int attributeId)
public <T extends Attribute> T getAttribute(Capability.AttributeId attributeId)
protected boolean containsAttribute(int attributeId)
public boolean containsAttribute(Capability.AttributeId attributeId)
protected void internalAddAttribute(Attribute attribute)
protected void internalRemoveAttribute(int attributeId)
protected void internalSetParent(Resource parent)
public void setCapabilityWrapper(CapabilityWrapper capabilityWrapper)
CapabilityWrapper
object.capabilityWrapper
- instance of wrapper object.public CapabilityWrapper getCapabilityWrapper()
public final int hashCode()
hashCode
in class java.lang.Object
public java.util.List<Capability.CommandId> getSupportedCommands()
protected abstract Command<? extends Capability.CommandId> extendedCreateCommand(int commandId, com.google.gson.JsonElement commandParams)
commandId
- The int form of the commandIdcommandParams
- The Json params that can form a commandprotected <T extends CommandIdInterface> CommandResponse.Args<T> createCommandResponseArgs(T commandId, com.google.gson.JsonElement jsonResponse)
commandId
- The command ID which has to be respondedjsonResponse
- The response bodyCommandResponse.Args
protected Command<? extends Capability.CommandId> createCommand(int commandId, com.google.gson.JsonElement commandParams)
commandId
- The int form of the commandIdcommandParams
- The Json params that can form a commandpublic boolean isReady()
NativeCallbacks.resourceCapabilityCallback(boolean, java.lang.String, long, java.lang.String, int, java.lang.String, int[], java.lang.Object)
or by any other way.protected void internalSetName(java.lang.String name)
protected void clearAndSetStandardCommandSet(int[] commands)
protected void internalMarkAsReady()
public java.lang.String toString()
toString
in class java.lang.Object