Class ThingCode
- java.lang.Object
-
- com.thingworx.types.primitives.structs.ThingCode
-
@ThingworxExtensionApiClass(since={7,1}, canInstantiate=true) public class ThingCode extends java.lang.Object
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.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
DOMAIN_ID
static java.lang.String
INSTANCE_ID
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description int
compare(ThingCode v1, ThingCode v2)
int
compareTo(java.lang.Object value)
static ThingCode
fromJSON(org.json.JSONObject props)
Construct a ThingCode from a JSONObject by performing a lookup for "domainId" and "instanceId".static ThingCode
fromMap(java.util.Map<java.lang.String,java.lang.Object> props)
Construct a ThingCode from a HashMap by performing a lookup for "domainId" and "instanceId".static ThingCode
fromString(java.lang.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.java.lang.Integer
getDomainId()
Get the domain ID of the ThingCode.java.lang.Long
getInstanceId()
Get the instanceId of the ThingCode.boolean
isDefaultValue()
Checks if the ThingCode instance is in its default state.void
setDomainId(java.lang.Integer domainId)
Set the domainId of the ThingCode.void
setInstanceId(java.lang.Long instanceId)
Set the instanceId of the ThingCode.org.json.JSONObject
toJSON()
Construct a new JSONObject from this ThingCode instance.java.util.Map<java.lang.String,java.lang.Object>
toMap()
Construct a new HashMap from this ThingCode instance.java.lang.String
toString()
Construct a String representation of this ThingCode instance.
-
-
-
Field Detail
-
DOMAIN_ID
public static final java.lang.String DOMAIN_ID
- See Also:
- Constant Field Values
-
INSTANCE_ID
public static final java.lang.String INSTANCE_ID
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ThingCode
@ThingworxExtensionApiMethod(since={7,1}) public ThingCode()
Construct a new ThingCode with null values for domainId and instanceId.
-
ThingCode
@ThingworxExtensionApiMethod(since={7,1}) public ThingCode(java.lang.Integer domainId, java.lang.Long instanceId)
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 Detail
-
getDomainId
@ThingworxExtensionApiMethod(since={7,1}) public java.lang.Integer getDomainId()
Get the domain ID of the ThingCode.- Returns:
- The domain ID of the ThingCode
-
setDomainId
@ThingworxExtensionApiMethod(since={7,1}) public void setDomainId(java.lang.Integer domainId)
Set the domainId of the ThingCode.- Parameters:
domainId
- - numerical ID that represents an organization or sub-unit
-
getInstanceId
@ThingworxExtensionApiMethod(since={7,1}) public java.lang.Long getInstanceId()
Get the instanceId of the ThingCode.- Returns:
- The instance ID of the ThingCode
-
setInstanceId
@ThingworxExtensionApiMethod(since={7,1}) public void setInstanceId(java.lang.Long instanceId)
Set the instanceId of the ThingCode.- Parameters:
instanceId
- - numerical ID that represents a unique Thing
-
compareTo
@ThingworxExtensionApiMethod(since={7,1}) public int compareTo(java.lang.Object value)
-
compare
@ThingworxExtensionApiMethod(since={7,1}) public int compare(ThingCode v1, ThingCode v2)
-
fromMap
@ThingworxExtensionApiMethod(since={7,1}) public static ThingCode fromMap(java.util.Map<java.lang.String,java.lang.Object> props)
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
@ThingworxExtensionApiMethod(since={7,1}) public java.util.Map<java.lang.String,java.lang.Object> toMap()
Construct a new HashMap from this ThingCode instance.- Returns:
- A new HashMap containing domain ID and instance ID
-
toJSON
@ThingworxExtensionApiMethod(since={7,1}) public org.json.JSONObject toJSON()
Construct a new JSONObject from this ThingCode instance.- Returns:
- A new JSONObject containing domain ID and instance ID
-
toString
@ThingworxExtensionApiMethod(since={7,1}) public java.lang.String toString()
Construct a String representation of this ThingCode instance.- Overrides:
toString
in classjava.lang.Object
- Returns:
- A String representation of this ThingCode instance containing the domain ID and instance ID separated by ':'
-
isDefaultValue
@ThingworxExtensionApiMethod(since={7,1}) public boolean 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
@ThingworxExtensionApiMethod(since={7,1}) public static ThingCode fromString(java.lang.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.- Parameters:
value
- - String to be parsed- Returns:
- A new ThingCode from the provided value
-
-