Vojtech Szocs has posted comments on this change.

Change subject: webadmin: User Event Notification dialog element IDs
......................................................................


Patch Set 2: (2 inline comments)

Thanks guys, see my comments inline.

....................................................
File 
frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/utils/ElementIdUtils.java
Line 68:     }
Line 69: 
Line 70:     private static <M extends TreeNodeModel<?, M>> int 
getRootNodeIndex(M node, List<M> rootNodes) {
Line 71:         for (M root : rootNodes) {
Line 72:             if (node == root) {
Alex, in general you're right, logical equality (equals method) is typically 
preferred over referential equality (== operator), given that 
java.lang.Object.equals method falls back to reference comparison.

However, in this particular case, referential equality is technically 
sufficient. Parent/child relationship via reference is initialized in 
SimpleSelectionTreeNodeModel constructor ("child.parent = this"). So 
technically it's safe to do reference comparison here.

However, as I wrote above, equals method is typically preferred. This patch is 
actually the first one in a series of 3 patches to add element IDs to all 
CellTree instances. In the 3rd patch [http://gerrit.ovirt.org/#/c/14165/] you 
can see that I modified ElementIdUtils [getRootNodeIndex + getTreeNodeIndex] to 
use equals method instead of == operator.

Long story short, even though reference comparison is technically sufficient 
here, I changed this code to use equals method in upcoming patch.
Line 73:                 return rootNodes.indexOf(root);
Line 74:             }
Line 75:         }
Line 76:         if (node.getParent() != null) {


....................................................
File 
frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/uicommon/model/SimpleSelectionTreeNodeModel.java
Line 96:         }
Line 97: 
Line 98:         ArrayList<SimpleSelectionTreeNodeModel> siblings = 
parent.getChildren();
Line 99:         for (int i = 0; i < siblings.size(); i++) {
Line 100:             if (model == siblings.get(i).model) {
Please see my comment in ElementIdUtils.java, even though reference comparison 
is technically sufficient here, I changed this code to use equals method in 
upcoming patch.
Line 101:                 return i;
Line 102:             }
Line 103:         }
Line 104: 


--
To view, visit http://gerrit.ovirt.org/14048
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: Icf18b0080fffe6ba3886736a605f53570889bf3a
Gerrit-PatchSet: 2
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Vojtech Szocs <[email protected]>
Gerrit-Reviewer: Alexander Wels <[email protected]>
Gerrit-Reviewer: Daniel Erez <[email protected]>
Gerrit-Reviewer: Einav Cohen <[email protected]>
Gerrit-Reviewer: Tomas Jelinek <[email protected]>
Gerrit-Reviewer: Vojtech Szocs <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to