metron-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mmiklavc <...@git.apache.org>
Subject [GitHub] incubator-metron pull request #445: METRON-706: Add Stellar transformations ...
Date Wed, 08 Feb 2017 18:04:55 GMT
Github user mmiklavc commented on a diff in the pull request:

    https://github.com/apache/incubator-metron/pull/445#discussion_r100129984
  
    --- Diff: metron-platform/metron-common/src/main/java/org/apache/metron/common/utils/ConversionUtils.java
---
    @@ -35,6 +35,14 @@ protected ConvertUtilsBean initialValue() {
         }
       };
     
    +  public static <T> T convertOrFail(Object o, Class<T> clazz) {
    +    if (clazz.isInstance(o)) {
    --- End diff --
    
    Good point. I'm removing this entirely. I'll just use casting in place, e.g.
    
    **Example 1**
    `String val = (String) map.get("foo"); // throws class cast exception on failure, which
is what we want`
    
    **Example 2**
    ```
    Map<Object, Object> a = new HashMap() {{
        put("hello", "world");
        put(1, 2);
    }};
    
    Map<String, Object> b = new HashMap() {{
        put("a", a);
    }};
    Map<Object, Object> c = (Map) b.get("a"); // throws class cast exception if not
a Map
    Map<String, String> d = new HashMap<>();
    for (Map.Entry<Object, Object> entry : c.entrySet()) {
        d.put((String) entry.getKey(), (String) entry.getValue()); // throws class cast exception.
also what we want
    }
    ```



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