accumulo-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mike Drob (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (ACCUMULO-2490) Pair.fromEntry should accept bounded wild card parameters
Date Tue, 18 Mar 2014 14:19:46 GMT

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

Mike Drob commented on ACCUMULO-2490:
-------------------------------------

Sure.

{code}
    Pair<Integer,String> pair = new Pair<Integer,String>(10, "XX");

    // Doesn't compile:
    // Type mismatch: cannot convert from Map.Entry<capture#1-of ? super Integer,capture#2-of
? super String> to Map.Entry<Integer,String>
    Entry<Integer,String> entry = pair.toMapEntry();

    // does compile but forces the client to use wildcards.
    Entry<? super Integer,? super String> entry2 = pair.toMapEntry();

    // Doesn't compile either:
    Entry<Number,CharSequence> entry3 = pair.toMapEntry();
{code}

> Pair.fromEntry should accept bounded wild card parameters
> ---------------------------------------------------------
>
>                 Key: ACCUMULO-2490
>                 URL: https://issues.apache.org/jira/browse/ACCUMULO-2490
>             Project: Accumulo
>          Issue Type: Improvement
>          Components: client
>            Reporter: Mike Drob
>            Assignee: Christopher Tubbs
>            Priority: Minor
>              Labels: API, newbie
>             Fix For: 1.7.0
>
>
> The following \[psuedo-]code should be legal:
> {code}
> Entry<Integer, String> entry = new Entry(10, "IO")
> Pair<Object,Object> pair = Pair.fromEntry(entry)
> {code}
> This is possible if we replace the generic parameters with bounded wild cards.
> (Effective Java SE; Item 28)



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Mime
View raw message