You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by "Ash .." <eq...@hotmail.com> on 2003/11/30 20:44:33 UTC

[collections] MapUtils.getXxx() return types

I am curious to know why MapUtils does not have getters that return 
primitive types. Perhaps there was a discussion on whether it was needed or 
not, you could point me to such discussion that took place in the past when 
this class was conceived.
In any case, I think that getters that return primitives could be very 
useful, much more than those that return wrapper objects. Thus, I think we 
could do with methods like:

MapUtils.getDoubleValue(Map map, Object key [,defaultValue]);

If the answer to my question is "you can do a MapUtils.getDouble(map, 
key).doubleValue() and so on",
I would say, having a built-in method enhances the use of this class than 
having a programmer resort to such multiple method call. Of course, the 
internal implementation would do the same, but in the end, client code would 
look far neater.

Let me know,
Ash

_________________________________________________________________
Get Hotmail on your mobile phone http://www.msn.co.uk/msnmobile


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


Re: [collections] MapUtils.getXxx() return types

Posted by Stephen Colebourne <sc...@btopenworld.com>.
This is a very old class in [collections] and pre-dates me. I would probably
oppose adding these methods now. However, now that we have them, I would
support having the primitive methods as you propose. I would only add the
full signature version (with default). That way the method name can just be
getDouble().
Stephen

----- Original Message -----
From: "Ash .." <eq...@hotmail.com>
> I am curious to know why MapUtils does not have getters that return
> primitive types. Perhaps there was a discussion on whether it was needed
or
> not, you could point me to such discussion that took place in the past
when
> this class was conceived.
> In any case, I think that getters that return primitives could be very
> useful, much more than those that return wrapper objects. Thus, I think we
> could do with methods like:
>
> MapUtils.getDoubleValue(Map map, Object key [,defaultValue]);
>
> If the answer to my question is "you can do a MapUtils.getDouble(map,
> key).doubleValue() and so on",
> I would say, having a built-in method enhances the use of this class than
> having a programmer resort to such multiple method call. Of course, the
> internal implementation would do the same, but in the end, client code
would
> look far neater.
>
> Let me know,
> Ash
>
> _________________________________________________________________
> Get Hotmail on your mobile phone http://www.msn.co.uk/msnmobile
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>


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