Class ThingCode
java.lang.Object
com.thingworx.types.primitives.structs.ThingCode
BaseType used to handle ThingCodes which are a numerical and unique way to identify a Thing by utilizing two key pieces of information, a
domainId and an instanceId. The domain ID is a positive 32-bit integer which is registered for each organization or
developer requesting one. The instance ID is a positive 64-bit integer that map to a unique Thing.
Default domainId is 0.
Default instanceId is 0.
Default domainId is 0.
Default instanceId is 0.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionint
int
static ThingCode
fromJSON
(org.json.JSONObject props)
Construct a ThingCode from a JSONObject by performing a lookup for "domainId" and "instanceId".static ThingCode
Construct a ThingCode from a HashMap by performing a lookup for "domainId" and "instanceId".static ThingCode
fromString
(String value)
Construct a new ThingCode from a String by splitting the incoming string by ':' then parsing the first string value for domainId and the second string result for instanceId.
Get the domain ID of the ThingCode.
Get the instanceId of the ThingCode.boolean
Checks if the ThingCode instance is in its default state.void
setDomainId
(Integer domainId)
Set the domainId of the ThingCode.void
setInstanceId
(Long instanceId)
Set the instanceId of the ThingCode.org.json.JSONObject
toJSON()
Construct a new JSONObject from this ThingCode instance.toMap()
Construct a new HashMap from this ThingCode instance.toString()
Construct a String representation of this ThingCode instance.
-
Field Details
-
DOMAIN_ID
- See Also:
-
INSTANCE_ID
- See Also:
-
-
Constructor Details
-
ThingCode
Construct a new ThingCode with null values for domainId and instanceId. -
ThingCode
Construct a new ThingCode with the provided domainId and instanceId.- Parameters:
domainId
- - numerical ID that represents an organization or sub-unitinstanceId
- - numerical ID that represents a unique Thing
-
-
Method Details
-
getDomainId
Get the domain ID of the ThingCode.- Returns:
- The domain ID of the ThingCode
-
setDomainId
Set the domainId of the ThingCode.- Parameters:
domainId
- - numerical ID that represents an organization or sub-unit
-
getInstanceId
Get the instanceId of the ThingCode.- Returns:
- The instance ID of the ThingCode
-
setInstanceId
Set the instanceId of the ThingCode.- Parameters:
instanceId
- - numerical ID that represents a unique Thing
-
compareTo
-
compare
-
fromMap
Construct a ThingCode from a HashMap by performing a lookup for "domainId" and "instanceId".- Parameters:
props
- - HashMap of data- Returns:
- A new ThingCode from the provided props
-
fromJSON
@ThingworxExtensionApiMethod(since={7,1}) public static ThingCode fromJSON(org.json.JSONObject props)
Construct a ThingCode from a JSONObject by performing a lookup for "domainId" and "instanceId". If either of these keys are not in the provided JSONObject, the default values for domainId and instanceId will be used.- Parameters:
props
- - JSONObject of data- Returns:
- A new ThingCode from the provided props
-
toMap
Construct a new HashMap from this ThingCode instance.- Returns:
- A new HashMap containing domain ID and instance ID
-
toJSON
Construct a new JSONObject from this ThingCode instance.- Returns:
- A new JSONObject containing domain ID and instance ID
-
toString
Construct a String representation of this ThingCode instance. -
isDefaultValue
Checks if the ThingCode instance is in its default state.- Returns:
- true, if domain ID equals 0 and instance ID equals 0, false otherwise
-
fromString
Construct a new ThingCode from a String by splitting the incoming string by ':' then parsing the first string value for domainId and the second string result for instanceId.- Parameters:
value
- - String to be parsed- Returns:
- A new ThingCode from the provided value
-