[dna-issues] [JBoss JIRA] Commented: (DNA-448) The 'createIfMissing()' methods should be removed from the Graph API
Brian Carothers (JIRA)
jira-events at lists.jboss.org
Sat Jul 4 15:59:51 EDT 2009
[ https://jira.jboss.org/jira/browse/DNA-448?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12474896#action_12474896 ]
Brian Carothers commented on DNA-448:
-------------------------------------
Actually, returning the GetNodeConjunction interface would cause problems for batch create, as it could potentially require the newly created node to be returned before the batch was executed. E.g.,
Path path = ... ; // Path to a node that doesn't yet exist
Graph.Batch batch = ....;
batch.create(path).ifAbsent().andReturn().getNode(); // Can't return anything yet as we don't even know if the node exists until the batch executes
...
batch.execute();
Based on this, I'm going to commit the patch and leave the defect open for feedback and comment.
> The 'createIfMissing()' methods should be removed from the Graph API
> --------------------------------------------------------------------
>
> Key: DNA-448
> URL: https://jira.jboss.org/jira/browse/DNA-448
> Project: DNA
> Issue Type: Bug
> Components: API, Graph
> Affects Versions: 0.4
> Reporter: Randall Hauch
> Fix For: 0.6
>
> Attachments: DNA-448.patch
>
>
> This issue stemmed from DNA-443. The existence of the "createIfMissing()" methods that exist only on the Graph interface (and not the Graph.Batch interface) mask the existence of newer, more powerful methods that can do the same thing on Graph and Graph.Batch:
> graph.create(path).ifAbsent()...
> or
> batch.create(path).ifAbsent()...
> In fact, this style makes available several other methods than "ifAbsent()", such as "orUpdate()", "byAppending()", and "orReplace()". These correspond to the different NodeConflictBehavior options.
> Unfortunately, the 'create()' methods just return the Conjunction interface, while the 'createIfMissing()' methods return the "GetNodeConjunction" interface (which extends Conjunction and adds the "andReturn():Node" method). And there is at least one place where 'createIfMissing(...).andReturn()' is being called. Looking at this now, I'm not sure why the Graph.create(...) methods can't return the GetNodeConjunction interface. This would allow the existing uses of the 'createIfMissing(...).andReturn()' to replace them with 'create(...).ifAbsent().andReturn()' calls, and enable the removal of the 'createIfMissing(...)' methods.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the dna-issues
mailing list