[ 
https://issues.apache.org/jira/browse/SLING-602?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12620157#action_12620157
 ] 

Andreas Vogl commented on SLING-602:
------------------------------------

I think supporting more primitive types would be great.

Integer and Float are probably the most convenient to have, but it can't hurt 
to support Byte and Short too.

Personally I don't see data loss as a big issue in regard to Integer and Float. 
In most cases the number values an editor will type into a web site are not 
going to exceed integer range. Maybe it is more an issue for smaller types such 
as Short and Byte.

It could be helpful to make a check if data loss will happen with the downcast 
and in that case return the maximum value of the wrapper type. This would 
ensure that always as reasonable value is returned.

> ValueMap#get(java.lang.String name, T defaultValue) should support Integer
> --------------------------------------------------------------------------
>
>                 Key: SLING-602
>                 URL: https://issues.apache.org/jira/browse/SLING-602
>             Project: Sling
>          Issue Type: Wish
>         Environment: Windows XP, Sling Version 2.0.3-incubator-SNAPSHOT 
> (running of Communiqué5)
>            Reporter: Andreas Vogl
>            Priority: Minor
>
> Hi,
> Working with the sling API, I've been using the ValueMap class rather 
> frequently:
> org.apache.sling.api.resource.ValueMap
> I noticed that the type java.util.Lang is supported for the getter methods, 
> but the type java.util.Integer is apparently not supported.
> The getter methods i am referring to:
> <T> T get(java.lang.String name, java.lang.Class<T> type)
> <T> T get(java.lang.String name, T defaultValue) 
>  
> Personally I would find it very convenient to be able to pass integers as 
> default values and also get an integer as return type.
> Apart from the convenience aspect, the lack of Integer support is really a 
> source for bugs: It's intuitive to pass Integers - it will compile fine but 
> not work in the end.

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

Reply via email to