]>
git.argeo.org Git - lgpl/argeo-commons.git/blob - eclipse/runtime/org.argeo.eclipse.ui.jcr/src/main/java/org/argeo/eclipse/ui/jcr/utils/NodeViewerComparer.java
1 package org
.argeo
.eclipse
.ui
.jcr
.utils
;
4 import javax
.jcr
.RepositoryException
;
6 import org
.argeo
.ArgeoException
;
7 import org
.eclipse
.jface
.viewers
.IElementComparer
;
9 public class NodeViewerComparer
implements IElementComparer
{
11 // force comparison on Node IDs only.
12 public boolean equals(Object elementA
, Object elementB
) {
13 if (!(elementA
instanceof Node
) || !(elementB
instanceof Node
)) {
14 return elementA
== null ? elementB
== null : elementA
18 boolean result
= false;
20 String idA
= ((Node
) elementA
).getIdentifier();
21 String idB
= ((Node
) elementB
).getIdentifier();
22 result
= idA
== null ? idB
== null : idA
.equals(idB
);
23 } catch (RepositoryException re
) {
24 throw new ArgeoException("cannot compare nodes", re
);
31 public int hashCode(Object element
) {
32 // TODO enhanced this method.
33 return element
.getClass().toString().hashCode();