ThingWorx Edge Java SDK > Application Details > VirtualThing Component > Defining Properties > Using Annotations
  
Using Annotations
The preferred method of defining properties, services, and events is to use annotations. This section provides examples for properties.
The @ThingWorxPropertyDefinitions annotation contains all the child @ThingWorxPropertyDefinition annotations. Annotations are placed at the beginning of the main code file, after the import and initial statements.
Here are examples that define properties, using annotations to set the name, description, and baseType attributes as well as the set of aspects. You can find this code in the SimpleThing.java sample file
The first property (Temperature) is set up for collecting time series data. Each value that is collected is pushed to the ThingWorx platform from within the processScanRequest() method. Since pushType is set to ALWAYS and isFolded is set to FALSE, all updates of this property are pushed to the server, whether or not the value changed. The value of cacheTime is -1, which means that the value is not cached. Instead, it is always read from the remote device. Finally, note that isPersistent is set to FALSE, so the platform does not persist the values.
@ThingWorxPropertyDefinition(name="Temperature",
description=="The device temperature",
baseType="NUMBER",
aspects={"dataChangeType:NEVER",
"dataChangeThreshold:0",
"cacheTime:-1",
"isPersistent:FALSE",
"isReadOnly:FALSE",
"pushType:ALWAYS",
"isFolded:FALSE",
"defaultValue:0")),
The second property (Humidity) is also pushed to the platform, but only when the value changes ("dataChangeType:NEVER"). The value of cacheTime is -1, so that the value is never cached; it is always read from the remote device. Since isFolded is not set, the default value (TRUE) is used. Only the last value set is pushed to the platform when updateSubscribedProperties is called.
@ThingWorxPropertyDefinition(name="Humidity",
description="The humidity at the device ",
baseType="NUMBER",
aspects={"dataChangeType:VALUE",
"dataChangeThreshold:0",
"cacheTime:-1",
"isPersistent:FALSE",
"isReadOnly:FALSE",
"pushType:VALUE",
"defaultValue:0"}),
The third property (SetPoint) provides the optimal temperature for the thing. This property is never pushed to the platform (dataChangeThreshold and pushType aspects are both set to NEVER). The cacheTime is set to 0, which means that the property is never read from the remote device. Instead, the property value is always pushed, using the updateSubscribedProperties method. In addition, the value is never read from the cache. the platform always requests the current value from the client application. The setting for isPersistent is TRUE, meaning that the value is persisted on the platform. If this value is displayed in a mashup, for example, a service can always see what temperature is considered best for the thing.
@ThingWorxPropertyDefinition(name="SetPoint",
description="The desired temperature",
baseType="NUMBER",
aspects={"dataChangeType:NEVERA",
"dataChangeThreshold:0",
"cacheTime:0",
"isPersistent:TRUE",
"isReadOnly:FALSE",
"pushType:NEVER",
"defaultValue:70"}),