Return-Path: X-Original-To: apmail-commons-issues-archive@minotaur.apache.org Delivered-To: apmail-commons-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 3414C9043 for ; Wed, 7 Mar 2012 16:41:24 +0000 (UTC) Received: (qmail 66665 invoked by uid 500); 7 Mar 2012 16:41:23 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 64935 invoked by uid 500); 7 Mar 2012 16:41:20 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 64904 invoked by uid 99); 7 Mar 2012 16:41:20 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 07 Mar 2012 16:41:20 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED,T_RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.116] (HELO hel.zones.apache.org) (140.211.11.116) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 07 Mar 2012 16:41:18 +0000 Received: from hel.zones.apache.org (hel.zones.apache.org [140.211.11.116]) by hel.zones.apache.org (Postfix) with ESMTP id 83CF2E834 for ; Wed, 7 Mar 2012 16:40:58 +0000 (UTC) Date: Wed, 7 Mar 2012 16:40:58 +0000 (UTC) From: "Gary D. Gregory (Commented) (JIRA)" To: issues@commons.apache.org Message-ID: <1001370147.34750.1331138458541.JavaMail.tomcat@hel.zones.apache.org> In-Reply-To: <1811406197.19071.1330828437347.JavaMail.tomcat@hel.zones.apache.org> Subject: [jira] [Commented] (LANG-790) Null safe Navigation in ObjectUtils MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 X-Virus-Checked: Checked by ClamAV on apache.org [ 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