Hello,

I'm new to Neo && presume the post fits better here than on SO && feeling 
courageous.


I wrote an app to update my graph via the REST API (using 
org.neo4j.rest.graphdb.RestGraphDatabase).

My use case is getting nodes I previously created to set a property which 
is absent (or not).

1/
Naturally, I wrote 
    if (node.getProperty("propLabel") == null) 
 departement.setProperty("propLabel", "whatever");

but getProperty throws a NotFoundException this leads to writing the 
following code 

try{
   if (node.getProperty("propLabel") != null && 
!node.getProperty("propLabel").equals("something"))  
           departement.setProperty("propLabel", "whatever"); 
}catch(NotFoundException e){
   departement.setProperty("propLabel", "whatever");  // SAME CODE HERE !! 
OH NO !!!
}

See, code repetition.
And a costly catch.

Pattern to be repeated for each different property to add/update...

Of course, I could use a wrapper to hide this in an util class of mine but 
that would not fix it.
Therefore, I propose that *Node.getProperty() should return null*.

Is The Architect reading this ?  ;)

Best Regards,

@wadael






-- 
You received this message because you are subscribed to the Google Groups 
"Neo4j" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to