in provisioning/provisioning-service-client/src/main/java/com/microsoft/azure/sdk/iot/provisioning/service/configs/IndividualEnrollment.java [295:360]
public IndividualEnrollment(String json)
{
if (json == null || json.isEmpty())
{
throw new IllegalArgumentException("JSON with result is null or empty");
}
Gson gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().disableHtmlEscaping().create();
IndividualEnrollment result = gson.fromJson(json, IndividualEnrollment.class);
this.setRegistrationId(result.registrationId);
this.setAttestation(result.attestation);
if (result.deviceId != null)
{
this.setDeviceId(result.deviceId);
}
if (result.iotHubHostName != null)
{
this.setIotHubHostName(result.iotHubHostName);
}
if (result.provisioningStatus != null)
{
this.setProvisioningStatus(result.provisioningStatus);
}
if (result.deviceRegistrationState != null)
{
this.setDeviceRegistrationState(result.deviceRegistrationState);
}
if (result.initialTwin != null)
{
/*
* During the deserialization process, the GSON will convert both tags and
* properties to a raw Map, which will includes the $version and $metadata
* as part of the collection. So, we need to reorganize this map using the
* TwinCollection format. This constructor will do that.
*/
this.initialTwin = new TwinState(result.initialTwin.getTags(), result.initialTwin.getDesiredProperties());
}
if (result.createdDateTimeUtcString != null)
{
this.setCreatedDateTimeUtcString(result.createdDateTimeUtcString);
}
if (result.lastUpdatedDateTimeUtcString != null)
{
this.setLastUpdatedDateTimeUtcString(result.lastUpdatedDateTimeUtcString);
}
if (result.etag != null)
{
this.setEtag(result.etag);
}
if (result.capabilities != null)
{
this.setCapabilities(result.capabilities);
}
this.setIotHubs(result.getIotHubs());
this.setAllocationPolicy(result.getAllocationPolicy());
this.setCustomAllocationDefinition(result.getCustomAllocationDefinition());
this.setReprovisionPolicy(result.getReprovisionPolicy());
}