apex-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gauravgopi123 <...@git.apache.org>
Subject [GitHub] incubator-apex-malhar pull request: - MLHR-1908 Added helper metho...
Date Tue, 17 Nov 2015 18:38:17 GMT
Github user gauravgopi123 commented on a diff in the pull request:

    https://github.com/apache/incubator-apex-malhar/pull/103#discussion_r45099965
  
    --- Diff: library/src/main/java/com/datatorrent/lib/appdata/gpo/GPOUtils.java ---
    @@ -123,6 +123,54 @@ public static GPOMutable deserialize(FieldsDescriptor fieldsDescriptor,
       }
     
       /**
    +   * This method deserializes the fields in the given {@link FieldsDescriptor} into a
map.
    +   * @param fieldsDescriptor The {@link FieldsDescriptor} to fetch fields from.
    +   * @param dpou The {@link JSONObject} which contains the fields whose values need to
be fetched.
    +   * @return A {@link Map} whose keys are field names, and whose values are possible
values for those fields.
    +   */
    +  public static Map<String, Set<Object>> deserializeToMap(FieldsDescriptor
fieldsDescriptor,
    +                                                          JSONObject dpou)
    +  {
    +    Map<String, Set<Object>> keyToValues = Maps.newHashMap();
    +
    +    for (String key : fieldsDescriptor.getFields().getFields()) {
    +      if (!dpou.has(key)) {
    +        throw new IllegalArgumentException("The given key " + key + " is not contained
in the given JSON");
    +      }
    +
    +      Type type = fieldsDescriptor.getType(key);
    --- End diff --
    
    Can this go into if (keyValue instanceof JSONArray) {} loop


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message