public class Resource extends java.lang.Object implements java.lang.Iterable<Capability>
Device.AddResource,
removed using Device.RemoveResource resource and
force removed using Device.ForceRemoveResource in case if the resource is broken or lost.
Resources by default are added to Default zone.
Resources can be moved from one Zone to another zone using
Network.moveResources(Zone, Zone, Resource[], Network.NetworkManagementStatusListener)
Resource class acts as blueprint for resource belonging to a device. This class encapsulates all information about a resource such as id, name, manufacturer, power source, protocol, parent device, parent zone and capability map etc.
| Modifier | Constructor and Description |
|---|---|
protected |
Resource(java.lang.String eui,
Device parentDevice,
Zone parentZone)
The constructor is protected.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
containsCapability(Capability.CapabilityId capabilityId)
This function assists in checking membership of capability in capability map.
|
<T extends Attribute> |
getAttribute(Capability.AttributeId attrId)
This function is used to return the Attribute object for the given Attribute ID.
|
<T extends Capability> |
getCapability(Capability.CapabilityId capId)
This function is used to return the capability with the given capabilityId.
|
java.util.Map<Capability.CapabilityId,Capability> |
getCapabilityMap()
This function is used to return the HashMap that the sdk uses to map
the CapabilityId to the Capability Objects.
|
java.lang.String |
getFirmware()
This function is used to get the firmware version of the current resource.
|
java.lang.String |
getId()
This function is used to get the unique ID of the resource.
|
java.lang.String |
getManufacturer()
This function is used to get the manufacturer name of the resource.
|
java.lang.String |
getMetadata()
A function to get the metadata of the resource.
|
java.lang.String |
getModel()
This function is used to get the model name of the resource.
|
java.lang.String |
getName()
This function is used to get the name of the resource.
|
<T extends Device> |
getParent()
This function is used to get the Parent device of the resource.
|
<T extends Zone> |
getParentZone()
This function is used to get the Parent zone of the resource.
|
PowerSource |
getPowerSource()
This function is used to know how the resource is being powered.
|
RadioProtocol |
getProtocol()
A function to get protocol used by the use resource.
|
ReceiverType |
getReceiverType()
This function is used to get the receiver properties of the resource.
|
int |
hashCode() |
protected void |
internalAddCapability(Capability capability)
A function that would be triggered when a
Capability is added. |
protected void |
internalMarkAsReady()
A function that would be triggered to mark the resource ready.
|
protected void |
internalRemoveCapability(Capability.CapabilityId capabilityId)
A function that would be triggered when
Capability is removed. |
protected void |
internalRemoveResource()
A function that would be the triggered when this resource is removed.
|
protected void |
internalSetFirmware(java.lang.String firmware)
A function that would be triggered when
firmware is updated. |
protected void |
internalSetManufacturer(java.lang.String manufacturer)
A function that would be triggered when
manufacturer is updated. |
protected void |
internalSetMetadata(java.lang.String metadata)
A function that would be triggered when
metadata is updated. |
protected void |
internalSetModel(java.lang.String model)
A function that would be triggered when
model is updated. |
protected void |
internalSetName(java.lang.String name)
A function that would be triggered when
name is updated. |
protected void |
internalSetParentDevice(Device parentDevice)
A function that would be triggered when
Device.parent is updated. |
protected void |
internalSetParentZone(Zone parentZone)
A function that would be triggered when
Device.parent is updated. |
protected void |
internalSetPowerSource(PowerSource powerSource)
A function that would be triggered when
powerSource is updated. |
protected void |
internalSetProtocol(RadioProtocol protocol)
A function that would be triggered when
protocol is updated. |
protected void |
internalSetReceiverType(ReceiverType receiverType)
A function that would be triggered when
ReceiverType is updated. |
boolean |
isReady()
A function to suggest if the current resource is dummy or not.
|
java.util.Iterator<Capability> |
iterator() |
void |
setMetadata(java.lang.String metadata,
Device.DeviceManagementStatusListener listener)
A function to set the name of the current resource.
|
void |
setName(java.lang.String name,
Device.DeviceManagementStatusListener listener)
A function to set the name of the current resource.
|
java.lang.String |
toString() |
protected Resource(java.lang.String eui,
Device parentDevice,
Zone parentZone)
eui - The unique ID of the resource.parentDevice - The parent device which contains this resource.parentZone - The parent zone which contains this resource.public final java.lang.String getId()
public java.lang.String getName()
public void setName(java.lang.String name,
Device.DeviceManagementStatusListener listener)
resource.setName(resourceName,
(command, resourceImpacted, throwable) -> {
if (null != throwable) {
// client specific code.
}
})
name - The name which has to be set.listener - The listener that will be triggered with callbacks.public java.lang.String getManufacturer()
public java.lang.String getModel()
public java.lang.String getFirmware()
public PowerSource getPowerSource()
PowerSource of the resource.public ReceiverType getReceiverType()
ReceiverType of the resource.public final <T extends Device> T getParent()
T - capture for casting.public final <T extends Zone> T getParentZone()
T - capture for casting.public java.lang.String getMetadata()
public void setMetadata(java.lang.String metadata,
Device.DeviceManagementStatusListener listener)
metadata - The data which has to be stored.listener - The listener that will be triggered with callbacks.public java.util.Map<Capability.CapabilityId,Capability> getCapabilityMap()
public <T extends Capability> T getCapability(Capability.CapabilityId capId)
T - Class to which Capability has to be cast.capId - Capability ID corresponding to
Capability.public <T extends Attribute> T getAttribute(Capability.AttributeId attrId)
T - Class to which Attribute has to be cast.attrId - CapabilityLevel.AttributeId.public boolean containsCapability(Capability.CapabilityId capabilityId)
capabilityId - identifier of the Capabilityprotected void internalAddCapability(Capability capability)
Capability is added.capability - capability that is added to the resource.protected void internalRemoveCapability(Capability.CapabilityId capabilityId)
Capability is removed.capabilityId - ID of the removed capability.public boolean isReady()
protected void internalSetName(java.lang.String name)
name is updated.name - Updated name of the resource.protected void internalSetMetadata(java.lang.String metadata)
metadata is updated.metadata - Updated metadata of the resource.protected void internalSetManufacturer(java.lang.String manufacturer)
manufacturer is updated.manufacturer - Updated manufacturer name.protected void internalSetModel(java.lang.String model)
model is updated.model - Updated model.protected void internalSetFirmware(java.lang.String firmware)
firmware is updated.firmware - Updated firmware version.protected void internalSetPowerSource(PowerSource powerSource)
powerSource is updated.powerSource - Updated power source of the resource.protected void internalSetReceiverType(ReceiverType receiverType)
ReceiverType is updated.receiverType - Updated ReceiverType of the resource.protected void internalSetParentDevice(Device parentDevice)
Device.parent is updated.parentDevice - Updated parent device.protected void internalSetParentZone(Zone parentZone)
Device.parent is updated.parentZone - Updated parent zone.protected void internalMarkAsReady()
protected void internalSetProtocol(RadioProtocol protocol)
protocol is updated.protocol - Updated protocol of the resource.protected void internalRemoveResource()
public RadioProtocol getProtocol()
public final int hashCode()
hashCode in class java.lang.Objectpublic java.util.Iterator<Capability> iterator()
iterator in interface java.lang.Iterable<Capability>public java.lang.String toString()
toString in class java.lang.Object