You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Sebb (JIRA)" <ji...@apache.org> on 2009/12/14 16:04:18 UTC

[jira] Created: (LANG-564) StrLookup API is confused

StrLookup API is confused
-------------------------

                 Key: LANG-564
                 URL: https://issues.apache.org/jira/browse/LANG-564
             Project: Commons Lang
          Issue Type: Bug
            Reporter: Sebb
             Fix For: 3.0


The API for StrLookup is confused. The class has been partly genericised, but why?

The Javadoc says the class is for looking up Strings which are indexed by Strings, and this agrees with the method lookup()

Surely if the class is generic on <V>, the lookup() method should return V, not String?

Does it make any sense for the class to return anything but a String? If not, then why is the class generic?
If it does make sense, then lookup() should return V.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (LANG-564) StrLookup API is confused

Posted by "Matt Benson (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LANG-564?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12794448#action_12794448 ] 

Matt Benson commented on LANG-564:
----------------------------------

+1 for T extends CharSequence for parameters, but to guarantee a T return type would a) require a Class<T> parameter, and b) require us to make assumptions about T+ constructors... so either String or CharSequence (returning String) would still seem the appropriate RT.

> StrLookup API is confused
> -------------------------
>
>                 Key: LANG-564
>                 URL: https://issues.apache.org/jira/browse/LANG-564
>             Project: Commons Lang
>          Issue Type: Bug
>          Components: lang.text.*
>            Reporter: Sebb
>             Fix For: 3.0
>
>
> The API for StrLookup is confused. The class has been partly genericised, but why?
> The Javadoc says the class is for looking up Strings which are indexed by Strings, and this agrees with the method lookup()
> Surely if the class is generic on <V>, the lookup() method should return V, not String?
> Does it make any sense for the class to return anything but a String? If not, then why is the class generic?
> If it does make sense, then lookup() should return V.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (LANG-564) StrLookup API is confused

Posted by "Sebb (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LANG-564?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12790254#action_12790254 ] 

Sebb commented on LANG-564:
---------------------------

Likewise, StrSubstitutor is partially generic.

However, almost all the methods return Strings - none of them return <V> - so why is it generic?

> StrLookup API is confused
> -------------------------
>
>                 Key: LANG-564
>                 URL: https://issues.apache.org/jira/browse/LANG-564
>             Project: Commons Lang
>          Issue Type: Bug
>            Reporter: Sebb
>             Fix For: 3.0
>
>
> The API for StrLookup is confused. The class has been partly genericised, but why?
> The Javadoc says the class is for looking up Strings which are indexed by Strings, and this agrees with the method lookup()
> Surely if the class is generic on <V>, the lookup() method should return V, not String?
> Does it make any sense for the class to return anything but a String? If not, then why is the class generic?
> If it does make sense, then lookup() should return V.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (LANG-564) StrLookup API is confused

Posted by "Joerg Schaible (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LANG-564?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12794437#action_12794437 ] 

Joerg Schaible commented on LANG-564:
-------------------------------------

Or consider using <T extends CharSequence>

> StrLookup API is confused
> -------------------------
>
>                 Key: LANG-564
>                 URL: https://issues.apache.org/jira/browse/LANG-564
>             Project: Commons Lang
>          Issue Type: Bug
>          Components: lang.text.*
>            Reporter: Sebb
>             Fix For: 3.0
>
>
> The API for StrLookup is confused. The class has been partly genericised, but why?
> The Javadoc says the class is for looking up Strings which are indexed by Strings, and this agrees with the method lookup()
> Surely if the class is generic on <V>, the lookup() method should return V, not String?
> Does it make any sense for the class to return anything but a String? If not, then why is the class generic?
> If it does make sense, then lookup() should return V.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (LANG-564) StrLookup API is confused

Posted by "Henri Yandell (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LANG-564?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12801123#action_12801123 ] 

Henri Yandell commented on LANG-564:
------------------------------------

The class is for providing a Str, Str view on a Str, V storage. From the tests:

{code:java}
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("number", new Integer(2));
        assertEquals("2", StrLookup.mapLookup(map).lookup("number"));
{code}

Based on that, the genercizing looks good to me (yeah I know I'm contradicting my previous comment, I hadn't dug into the previous code). I think a bit more javadoc explanation is in need but not a generics change.

> StrLookup API is confused
> -------------------------
>
>                 Key: LANG-564
>                 URL: https://issues.apache.org/jira/browse/LANG-564
>             Project: Commons Lang
>          Issue Type: Bug
>          Components: lang.text.*
>            Reporter: Sebb
>             Fix For: 3.0
>
>
> The API for StrLookup is confused. The class has been partly genericised, but why?
> The Javadoc says the class is for looking up Strings which are indexed by Strings, and this agrees with the method lookup()
> Surely if the class is generic on <V>, the lookup() method should return V, not String?
> Does it make any sense for the class to return anything but a String? If not, then why is the class generic?
> If it does make sense, then lookup() should return V.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (LANG-564) Improve StrLookup API documentation

Posted by "Sebb (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/LANG-564?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Sebb resolved LANG-564.
-----------------------

    Resolution: Fixed

