]>
git.argeo.org Git - lgpl/argeo-commons.git/blob - jcr/org.argeo.cms.ui/src/org/argeo/eclipse/ui/jcr/NodeElementComparer.java
1 package org
.argeo
.eclipse
.ui
.jcr
;
4 import javax
.jcr
.RepositoryException
;
6 import org
.argeo
.eclipse
.ui
.EclipseUiException
;
7 import org
.eclipse
.jface
.viewers
.IElementComparer
;
9 /** Element comparer for JCR node, to be used in JFace viewers. */
10 public class NodeElementComparer
implements IElementComparer
{
12 public boolean equals(Object a
, Object b
) {
14 if ((a
instanceof Node
) && (b
instanceof Node
)) {
15 Node nodeA
= (Node
) a
;
16 Node nodeB
= (Node
) b
;
17 return nodeA
.getIdentifier().equals(nodeB
.getIdentifier());
21 } catch (RepositoryException e
) {
22 throw new EclipseUiException("Cannot compare nodes", e
);
26 public int hashCode(Object element
) {
28 if (element
instanceof Node
)
29 return ((Node
) element
).getIdentifier().hashCode();
30 return element
.hashCode();
31 } catch (RepositoryException e
) {
32 throw new EclipseUiException("Cannot get hash code", e
);