[ 
https://issues.apache.org/jira/browse/OFBIZ-6217?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14385222#comment-14385222
 ] 

Adrian Crum edited comment on OFBIZ-6217 at 3/28/15 10:34 AM:
--------------------------------------------------------------

Taher,

Thank you for working on this! One thing has me confused: You make use of the 
UtilGenerics methods in some places, but not in others - where you add a 
@SuppressWarnings annotation instead. Why not always use UtilGenerics?

Example from your patch:

{code}
    @SuppressWarnings("rawtypes")
    public void testJSONToMap() throws Exception {
        Converter<JSON, Map> converter = Converters.getConverter(JSON.class, 
Map.class);
        Map<String,String> map, convertedMap;
        map = new HashMap<String,String>();
        map.put("field1", "value1");
        JSON json = JSON.from(map);
        convertedMap = UtilGenerics.toMap(converter.convert(json));
        assertEquals("JSON to Map", map, convertedMap);
    }
{code}

The @SuppressWarnings annotation is not needed:

{code}
    public void testJSONToMap() throws Exception {
        Converter<JSON, Map<String,String>> converter = 
UtilGenerics.cast(Converters.getConverter(JSON.class, Map.class));
        Map<String,String> map, convertedMap;
        map = new HashMap<String,String>();
        map.put("field1", "value1");
        JSON json = JSON.from(map);
        convertedMap = UtilGenerics.toMap(converter.convert(json));
        assertEquals("JSON to Map", map, convertedMap);
    }
{code}



was (Author: adri...@hlmksw.com):
Taher,

Thank you for working on this! One thing has me confused: You make use of the 
UtilGenerics methods in some places, but not in others - where you add a 
@SuppressWarnings annotation instead. Why not always use UtilGenerics?

Example from your patch:

{code}
    @SuppressWarnings("rawtypes")
    public void testJSONToMap() throws Exception {
        Converter<JSON, Map> converter = Converters.getConverter(JSON.class, 
Map.class);
        Map<String,String> map, convertedMap;
        map = new HashMap<String,String>();
        map.put("field1", "value1");
        JSON json = JSON.from(map);
        convertedMap = UtilGenerics.toMap(converter.convert(json));
        assertEquals("JSON to Map", map, convertedMap);
    }
{code}

The @Suppress annotation is not needed:

{code}
    public void testJSONToMap() throws Exception {
        Converter<JSON, Map<String,String>> converter = 
UtilGenerics.cast(Converters.getConverter(JSON.class, Map.class));
        Map<String,String> map, convertedMap;
        map = new HashMap<String,String>();
        map.put("field1", "value1");
        JSON json = JSON.from(map);
        convertedMap = UtilGenerics.toMap(converter.convert(json));
        assertEquals("JSON to Map", map, convertedMap);
    }
{code}


> fix warnings in trunk on java source code
> -----------------------------------------
>
>                 Key: OFBIZ-6217
>                 URL: https://issues.apache.org/jira/browse/OFBIZ-6217
>             Project: OFBiz
>          Issue Type: Improvement
>          Components: ALL COMPONENTS
>    Affects Versions: Trunk
>            Reporter: Taher Alkhateeb
>            Assignee: Adrian Crum
>            Priority: Minor
>              Labels: java, warning
>             Fix For: Upcoming Branch
>
>         Attachments: remove_unused_imports.patch, warnings_patch_2.patch
>
>
> Right now, we have 528 warnings on trunk out of which 238 are about raw types 
> and 118 never used imports. So we can already eliminate most of the warning 
> quite quickly.
> I will issue multiple patches to resolve most of these warnings. It might be 
> a bit of a challenge to eliminate the raw types because the generics are not 
> always deducable from the code especially when relying on external APIs



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to