#124

add helper method for dealing with navigating through legacy java object graphs which might throw NullPointerException

    • Created on: Fri, Aug 06 2010 (almost 2 years ago)
    • Reported by: jstrachan
    • Assigned to: jstrachan
    • Milestone: -
    • Estimate: None/Small/Medium/Large None
    • Status: New
    • Priority: Normal (3)
    • Component: -
    • Permission type: Private
    We have the elvis operator for dealing with nulls on an expression
    foo ?: "default value"

    however this doesnt work when you want to do
    foo.bar.whatnot

    the code is messy. So a helper method something like
    orElse(foo.bar.whatnot, "default value")

    might help - catching NullPointerExceptions along the way for you (with maybe debug logging if you want to search and find them)
  • Followers
     
    Ico-users jstrachan (Assigned To) 
     
    Attachments
    No attachments
    Associations
     
    No associations
    Activity
     
    User picture

          on Aug 06, 2010 @ 03:43pm UTC * By jstrachan

    Description changed from We have the elvis operator ... to We have the elvis operator ...
    User picture

          on Aug 06, 2010 @ 03:44pm UTC * By jstrachan

    Description changed from We have the elvis operator ... to We have the elvis operator ...
    User picture

          on Aug 06, 2010 @ 03:54pm UTC * By jstrachan

    Description changed from We have the elvis operator ... to We have the elvis operator ...
    User picture

          on Aug 06, 2010 @ 03:55pm UTC * By jstrachan

    Assigned to set to jstrachan
    (In revision:19120cdd3226fdc4cb6600c15ac7fce8625db7dc) added a helper orElse() method re #124

    Branch: master
    Time Expenditure
    Loading