You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ofbiz.apache.org by "Paul Foxworthy (Commented) (JIRA)" <ji...@apache.org> on 2012/01/10 05:33:47 UTC

[jira] [Commented] (OFBIZ-4427) Possible runtime errors with UtilValidate.isEmpty(Object) should be rather caught during compilation

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

Paul Foxworthy commented on OFBIZ-4427:
---------------------------------------

I've been doing some more thinking about this. I think UtilValidate.isEmpty() should work with an array, as Jacques said. Currently it doesn't.

There is at least one spot where isEmpty is being used with an array: https://fisheye6.atlassian.com/browse/ofbiz/trunk/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayStore.java?hb=true#to1441

That is very misleading code. Anyone reading it would be entitled to assume isEmpty would test for null and for an empty array.

If we do want to support arrays, and we want to remove UtilValidate.isEmpty for any Object in general, then we need to add eight overloaded versions of UtilValidate.isEmpty for arrays of each of the primitive types, plus one more for Object[].

Is that OK in order to achieve the goal of this Jira, or should we give up on compile time checking of calls to isEmpty?

                
> Possible runtime errors with UtilValidate.isEmpty(Object) should be rather caught during compilation
> ----------------------------------------------------------------------------------------------------
>
>                 Key: OFBIZ-4427
>                 URL: https://issues.apache.org/jira/browse/OFBIZ-4427
>             Project: OFBiz
>          Issue Type: Improvement
>          Components: framework
>    Affects Versions: SVN trunk
>            Reporter: Jacques Le Roux
>            Priority: Minor
>              Labels: UtilValidate.isEmpty
>             Fix For: SVN trunk
>
>         Attachments: OFBIZ-4427.patch
>
>
> Hence we need tp remove the UtilValidate.isEmpty(Object) method and provide methods that accept explicit types.  
> Scripting languages should use a facade class that provides methods for working with generic Objects or providing default behaviors.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira