Github user brightchen commented on a diff in the pull request:

    https://github.com/apache/incubator-apex-malhar/pull/91#discussion_r45138364
  
    --- Diff: 
library/src/main/java/com/datatorrent/lib/appdata/schemas/SchemaUtils.java ---
    @@ -490,5 +493,37 @@ public static JSONObject createJSONObject(Map<String, 
String> map)
         return jo;
       }
     
    +  /**
    +   * This is a helper method which converts the given {@link JSONArray} to 
a {@link List} of Strings.
    +   *
    +   * @param jsonStringArray The {@link JSONArray} to convert.
    +   * @return The converted {@link List} of Strings.
    +   */
    +  public static List<String> getStringsFromJSONArray(JSONArray 
jsonStringArray) throws JSONException
    +  {
    +    List<String> stringArray = 
Lists.newArrayListWithCapacity(jsonStringArray.length());
    +
    +    for (int stringIndex = 0; stringIndex < jsonStringArray.length(); 
stringIndex++) {
    +      stringArray.add(jsonStringArray.getString(stringIndex));
    +    }
    +
    +    return stringArray;
    +  }
    +
    +  /**
    +   * This is a helper method which retrieves the schema tags from the 
{@link JSONObject} if they are present.
    +   *
    +   * @param jo The {@link JSONObject} to retrieve schema tags from.
    +   * @return A list containing the retrieved schema tags. The list is 
empty if there are no schema tags present.
    +   */
    +  public static List<String> getTags(JSONObject jo) throws JSONException
    +  {
    +    if (jo.has(FIELD_TAGS)) {
    +      return getStringsFromJSONArray(jo.getJSONArray(FIELD_TAGS));
    +    } else {
    +      return Lists.newArrayList();
    --- End diff --
    
    what about Collections.emptyList(); which don't need to create new instance


---
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 [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to