QuerySpecificationBuilder Class
- java.
lang. Object - com.
microsoft. azure. sdk. iot. provisioning. service. configs. QuerySpecificationBuilder
- com.
public class QuerySpecificationBuilder
This is a helper to create a new instance of the QuerySpecification.
This helper will create a query forcing the correct sql format. It expects the SELECT and FROM, but optionally accepts WHERE and GROUP BY. As a result, it will return a QuerySpecification object, accepted by the provisioning service.
Sample:
The follow line will create a QuerySpecification.
QuerySpecification querySpecification = new QuerySpecificationBuilder("*", QuerySpecificationBuilder.FromType.ENROLLMENTS)
.where("iotHubHostName=`ContosoIoTHub.azure-devices.net`").createSqlQuery();
Will generate the sql query:
{
"query":"select * from enrollments where iotHubHostName=`ContosoIoTHub.azure-devices.net`"
}
Constructor Summary
| Constructor | Description |
|---|---|
| QuerySpecificationBuilder(String selection, QuerySpecificationBuilder.FromType fromType) |
CONSTRUCTOR |
Method Summary
| Modifier and Type | Method and Description |
|---|---|
|
Query |
createSqlQuery()
Creates a new instance of the QuerySpecification using the provided clauses to make the sql query. |
|
Query |
groupBy(String groupBy)
Setter for the `group |
|
Query |
where(String where)
Setter for the `where` clause. |
Methods inherited from java.lang.Object
Constructor Details
QuerySpecificationBuilder
public QuerySpecificationBuilder(String selection, QuerySpecificationBuilder.FromType fromType)
CONSTRUCTOR
Creates a new instance of the builder, receiving the mandatory parameters.
Parameters:
String with the mandatory SELECT clause. It cannot be null or empty.
null.
Method Details
createSqlQuery
public QuerySpecification createSqlQuery()
Creates a new instance of the QuerySpecification using the provided clauses to make the sql query.
Returns:
groupBy
public QuerySpecificationBuilder groupBy(String groupBy)
Setter for the `groupBy` clause.
Parameters:
String with the new clause group by. It can be null or empty.
Returns:
QuerySpecificationBuilder.where
public QuerySpecificationBuilder where(String where)
Setter for the `where` clause.
Parameters:
String with the new clause where. It can be null or empty.
Returns:
QuerySpecificationBuilder.