TableEntity Class
- java.
lang. Object - com.
azure. data. tables. models. TableEntity
- com.
public final class TableEntity
Overview
An entity within a table.
A TableEntity
can be used directly when interacting with the Tables service, with methods on the TableClient and TableAsyncClient classes that accept and return TableEntity
instances. After creating an instance, call the addProperty(String key, Object value) or setProperties(Map<String,Object> properties) methods to add properties to the entity. When retrieving an entity from the service, call the getProperty(String key) or getProperties() methods to access the entity's properties.
Usage Code Samples
The following samples provide examples of common operations preformed on a TableEntity. The samples use a subset of acceptable property values. For an exhaustive list, see the service documentation.
Create a TableEntity
The following sample shows the creation of a table entity.
TableEntity entity = new TableEntity("partitionKey", "rowKey");
Add properties to a TableEntity
The following sample shows the addition of properties to a table entity.
TableEntity entity = new TableEntity("partitionKey", "rowKey");
Set properties from a TableEntity
The following sample shows the setting of a table entity's properties.
Map<String, Object> properties = new HashMap<>();
properties.put("String", "StringValue");
properties.put("Integer", 100);
properties.put("Boolean", true);
TableEntity entity = new TableEntity("partitionKey", "rowKey")
.setProperties(properties);
Get a property from a TableEntity
The following sample shows the retrieval of a property from a table entity.
TableEntity entity = new TableEntity("partitionKey", "rowKey")
.addProperty("String", "StringValue")
.addProperty("Integer", 100)
.addProperty("Boolean", true);
String stringValue = (String) entity.getProperty("String");
int integerValue = (int) entity.getProperty("Integer");
boolean booleanValue = (boolean) entity.getProperty("Boolean");
Get properties from a TableEntity
The following sample shows the retrieval of all properties from a table entity.
TableEntity entity = new TableEntity("partitionKey", "rowKey")
.addProperty("String", "StringValue")
.addProperty("Integer", 100)
.addProperty("Boolean", true);
Map<String, Object> properties = entity.getProperties();
Constructor Summary
Constructor | Description |
---|---|
TableEntity(String partitionKey, String rowKey) |
Construct a new |
Method Summary
Modifier and Type | Method and Description |
---|---|
Table |
addProperty(String key, Object value)
Adds a single property to the entity's properties map. |
String |
getETag()
Gets the entity's e |
String |
getPartitionKey()
Gets the entity's partition key. |
Map<String,Object> |
getProperties()
Gets the map of the entity's properties. |
Object |
getProperty(String key)
Gets a single property from the entity's properties map. |
String |
getRowKey()
Gets the entity's row key. |
Offset |
getTimestamp()
Gets the entity's timestamp. |
Table |
setProperties(Map<String,Object> properties)
Sets the contents of the provided map to the entity's properties map. |
Methods inherited from java.lang.Object
Constructor Details
TableEntity
public TableEntity(String partitionKey, String rowKey)
Construct a new TableEntity
.
Parameters:
Method Details
addProperty
public TableEntity addProperty(String key, Object value)
Adds a single property to the entity's properties map.
Parameters:
Returns:
getETag
public String getETag()
Gets the entity's eTag.
The eTag is automatically populated by the service. New TableEntity
instances will not have an eTag, but an eTag will be present on any TableEntity
returned from the service.
Returns:
getPartitionKey
public String getPartitionKey()
Gets the entity's partition key.
Returns:
getProperties
public Map
Gets the map of the entity's properties.
Only properties that have been added by calling addProperty(String key, Object value) or setProperties(Map<String,Object> properties) will be returned from this method.
Returns:
getProperty
public Object getProperty(String key)
Gets a single property from the entity's properties map.
Only properties that have been added by calling addProperty(String key, Object value) or setProperties(Map<String,Object> properties) will be returned from this method.
Parameters:
Returns:
getRowKey
public String getRowKey()
Gets the entity's row key.
Returns:
getTimestamp
public OffsetDateTime getTimestamp()
Gets the entity's timestamp.
The timestamp is automatically populated by the service. New TableEntity
instances will not have a timestamp, but a timestamp will be present on any TableEntity
returned from the service.
Returns:
setProperties
public TableEntity setProperties(Map
Sets the contents of the provided map to the entity's properties map.
Parameters:
Returns:
Applies to
Azure SDK for Java