brooklyn-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ahgittin <...@git.apache.org>
Subject [GitHub] incubator-brooklyn pull request: BROOKLYN-136: persist dynamic loc...
Date Tue, 17 Mar 2015 19:31:50 GMT
Github user ahgittin commented on a diff in the pull request:

    https://github.com/apache/incubator-brooklyn/pull/555#discussion_r26607509
  
    --- Diff: utils/common/src/main/java/brooklyn/util/yaml/Yamls.java ---
    @@ -66,6 +66,47 @@
             return (T)x;
         }
     
    +    /**
    +     * Parses the given yaml, and walks the given path to return the referenced object.
    +     * 
    +     * @see #getAt(Object, List)
    +     */
    +    public static Object getAt(String yaml, List<String> path) {
    +        Iterable<Object> result = new org.yaml.snakeyaml.Yaml().loadAll(yaml);
    +        Object current = result.iterator().next();
    +        return getAtPreParsed(current, path);
    +    }
    +    
    +    /** 
    +     * For pre-parsed yaml, walks the maps/lists to return the given sub-item.
    +     * In the given path:
    +     * <ul>
    +     *   <li>A vanilla string is assumed to be a key into a map.
    +     *   <li>A string in the form like "[0]" is assumed to be an index into a list
    +     * </ul>
    +     * 
    +     * Returns {@code null} if that path does not exist. 
    +     */
    +    @SuppressWarnings("unchecked")
    +    public static Object getAtPreParsed(Object current, List<String> path) {
    --- End diff --
    
    ugly method name.  if it has already been parsed is there any difference between this
and `Jsonya.of(current).at(path).get()` ?
    
    (at least mark `@Beta`)


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