]>
git.argeo.org Git - lgpl/argeo-commons.git/blob - org.argeo.eclipse.ui.jcr/src/main/java/org/argeo/eclipse/ui/jcr/NodeElementComparer.java
2 * Copyright (C) 2007-2012 Argeo GmbH
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package org
.argeo
.eclipse
.ui
.jcr
;
18 import javax
.jcr
.Node
;
19 import javax
.jcr
.RepositoryException
;
21 import org
.argeo
.ArgeoException
;
22 import org
.eclipse
.jface
.viewers
.IElementComparer
;
24 /** Element comparer for JCR node, to be used in JFace viewers. */
25 public class NodeElementComparer
implements IElementComparer
{
27 public boolean equals(Object a
, Object b
) {
29 if ((a
instanceof Node
) && (b
instanceof Node
)) {
30 Node nodeA
= (Node
) a
;
31 Node nodeB
= (Node
) b
;
32 return nodeA
.getIdentifier().equals(nodeB
.getIdentifier());
36 } catch (RepositoryException e
) {
37 throw new ArgeoException("Cannot compare nodes", e
);
41 public int hashCode(Object element
) {
43 if (element
instanceof Node
)
44 return ((Node
) element
).getIdentifier().hashCode();
45 return element
.hashCode();
46 } catch (RepositoryException e
) {
47 throw new ArgeoException("Cannot get hash code", e
);