URL: http://svn.apache.org/viewvc?rev=899933&view=rev
Log:
LANG-564 Improve StrLookup API documentation

Modified:
   commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/text/StrLookup.java
   commons/proper/lang/trunk/xdocs/changes.xml

> Improve StrLookup API documentation
> -----------------------------------
>
>                 Key: LANG-564
>                 URL: https://issues.apache.org/jira/browse/LANG-564
>             Project: Commons Lang
>          Issue Type: Bug
>          Components: lang.text.*
>            Reporter: Sebb
>             Fix For: 3.0
>
>
> The API for StrLookup is confused. The class has been partly genericised, but why?
> The Javadoc says the class is for looking up Strings which are indexed by Strings, and this agrees with the method lookup()
> Surely if the class is generic on <V>, the lookup() method should return V, not String?
> Does it make any sense for the class to return anything but a String? If not, then why is the class generic?
> If it does make sense, then lookup() should return V.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (LANG-564) Improve StrLookup API documentation

Posted by "Sebb (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/LANG-564?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Sebb updated LANG-564:
----------------------

    Summary: Improve StrLookup API documentation  (was: StrLookup API is confused)

> Improve StrLookup API documentation
> -----------------------------------
>
>                 Key: LANG-564
>                 URL: https://issues.apache.org/jira/browse/LANG-564
>             Project: Commons Lang
>          Issue Type: Bug
>          Components: lang.text.*
>            Reporter: Sebb
>             Fix For: 3.0
>
>
> The API for StrLookup is confused. The class has been partly genericised, but why?
> The Javadoc says the class is for looking up Strings which are indexed by Strings, and this agrees with the method lookup()
> Surely if the class is generic on <V>, the lookup() method should return V, not String?
> Does it make any sense for the class to return anything but a String? If not, then why is the class generic?
> If it does make sense, then lookup() should return V.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (LANG-564) Improve StrLookup API documentation

Posted by "Sebb (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/LANG-564?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Sebb updated LANG-564:
----------------------

    Comment: was deleted

(was: Likewise, StrSubstitutor is partially generic.

However, almost all the methods return Strings - none of them return <V> - so why is it generic?)

> Improve StrLookup API documentation
> -----------------------------------
>
>                 Key: LANG-564
>                 URL: https://issues.apache.org/jira/browse/LANG-564
>             Project: Commons Lang
>          Issue Type: Bug
>          Components: lang.text.*
>            Reporter: Sebb
>             Fix For: 3.0
>
>
> The API for StrLookup is confused. The class has been partly genericised, but why?
> The Javadoc says the class is for looking up Strings which are indexed by Strings, and this agrees with the method lookup()
> Surely if the class is generic on <V>, the lookup() method should return V, not String?
> Does it make any sense for the class to return anything but a String? If not, then why is the class generic?
> If it does make sense, then lookup() should return V.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (LANG-564) StrLookup API is confused

Posted by "Henri Yandell (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LANG-564?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12794333#action_12794333 ] 

Henri Yandell commented on LANG-564:
------------------------------------

Agreed that this is confused. I think we should roll back the generics changes.

> StrLookup API is confused
> -------------------------
>
>                 Key: LANG-564
>                 URL: https://issues.apache.org/jira/browse/LANG-564
>             Project: Commons Lang
>          Issue Type: Bug
>          Components: lang.text.*
>            Reporter: Sebb
>             Fix For: 3.0
>
>
> The API for StrLookup is confused. The class has been partly genericised, but why?
> The Javadoc says the class is for looking up Strings which are indexed by Strings, and this agrees with the method lookup()
> Surely if the class is generic on <V>, the lookup() method should return V, not String?
> Does it make any sense for the class to return anything but a String? If not, then why is the class generic?
> If it does make sense, then lookup() should return V.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Issue Comment Edited: (LANG-564) StrLookup API is confused

Posted by "Matt Benson (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LANG-564?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12794448#action_12794448 ] 

Matt Benson edited comment on LANG-564 at 12/24/09 3:55 PM:
------------------------------------------------------------

+1 for T extends CharSequence for parameters, but to guarantee a T return type would a) require a Class<T> parameter, and b) require us to make assumptions about constructors of T subclasses... so either String or CharSequence (returning String) would still seem the appropriate RT.

      was (Author: mbenson):
    +1 for T extends CharSequence for parameters, but to guarantee a T return type would a) require a Class<T> parameter, and b) require us to make assumptions about T+ constructors... so either String or CharSequence (returning String) would still seem the appropriate RT.
  
> StrLookup API is confused
> -------------------------
>
>                 Key: LANG-564
>                 URL: https://issues.apache.org/jira/browse/LANG-564
>             Project: Commons Lang
>          Issue Type: Bug
>          Components: lang.text.*
>            Reporter: Sebb
>             Fix For: 3.0
>
>
> The API for StrLookup is confused. The class has been partly genericised, but why?
> The Javadoc says the class is for looking up Strings which are indexed by Strings, and this agrees with the method lookup()
> Surely if the class is generic on <V>, the lookup() method should return V, not String?
> Does it make any sense for the class to return anything but a String? If not, then why is the class generic?
> If it does make sense, then lookup() should return V.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.