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 19:05:13 GMT
Github user gauravgopi123 commented on a diff in the pull request:

    https://github.com/apache/incubator-apex-malhar/pull/103#discussion_r45103964
  
    --- Diff: library/src/main/java/com/datatorrent/lib/appdata/gpo/GPOUtils.java ---
    @@ -178,33 +226,44 @@ public static void setFieldFromJSON(GPOMutable gpo, Type type, String
field, JSO
        */
       public static void setFieldFromJSON(GPOMutable gpo, String field, JSONObject jo)
       {
    -    Type type = gpo.getFieldDescriptor().getType(field);
    +    Object val = getFieldFromJSON(gpo.getFieldDescriptor(), field, jo);
    +    gpo.setFieldGeneric(field, val);
    +  }
    +
    +  /**
    +   * This method gets the given field from the given {@link JSONObject} and converts
the field to an object
    +   * of the type specified in the given {@link FieldsDescriptor}.
    +   * @param fd The {@link FieldsDescriptor} describing the type of each field.
    +   * @param field The field to retrieve from the given {@link JSONObject}.
    +   * @param jo The {@link JSONObject} to retrieve a field from.
    +   * @return The value of the given field converted to an object of the correct type.
    +   */
    +  public static Object getFieldFromJSON(FieldsDescriptor fd, String field, JSONObject
jo)
    +  {
    +    Type type = fd.getType(field);
     
    -    if(type == Type.BOOLEAN) {
    +    if (type == Type.BOOLEAN) {
           Boolean val;
     
           try {
             val = jo.getBoolean(field);
    -      }
    -      catch(JSONException ex) {
    +      } catch (JSONException ex) {
    --- End diff --
    
    why not return jo.getBoolean(field); 
    
    This also should be done for LONG, INTEGER, DOUBLE etc


---
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