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();
</code></pre></p>
Will generate the sql query:
{
"query":"select * from enrollments where iotHubHostName=`ContosoIoTHub.azure-devices.net`"
}
</code></pre></p>
Constructor Summary
Constructor | Description |
---|---|
QuerySpecificationBuilder(String selection, FromType fromType) |
CONSTRUCTOR Creates a new instance of the builder, receiving the mandatory parameters. |
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 `groupBy` clause. |
Query |
where(String where)
Setter for the `where` clause. |
Constructor Details
QuerySpecificationBuilder
public QuerySpecificationBuilder(String selection, FromType fromType)
CONSTRUCTOR
Creates a new instance of the builder, receiving the mandatory parameters.
Parameters:
theString
</code> with the mandatory SELECT clause. It cannot be<code>null
</code> or empty. </p>
the QuerySpecificationBuilder.FromType with the mandatory FROM clause. It cannot benull
</code> . </p>
Throws:
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:
theString
</code> with the new clause `group by`. It can be<code>null
</code> or empty. </p>
Returns:
The same instance of theQuerySpecificationBuilder
</code> . </p>
where
public QuerySpecificationBuilder where(String where)
Setter for the `where` clause.
Parameters:
theString
</code> with the new clause `where`. It can be<code>null
</code> or empty. </p>
Returns:
The same instance of theQuerySpecificationBuilder
</code> . </p>
Applies to
Azure SDK for Java
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for