[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GitHub] brooklyn-server pull request #982: Improve coercions esp with generics


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

    https://github.com/apache/brooklyn-server/pull/982#discussion_r214608331
  
    --- Diff: utils/common/src/main/java/org/apache/brooklyn/util/text/StringEscapes.java ---
    @@ -315,12 +320,121 @@ else if (c=='\"') {
                 throw new IllegalArgumentException("String '"+s+"' is not a valid Java string (unterminated string)");
             }
             
    +        /** @deprecated since 1.0.0, use {@link #unwrapJsonishListStringIfPossible(String)} (old semantics)
    +         * or {@link #unwrapJsonishListStringIfPossible(String)} (improved) */
    +        public static List<String> unwrapJsonishListIfPossible(String input) {
    +            return unwrapJsonishListStringIfPossible(input);
    +        }
    +
    +        /** converts a comma separated list in a single string to a list of json primitives or maps, 
    +         * falling back to returning the input.
    +         * <p>
    +         * specifically:
    +         * <li> 1) if of form <code>[ X ]</code> (in brackets after trim), parse as YAML;
    +         *         if parse succeeds return the result, or if parse fails, return {@link Maybe#absent()}.
    +         * <ll> 2) if not of form <code>[ X ]</code>, wrap in brackets and parse as YAML, 
    +         *         and if that succeeds and is a list, return the result.
    +         * <li> 3) otherwise, expect comma-separated tokens which after trimming are of the form "A" or B,
    +         *         where "A" is a valid Java string or C is any string not starting with ' 
    --- End diff --
    
    Could do we rewording. This line introduces `C` - should it be `B`? There was no mention of C previously.


---