You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Janek Bogucki <ya...@studylink.com> on 2004/02/18 11:35:30 UTC

[lang] CharUtils: toCharacterObject, toCharacter -> toCharacter, toChar?

CharUtils features these API methods:

    public static Character toCharacterObject(char ch)
    public static char toCharacter(Character ch)
    public static char toCharacter(String str)

    public static int toInteger(char ch)
    public static int toInteger(Character ch)

Although 'toCharacterObject' is very clear, 'toCharacter' is slightly 
ambiguous unless it is taken in context with 'toCharacterObject'. 
'toCharacter' suggests the return type will be a Character object when it is 
actually char.

As a suggestion, this API would be clearer:

    public static Character toCharacter(char ch)
    public static char toChar(Character ch)
    public static char toChar(String str)

    public static int toInt(char ch)
    public static int toInt(Character ch)


CharUtils is since lang 2.1 so there is no 'published' API to worry about. 
(I've omitted the methods overloaded with defaults but they would also be 
subject to this proposed change.)

As a side benefit of this API change the two 'toString' methods don't need to 
have 'Object' appended to be consistent with 'toCharacterObject':

    public static String toString(char ch)
    public static String toString(Character ch)

i.e. they stay as is instead of becoming:

    public static String toStringObject(char ch)
    public static String toStringObject(Character ch)

-Janek

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org