List of usage examples for com.google.gson JsonElement toString
@Override
public String toString()
From source file:com.microsoft.azure.sdk.iot.deps.serializer.Twin.java
License:Open Source License
/** * Reset the `desired` properties information in the collection, deleting all old properties and add all the new provided ones. * Return a string with a json that contains a sub-collection of added properties. * * @param propertyMap - Map of `desired` property to change the collection. * @return Json with added properties/* www . j a va2 s . co m*/ * @throws IllegalArgumentException This exception is thrown if the properties in the map do not fits the requirements. */ public String resetDesiredProperty(Map<String, Object> propertyMap) throws IllegalArgumentException { String json; if (propertyMap != null) { /* Codes_SRS_TWIN_21_125: [If the map is invalid, the resetDesiredProperty shall not change the collection and throw IllegalArgumentException.] */ validateMap(propertyMap); /* Codes_SRS_TWIN_21_120: [The resetDesiredProperty shall cleanup the desired collection and add all provided properties to the Desired property.] */ /* Codes_SRS_TWIN_21_123: [The `key` and `value` in property shall be case sensitive.] */ /* Codes_SRS_TWIN_21_124: [If the provided `propertyMap` is empty, the resetDesiredProperty shall cleanup the desired collection and return `{}`.] */ /* Codes_SRS_TWIN_21_129: [If any `value` is null, the resetDesiredProperty shall store it but do not report on Json.] */ JsonElement updatedElements = properties.resetDesired(propertyMap); if (updatedElements == null) { json = "{}"; } else { /* Codes_SRS_TWIN_21_121: [The resetDesiredProperty shall return a string with json representing the added desired properties.] */ json = updatedElements.toString(); } } else { /* Codes_SRS_TWIN_21_122: [If the provided `propertyMap` is null, the resetDesiredProperty shall not change the collection and throw IllegalArgumentException.] */ throw new IllegalArgumentException("Null property map"); } return json; }
From source file:com.microsoft.azure.sdk.iot.deps.serializer.Twin.java
License:Open Source License
/** * Reset the `reported` properties information in the collection, deleting all old properties and add all the new provided ones. * Return a string with a json that contains a sub-collection of added properties. * * @param propertyMap - Map of `reported` property to change the collection. * @return Json with added properties//from w w w . j a v a2 s . c o m * @throws IllegalArgumentException This exception is thrown if the properties in the map do not fits the requirements. */ public String resetReportedProperty(Map<String, Object> propertyMap) throws IllegalArgumentException { String json; if (propertyMap != null) { /* Codes_SRS_TWIN_21_135: [If the map is invalid, the resetReportedProperty shall not change the collection and throw IllegalArgumentException.] */ validateMap(propertyMap); /* Codes_SRS_TWIN_21_130: [The resetReportedProperty shall cleanup the reported collection and add all provided properties to the Reported property.] */ /* Codes_SRS_TWIN_21_133: [The `key` and `value` in property shall be case sensitive.] */ /* Codes_SRS_TWIN_21_134: [If the provided `propertyMap` is empty, the resetReportedProperty shall cleanup the reported collection and return `{}`.] */ /* Codes_SRS_TWIN_21_139: [If any `value` is null, the resetReportedProperty shall store it but do not report on Json.] */ JsonElement updatedElements = properties.resetReported(propertyMap); if (updatedElements == null) { json = "{}"; } else { /* Codes_SRS_TWIN_21_131: [The resetReportedProperty shall return a string with json representing the added reported properties.] */ json = updatedElements.toString(); } } else { /* Codes_SRS_TWIN_21_132: [If the provided `propertyMap` is null, the resetReportedProperty shall not change the collection and throw IllegalArgumentException.] */ throw new IllegalArgumentException("Null property map"); } return json; }
From source file:com.microsoft.azure.sdk.iot.deps.serializer.Twin.java
License:Open Source License
/** * Reset the `tags` information in the collection, deleting all old tags and add all the new provided ones. * Return a string with a json that contains a sub-collection of added tags. * * @param tagsMap - Map of `tags` to change the collection. * @return Json with added tags/*from w w w .ja v a2 s.co m*/ * @throws IllegalArgumentException This exception is thrown if the tags in the map do not fits the requirements. * @throws IOException This exception is thrown if tags the is not enabled. */ public String resetTags(Map<String, Object> tagsMap) throws IllegalArgumentException, IOException { String json; if (tags == null) { /* Codes_SRS_TWIN_21_146: [If Tags is not enable, the resetTags shall throw IOException.] */ throw new IOException("Update not enabled Tags"); } if (tagsMap != null) { /* Codes_SRS_TWIN_21_145: [If the map is invalid, the resetTags shall not change the collection and throw IllegalArgumentException.] */ validateMap(tagsMap); /* Codes_SRS_TWIN_21_140: [The resetTags shall cleanup the tags collection and add all provided tags to the tags.] */ /* Codes_SRS_TWIN_21_143: [The `key` and `value` in tags shall be case sensitive.] */ /* Codes_SRS_TWIN_21_144: [If the provided `tagsMap` is empty, the resetTags shall cleanup the tags collection and return `{}`.] */ /* Codes_SRS_TWIN_21_149: [If any `value` is null, the resetTags shall store it but do not report on Json.] */ tags = new TwinTags(); JsonElement updatedElements = this.tags.update(tagsMap); if (updatedElements == null) { json = "{}"; } else { /* Codes_SRS_TWIN_21_141: [The resetTags shall return a string with json representing the added tags.] */ json = updatedElements.toString(); } } else { /* Codes_SRS_TWIN_21_142: [If the provided `tagsMap` is null, the resetTags shall not change the collection and throw IllegalArgumentException.] */ throw new IllegalArgumentException("Null tags map"); } return json; }
From source file:com.microsoft.azure.sdk.iot.deps.serializer.TwinParser.java
License:Open Source License
/** * Update the `desired` properties information in the collection, and return a string with a json that contains a * sub-collection of added properties, or properties with new value. * * @param propertyMap - Map of `desired` property to change the collection. * @return Json with added or changed properties * @throws IllegalArgumentException This exception is thrown if the properties in the map do not fits the requirements. *///w w w . j a v a 2 s .c o m public String updateDesiredProperty(Map<String, Object> propertyMap) throws IllegalArgumentException { if (propertyMap == null) { /* Codes_SRS_TWINPARSER_21_023: [If the provided `property` map is null, the updateDesiredProperty shall not change the collection and throw IllegalArgumentException.] */ throw new IllegalArgumentException("Null desired property map."); } JsonElement jsonElement = innerUpdateDesiredProperty(propertyMap); if (jsonElement == null) { /* Codes_SRS_TWINPARSER_21_024: [If no Desired property changed its value, the updateDesiredProperty shall return null.] */ /* Codes_SRS_TWINPARSER_21_063: [If the provided `property` map is empty, the updateDesiredProperty shall not change the collection and return null.] */ return null; } return jsonElement.toString(); }
From source file:com.microsoft.azure.sdk.iot.deps.serializer.TwinParser.java
License:Open Source License
/** * Update the `reported` properties information in the collection, and return a string with a json that contains a * sub-collection of added properties, or properties with new value. * * @param propertyMap - Map of `reported` property to change the collection. * @return Json with added or changed properties * @throws IllegalArgumentException This exception is thrown if the properties in the map do not fits the requirements. *///from ww w . j ava2 s . co m public String updateReportedProperty(Map<String, Object> propertyMap) throws IllegalArgumentException { if (propertyMap == null) { /* Codes_SRS_TWINPARSER_21_027: [If the provided `property` map is null, the updateReportedProperty shall not change the collection and throw IllegalArgumentException.] */ throw new IllegalArgumentException("Null reported property map."); } JsonElement jsonElement = innerUpdateReportedProperty(propertyMap); if (jsonElement == null) { /* Codes_SRS_TWINPARSER_21_028: [If no Reported property changed its value, the updateReportedProperty shall return null.] */ return null; } return jsonElement.toString(); }
From source file:com.microsoft.azure.sdk.iot.deps.serializer.TwinParser.java
License:Open Source License
/** * Update the `tags` information in the collection, and return a string with a json that contains a * sub-collection of added tags, or tags with new value. * * @param tagsMap - Map of `tags` to change the collection. * @return Json with added or changed tags * @throws IllegalArgumentException This exception is thrown if the tags in the map do not fits the requirements. * @throws IOException This exception is thrown if tags the is not enabled. *//*ww w. ja v a2 s. c o m*/ public String updateTags(Map<String, Object> tagsMap) throws IllegalArgumentException, IOException { JsonElement jsonElement = innerUpdateTags(tagsMap); if (jsonElement == null) { /* Codes_SRS_TWINPARSER_21_109: [If the provided `tagsMap` is empty, the updateTags shall not change the collection and return null.] */ /* Codes_SRS_TWINPARSER_21_104: [The updateTags shall return a string with json representing the tags with changes.] */ return null; } return jsonElement.toString(); }
From source file:com.microsoft.azure.sdk.iot.deps.serializer.TwinParser.java
License:Open Source License
/** * Reset the `desired` properties information in the collection, deleting all old properties and add all the new provided ones. * Return a string with a json that contains a sub-collection of added properties. * * @param propertyMap - Map of `desired` property to change the collection. * @return Json with added properties//from w w w. ja va 2s.c o m * @throws IllegalArgumentException This exception is thrown if the properties in the map do not fits the requirements. */ public String resetDesiredProperty(Map<String, Object> propertyMap) throws IllegalArgumentException { String json; if (propertyMap != null) { /* Codes_SRS_TWINPARSER_21_125: [If the map is invalid, the resetDesiredProperty shall not change the collection and throw IllegalArgumentException.] */ validateMap(propertyMap); /* Codes_SRS_TWINPARSER_21_120: [The resetDesiredProperty shall cleanup the desired collection and add all provided properties to the Desired property.] */ /* Codes_SRS_TWINPARSER_21_123: [The `key` and `value` in property shall be case sensitive.] */ /* Codes_SRS_TWINPARSER_21_124: [If the provided `propertyMap` is empty, the resetDesiredProperty shall cleanup the desired collection and return `{}`.] */ /* Codes_SRS_TWINPARSER_21_129: [If any `value` is null, the resetDesiredProperty shall store it but do not report on Json.] */ JsonElement updatedElements = properties.resetDesired(propertyMap); if (updatedElements == null) { json = "{}"; } else { /* Codes_SRS_TWINPARSER_21_121: [The resetDesiredProperty shall return a string with json representing the added desired properties.] */ json = updatedElements.toString(); } } else { /* Codes_SRS_TWINPARSER_21_122: [If the provided `propertyMap` is null, the resetDesiredProperty shall not change the collection and throw IllegalArgumentException.] */ throw new IllegalArgumentException("Null property map"); } return json; }
From source file:com.microsoft.azure.sdk.iot.deps.serializer.TwinParser.java
License:Open Source License
/** * Reset the `reported` properties information in the collection, deleting all old properties and add all the new provided ones. * Return a string with a json that contains a sub-collection of added properties. * * @param propertyMap - Map of `reported` property to change the collection. * @return Json with added properties/*from w w w .j a v a 2s . c o m*/ * @throws IllegalArgumentException This exception is thrown if the properties in the map do not fits the requirements. */ public String resetReportedProperty(Map<String, Object> propertyMap) throws IllegalArgumentException { String json; if (propertyMap != null) { /* Codes_SRS_TWINPARSER_21_135: [If the map is invalid, the resetReportedProperty shall not change the collection and throw IllegalArgumentException.] */ validateMap(propertyMap); /* Codes_SRS_TWINPARSER_21_130: [The resetReportedProperty shall cleanup the reported collection and add all provided properties to the Reported property.] */ /* Codes_SRS_TWINPARSER_21_133: [The `key` and `value` in property shall be case sensitive.] */ /* Codes_SRS_TWINPARSER_21_134: [If the provided `propertyMap` is empty, the resetReportedProperty shall cleanup the reported collection and return `{}`.] */ /* Codes_SRS_TWINPARSER_21_139: [If any `value` is null, the resetReportedProperty shall store it but do not report on Json.] */ JsonElement updatedElements = properties.resetReported(propertyMap); if (updatedElements == null) { json = "{}"; } else { /* Codes_SRS_TWINPARSER_21_131: [The resetReportedProperty shall return a string with json representing the added reported properties.] */ json = updatedElements.toString(); } } else { /* Codes_SRS_TWINPARSER_21_132: [If the provided `propertyMap` is null, the resetReportedProperty shall not change the collection and throw IllegalArgumentException.] */ throw new IllegalArgumentException("Null property map"); } return json; }
From source file:com.microsoft.azure.sdk.iot.deps.serializer.TwinParser.java
License:Open Source License
/** * Reset the `tags` information in the collection, deleting all old tags and add all the new provided ones. * Return a string with a json that contains a sub-collection of added tags. * * @param tagsMap - Map of `tags` to change the collection. * @return Json with added tags// www . j av a 2s. co m * @throws IllegalArgumentException This exception is thrown if the tags in the map do not fits the requirements. * @throws IOException This exception is thrown if tags the is not enabled. */ public String resetTags(Map<String, Object> tagsMap) throws IllegalArgumentException, IOException { String json; if (tags == null) { /* Codes_SRS_TWINPARSER_21_146: [If Tags is not enable, the resetTags shall throw IOException.] */ throw new IOException("Update not enabled Tags"); } if (tagsMap != null) { /* Codes_SRS_TWINPARSER_21_145: [If the map is invalid, the resetTags shall not change the collection and throw IllegalArgumentException.] */ validateMap(tagsMap); /* Codes_SRS_TWINPARSER_21_140: [The resetTags shall cleanup the tags collection and add all provided tags to the tags.] */ /* Codes_SRS_TWINPARSER_21_143: [The `key` and `value` in tags shall be case sensitive.] */ /* Codes_SRS_TWINPARSER_21_144: [If the provided `tagsMap` is empty, the resetTags shall cleanup the tags collection and return `{}`.] */ /* Codes_SRS_TWINPARSER_21_149: [If any `value` is null, the resetTags shall store it but do not report on Json.] */ tags = new TwinTags(); JsonElement updatedElements = this.tags.update(tagsMap); if (updatedElements == null) { json = "{}"; } else { /* Codes_SRS_TWINPARSER_21_141: [The resetTags shall return a string with json representing the added tags.] */ json = updatedElements.toString(); } } else { /* Codes_SRS_TWINPARSER_21_142: [If the provided `tagsMap` is null, the resetTags shall not change the collection and throw IllegalArgumentException.] */ throw new IllegalArgumentException("Null tags map"); } return json; }
From source file:com.microsoft.azure.sdk.iot.deps.serializer.TwinTags.java
License:Open Source License
protected synchronized JsonElement update(Map<String, Object> tagsMap) throws IllegalArgumentException { JsonElement innerDiff = updateFromMap(tagsMap, tags); if ((innerDiff == null) || (innerDiff.toString().equals("{}"))) { return null; }/*www. java2 s . c o m*/ return innerDiff; }