public DeviceRegistrationState()

in provisioning/provisioning-service-client/src/main/java/com/microsoft/azure/sdk/iot/provisioning/service/configs/DeviceRegistrationState.java [117:176]


    public DeviceRegistrationState(String json)
    {
        if (json == null || json.isEmpty())
        {
            throw new IllegalArgumentException("JSON with result is null or empty");
        }

        Gson gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().disableHtmlEscaping().create();
        DeviceRegistrationState result = gson.fromJson(json, DeviceRegistrationState.class);

        this.registrationId = result.registrationId;

        if (result.deviceId != null)
        {
            this.deviceId = result.deviceId;
        }

        if (result.createdDateTimeUtcString != null)
        {
            this.createdDateTimeUtc = ParserUtility.getDateTimeUtc(result.createdDateTimeUtcString);
        }

        if (result.lastUpdatedDateTimeUtcString != null)
        {
            this.lastUpdatedDateTimeUtc = ParserUtility.getDateTimeUtc(result.lastUpdatedDateTimeUtcString);
        }

        if (result.assignedHub != null)
        {
            this.assignedHub = result.assignedHub;
        }

        if (result.status == null)
        {
            if (json.contains(QUOTED_STATE_TAG))
            {
                throw new IllegalArgumentException("status is nor valid");
            }
        }
        else
        {
            this.status = result.status;
        }

        if (result.errorCode != null)
        {
            this.errorCode = result.errorCode;
        }

        if (result.errorMessage != null)
        {
            this.errorMessage = result.errorMessage;
        }

        if (result.etag != null)
        {
            ParserUtility.validateStringUTF8(result.etag);
            this.etag = result.etag;
        }
    }