commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Gary D. Gregory (Commented) (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (LANG-790) Null safe Navigation in ObjectUtils
Date Wed, 07 Mar 2012 16:40:58 GMT

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

Gary D. Gregory commented on LANG-790:
--------------------------------------

"IMO, the request is not for another expression language or interpreter, it is for just an
utility method for easy navigation."

That does not make sense to me, when you have a string that maps to a sequence of method executions
that does not involve code generation, then you gave an interpreter.

"if(a!=null && a.getB()!=null && a.getB().getC())"

For this kind of code, you have to ask yourself if null is a legal value in the model or a
programming/configuration error where an NPE or IAE would be justified.

"JavaScript in Java6 - I guess this is not a solution for the problem we are trying to solve
in Java, converting Java Object to java script object each time may not be a good choice,
if this is the choice even we can use groovy or any other languages supported by JVM to solve
this problem, the main objective is to find easy solution with in java not outside."

Scripting *is* part of Java, and the JS engine is in Java so I am not sure what conversion
you are talking about. Like you say and this is true in general, this "may not be a good choice"
but is might just as well be a "good choice". You won't know until you try. By the same logic,
the solution you propose might not be a good choice either! You'll only know when you compare
both solutions. If you want to take the time to do that, please go ahead, I'm sure the results
would be interesting :)


"for your question on Arrays, Collections, Maps --> when we can navigate an object safely
on nulls, we can do so in these as well, after all they are all just group of Objects."

Uh? So *are* proposing to already augment the syntax to support "[]" addressing?

"for your question on Private Methods --> I am not sure what is your point with Private
methods."

Should your "." be allowed to access private fields and methods?

"for your point on Full Interpreter --> I am not sure what is the need of interpreter in
this case."

See above.

Cheers,
Gary


If you really want this, keep on bringing it up here and on the ML.
                
> Null safe Navigation in ObjectUtils
> -----------------------------------
>
>                 Key: LANG-790
>                 URL: https://issues.apache.org/jira/browse/LANG-790
>             Project: Commons Lang
>          Issue Type: New Feature
>            Reporter: Gokul Nanthakumar C
>
> Adding a method for null safe navigation of objects will be very helpful. for example
a method like
> ObjectUtils.getValue(Object obj, String "path", String defaultValue); 
> ex :ObjectUtils.getValue(myObject, "x.y.z", "default");
> it will navigate in the myObject like myObject.getX().getY().getZ(), if any thing in
the path is null (x,y or z), it will return the default value.
> It will be really useful, it is like null safe navigation in groovy.

--
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

        

Mime
View raw message